-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
JSON parse works with type Buffer #44944
Comments
Same as #17203 and moreover |
This is just an implicit coercion, not anything |
Literally false, see the spec step 1: |
I'm curious what you think an implicit coercion is? |
Everything you said is true. But I still think the original comment has some point. It should not be a TS error to pass a Buffer to |
If you have a raw const b = Buffer.from("{}", "utf-16le");
JSON.parse(b); // throws |
lib Update Request
Configuration Check
My compilation target is
ES2015
and my lib isthe default
.Missing / Incorrect Definition
parse(text: string, reviver?: (this: any, key: string, value: any) => any): any;
Sample Code
const object = JSON.parse(readFileSync("sample.json"));
Documentation Link
https://262.ecma-international.org/5.1/#sec-15.12.2
https://github.com/nodejs/node/blob/c41c09375b217d9daec614edb590147b14ff9b21/lib/buffer.js#L405
Suggestion
parse(text: string | Buffer, reviver?: (this: any, key: string, value: any) => any): any;
The text was updated successfully, but these errors were encountered: