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.ts 
TypeScript type information for compile-time validation of JSON objects.
How to use this
- Install this package
npm install --save-dev json-typescript- Import the types into the files where you wish to use them
import 'json-typescript';NOTE: You can add the types across your whole project by opening your
./global.d.tsambient type file (or create an empty file if it doesn't yet exist) and adding the same import
- check to see if json types are validated correctly
import '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 = [];Copyright
© 2017 Mike North, All Rights Reserved.