Closed
Description
Bug Report
🔎 Search Terms
access static private class parameter this.constructor
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about [static, private, classes]
this probably has always been like this since its a 'new' feature
latest test on 4.7.0-dev.20220302 (nightly)
⏯ Playground Link
Playground link with relevant code
💻 Code
class Test {
static #staticPrivateField = 'test' ;
constructor() {
console.log(
this.constructor.#staticPrivateField
)
}
}
new Test();
🙁 Actual behavior
if the parameter is only static, it doesn't show the 6133 warning whether its actually used or not
the moment you make it both static + private (#
), it suddenly shows the warning.
and then if the parameter is accessed via this.constructor
it stills shows the 6133 warning (declared but value never read)
- strict check enabled (screenshot is .ts file)
Property '#staticPrivateField' does not exist on type 'Function'.ts(2339)
🙂 Expected behavior
- in javascript using
this.constructor.#staticPrivateField
should be recognized as accessing the parameter (it does work, and recommended on MDN) - strict check should recognize that this field exist on the class constructor
Metadata
Metadata
Assignees
Labels
No labels