JSON.ts
TypeScript ambient type information for compile-time validation of JSON objects.
How to use this
- Install this package
npm install --save-dev json-typescript
- Include this module in your
tsconfig.json
's typeRoots
{
"compilerOptions": {
"typeRoots": [
"node_modules/@types",
"node_modules/json-typescript"
]
},
"exclude": [
"node_modules"
]
}
- check to see if json types are validated correctly
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.