$ gnpm install ts-brand-json
TypeScript type for JSON strings.
import {JSON, json} from 'ts-brand-json';
const str = '{"hello": "world"}' as json<{hello: string}>;
JSON.parse(str).hello; // OK
JSON.parse(str).foo; // Error: ...
Copyright 2013 - present © cnpmjs.org | Home |