question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No error for undeclared #private property in `.js` files

See original GitHub issue
class 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:open
  • Created 4 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
DanielRosenwassercommented, Jan 2, 2020

(CC @robpalme in case anyone on the team is interested)

0reactions
sandersncommented, Jan 8, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found