Skip to content

Instantly share code, notes, and snippets.

@ifyour
Created January 11, 2021 04:22
Show Gist options
  • Save ifyour/d5c904a6b0b5c548d9cc4d76783d071e to your computer and use it in GitHub Desktop.
Save ifyour/d5c904a6b0b5c548d9cc4d76783d071e to your computer and use it in GitHub Desktop.
JSON 操作不丢失类型
declare class Stringified<T> extends String {
private ___stringified: T
}
interface JSON {
stringify<T>(
value: T,
replacer?: (key: string, value: any) => any,
space?: string | number
): string & Stringified<T>
parse<T>(text: Stringified<T>, reviver?: (key: any, value: any) => any): T
parse(text: string, reviver?: (key: any, value: any) => any): any
}
@ifyour
Copy link
Author

ifyour commented Apr 10, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment