Socket
Socket
Sign inDemoInstall

json-typescript

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-typescript

JSON TypeScript type definitions


Version published
Weekly downloads
4.9K
decreased by-10.13%
Maintainers
1
Weekly downloads
 
Created
Source

JSON.ts

TypeScript type information for compile-time validation of JSON objects.

How to use this

  1. Install this package
npm install --save-dev json-typescript
  1. Import the types into the files where you wish to use them
import 'json.ts';

NOTE: You can add the types across your whole project by opening your ./global.d.ts ambient type file (or create an empty file if it doesn't yet exist) and adding the same import

  1. check to see if json types are validated correctly
import 'json.ts';

// ✅ This should be OK
let doc: JSON.Value = {
  data: {
    type: 'articles',
    id: '1'
  }
};

// ⛔️ This should NOT be OK ( functions are not allowed )
let doc: JSON.Value = {
  foo() {
    return bar;
  }
};

// ⛔️ This should NOT be OK ( Array is not a JSON.Object )
let doc: JSON.Object = [];

© 2017 Mike North, All Rights Reserved.

Keywords

FAQs

Package last updated on 16 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc