TypeScript type information for compile-time validation of JSON:API documents. Supports TS 2.3 and above.
- Install this package
npminstall--save-devjsonapi-typescript- Import this module
import*asJSONAPIfrom'jsonapi-typescript';- check to see if json types are validated correctly
import*asJSONAPIfrom'jsonapi-typescript';// ✅ This should be OKletdoc: JSONAPI.Document={data: {type: 'articles',id: '1'}};// ⛔️ This should NOT be OK ("result" is not a valid JSON:API top-level key)letdoc: JSONAPI.Document={result: "Success!"};// ⛔️ This should NOT be OK ( empty Array is not a valid JSON:API document )letdoc: JSONAPI.Document=[];© 2017 Mike North, All Rights Reserved.