Last active
July 20, 2018 02:59
-
-
Save kevincharm/f7b22113588ec161cfe35e152c33fc69 to your computer and use it in GitHub Desktop.
Tagged types for JSON.stringify and JSON.parse. Extended from: https://github.com/Microsoft/TypeScript/issues/19244
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Stringified<T> { | |
private ___stringified: T | |
} | |
interface JSON { | |
stringify( | |
value: any, | |
replacer?: (key: string, value: any) => any, | |
space?: string | number | |
): string | |
stringify<T>( | |
value: T, | |
replacer?: (key: string, value: any) => any, | |
space?: string | number | |
): string & Stringified<T> | |
parse(text: string, reviver?: (key: any, value: any) => any): any | |
parse<T>(text: Stringified<T>, reviver?: (key: any, value: any) => any): T | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment