DefinitelyTyped/types/jsonpack/jsonpack-tests.ts
2019-05-15 12:34:25 -07:00

14 lines
480 B
TypeScript

import * as jsonpack from 'jsonpack';
const obj = { myString: 'myStringValue' };
jsonpack.pack(obj); // $ExpectType string
jsonpack.pack(obj, { verbose: true }); // $ExpectType string
jsonpack.pack(JSON.stringify(obj)); // $ExpectType string
jsonpack.pack(JSON.stringify(obj), { debug: true }); // $ExpectType DebugObject
const packed = 'packed-string-here';
jsonpack.unpack(packed); // $ExpectType {}
jsonpack.unpack<string>(packed, { verbose: true }); // $ExpectType string