No error for undeclared #private property in `.js` files
See original GitHub issueclass Thing {
/**
* @param prop {string}
*/
constructor(prop) {
this.#prop = prop;
}
}
This class assigns to #prop
, but it’s an error to use #prop
without declaring it.
This is reported as a SyntaxError
, so this should report an error even outside of checkJs
.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Incorrect quick fix for undeclared private field in javascript files ...
name = name; } } Trigger the initialize property name quick fix Expected behavior: ... No error for undeclared #private property in .js...
Read more >Why does accessing a non-existent object property result in ...
Accessing an object property that doesn't exist gives you undefined , not an error. It's just the way the language is designed. One...
Read more >Private class features - JavaScript - MDN Web Docs - Mozilla
If you access a private property from an object that doesn't have the property, a TypeError is thrown, instead of returning undefined as...
Read more >Solve JavaScript Error before it happens [strict mode] - Atatus
Variables must be declared before they can be assigned to. Without strict mode, assigning a value to an undeclared variable automatically ...
Read more >Google JavaScript Style Guide
A JavaScript source file is described as being in Google Style if and only if ... Non-exported module-local symbols are not declared @private...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
(CC @robpalme in case anyone on the team is interested)
I don’t think this should be an error in JS without checkJs on. We don’t report errors for assignment to const either, which is another error that can be lexically determined as well.