JSPM

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

TypeScript definitions for JSON-API

Package Exports

  • jsonapi-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 (jsonapi-typescript) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

JSONAPI-typescript

Greenkeeper badge TypeScript type information for compile-time validation of JSON:API documents.

How to use this

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

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

// ⛔️ This should NOT be OK ("result" is not a valid JSON:API top-level key)
let doc: JSONAPI.Document = {
  result: "Success!"
};

// ⛔️ This should NOT be OK ( empty Array is not a valid JSON:API document )
let doc: JSONAPI.Document = [];

© 2017 Mike North, All Rights Reserved.