-
Notifications
You must be signed in to change notification settings - Fork 5.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
console.log not show private members of javascript #2528
Comments
The output with the TypeScript private is irrelevant because it isn't a runtime thing, There appears to be inconstancy between Chrome and Node.js on this. Chrome 74:
Node.js 12.4:
I would have expected private members to not be logged actually, since they would be like non-enumerable properties too. But clearly there is inconsistency. |
I think private members should be invisible for runtime but visible for debug. We should clear what In my option, it should be debuger.
|
How does rust handle this? println!("object {:?}", some_object); What about in Go fmt.Printf("%+v\n", someObject) Do they display private members? |
Rust debug display log them but with no indication of their visibility: #[derive(Debug)]
pub struct Foo {
foo: i64,
pub bar: i64,
}
pub fn main() {
let foo = Foo { foo: 8, bar: 8 };
println!("{:?}", foo);
} Outputs:
|
Node's stringify has been tweaked and optimized over many years, but without private properties. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Node 15 still doesn't support this, but Chromium still does. I am not sure we can get the information from inside the isolate, as the private members shouldn't be observable, so it would require an op out to rusty_v8, which might be tricky, so this wouldn't be straight forward, but I can see the benefit. |
Relevant discussion from Node.js, including a hacky way to display private members (that I am not suggesting we implement here): nodejs/node#27404 |
test.ts
test.js
The text was updated successfully, but these errors were encountered: