JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2718
  • Score
    100M100P100Q114741F
  • License MIT

TypeScript type definitions for JSON objects

Package Exports

  • json-typescript

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (json-typescript) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

JSON-typescript

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

Greenkeeper badge

How to use this

  1. Install this package
npm install --save-dev json-typescript
  1. Import this package
import _JSON from 'json-typescript';
  1. Check to see if json types are validated correctly
import _JSON from 'json-typescript';

// ✅ 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 = [];

© 2018 Mike North, All Rights Reserved.