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.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
- check to see if json types are validated correctly
import 'json.ts';
let doc: JSON.Value = {
data: {
type: 'articles',
id: '1'
}
};
let doc: JSON.Value = {
foo() {
return bar;
}
};
let doc: JSON.Object = [];
Copyright
© 2017 Mike North, All Rights Reserved.