-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Add ability to JSON.parse
function to specify the return type
#30220
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
Comments
While So there will be no difference between adding generic type to |
@hejkerooo here's a real-world example
How can your solution solve it? |
But you shouldn't return undefined, consider throwing an error or try nullable pattern edit |
@hejkerooo so, for a service file that contains about ten methods like this one I'm going to define ten types separately!!! |
I think this is what a type assertion is for.
|
I think, this is a point of strongly typed languages |
@j-oliveras but #26994 and #28416 discussing solutions that don't make sense, can you please refer to #30219, see the changes and tell me what you think?! |
There's already a place to put that:
|
@RyanCavanaugh you're right 😅 |
Search Terms
Suggestion
Add the ability to
JSON.parse
function to specify the return type, I already opened a PR #30219, implementing this featureUse Cases
is way better than
Examples
that said in the use cases ¯_(ツ)_/¯
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: