Skip to content

Instantly share code, notes, and snippets.

@ORESoftware
Last active July 8, 2018 22:48
stringifiable type with TS
export type Stringifiable = object | string | boolean | number | null;
export const stdMarker = 'gfy';
export const getJSONCanonical = function (v: Stringifiable, marker?: string) {
marker = marker || stdMarker;
return JSON.stringify({
[marker]: true,
value: v
});
};
getJSONCanonical(undefined); // no compilation error?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment