-
Notifications
You must be signed in to change notification settings - Fork 124
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
allow passing null
to JSON.parse()
#173
Comments
Currently the annoying hack i need to use is |
JSON.parse does call ToString(argument) before actual parse begins. https://tc39.es/ecma262/multipage/structured-data.html#sec-json.parse
Following cases are where ToString returns valid JSON values.
|
localStorage.setItem('a', null);
const result = JSON.parse(localStorage.getItem('a'));
console.log(result === null)
// true localStorage.setItem('a', "null");
const result = JSON.parse(localStorage.getItem('a'));
console.log(result === null)
// true |
The purpose is not to make every non throwing ECMAscript code pass typescript checking. |
|
I think If one wants to get advantage of string coercion this can be easily done by |
@NoamAnisfeld that makes it less typesafe. Typesafety should reflect what actually happens. |
Currently this fails type checking yet it works in all js environments I've tried.
The text was updated successfully, but these errors were encountered: