Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update typescript signature for stringify method #1

Merged
merged 2 commits into from
Sep 4, 2018

Conversation

c4ndybar
Copy link
Contributor

The signature for stringify only had the first parameter. The replacer and space parameters were not included. This PR updates the signature to match the sig of JSON.stringify.

@c4ndybar
Copy link
Contributor Author

The workaround for anyone experiencing this issue is to cast the stringify function to type any so the compiler doesn't get angry.

import stringify from `safe-stable-stringify`

let serialized = (stringify as any)(obj, replacer, space)

@@ -1,3 +1,3 @@
declare function stringify(data: any): string;
declare function stringify(value: any, replacer?: (key: string, value: any) => any, space?: string | number): string;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The replacer could also be an array of strings or numbers.

@BridgeAR
Copy link
Owner

@c4ndybar thanks a lot for your contribution! This is definitely already an improvement as I forgot about that. Would you be so kind and also add the array replacer?

@BridgeAR BridgeAR merged commit 7a87478 into BridgeAR:master Sep 4, 2018
@c4ndybar c4ndybar deleted the update-sig branch February 4, 2019 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants