Skip to content

Update lib.es5.d.ts #30219

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

Conversation

ahmedkamalio
Copy link

Update JSON.parse to accept optional type parameter and return this type "any by default".

Example:

let parsedObj = JSON.parse<TypeObj>("{ prop: 'val' }"); // parsedObj is TypeObj

is way better than

let parsedObj = JSON.parse("{ prop: 'val' }"); // parsedObj is any

Fixes #

updated

parse(text: string, reviver?: (key: any, value: any) => any): any;

to

parse<T = any>(text: string, reviver?: (key: any, value: any) => any): T;

Update JSON.parse to accept optional type parameter and return this type "any by default"
@typescript-bot
Copy link
Collaborator

It looks like you've sent a pull request to update our 'lib' files. These files aren't meant to be edited by hand, as they consist of last-known good states of the compiler and are generated from 'src'. Unless this is necessary, consider closing the pull request and sending a separate PR to update 'src'.

@j-oliveras
Copy link
Contributor

j-oliveras commented Mar 5, 2019

Already discussed and rejected as Working as intended: #26993 and #26994. Last times someone tried to change it: #28416 and #26994.

@ahmedkamalio ahmedkamalio deleted the update-JOSN-parse-return-type branch March 5, 2019 15:37
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.

3 participants