Microsoft/TypeScript
Ver no GitHubClass marked as unused when used in a static block
Open
#57.620 aberto em 3 de mar. de 2024
BugDomain: LS: Suggestion DiagnosticsHelp Wanted
Métricas do repositório
- Stars
- (48.455 stars)
- Métricas de merge de PR
- (Mesclagem média 6d 17h) (9 fundiu PRs em 30d)
Description
🔎 Search Terms
class unused static field block
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
💻 Code
let BluethootDevice_create;
class BluethootDevice {
#id!: string;
static #allowConstruct = false;
private constructor() {
if (!BluethootDevice.#allowConstruct) {
throw new Error("You cannot instantiate this class directly");
}
}
static {
BluethootDevice_create = (id: string) => {
BluethootDevice.#allowConstruct = true;
const device = new BluethootDevice();
BluethootDevice.#allowConstruct = false;
device.#id = id;
return device;
};
}
get id() {
return this.#id;
}
}
let a = 2;
BluethootDevice_create("aa");
export {}
🙁 Actual behavior
The class BluethootDevice is marked as unused, but it's used by the BluethootDevice_create function
🙂 Expected behavior
BluethootDevice should not be marked as unused
Additional information about the issue
No response