DefinitelyTyped/types/fast-json-stable-stringify/fast-json-stable-stringify-tests.ts
2018-12-24 16:18:24 +01:00

21 lines
573 B
TypeScript

import stringify = require('fast-json-stable-stringify');
const obj = { c: 8, b: [{ z: 6, y: 5, x: 4 }, 7], a: 3 };
stringify(obj); // $ExpectType string
// $ExpectType string
stringify(obj, (a, b) => {
a; // $ExpectType CompareDescriptor
b; // $ExpectType CompareDescriptor
return a.key < b.key ? 1 : -1;
});
// $ExpectType string
stringify(obj, {
cmp(a, b) {
a; // $ExpectType CompareDescriptor
b; // $ExpectType CompareDescriptor
return a.key < b.key ? 1 : -1;
},
});
stringify(obj, { cycles: true }); // $ExpectType string