Microsoft/TypeScript
在 GitHub 查看JSDoc: property access within static initialization block of @extends annotated class from different file
Open
#58,943 建立於 2024年6月20日
BugDomain: JSDocHelp Wanted
倉庫指標
- Star
- (48,455 star)
- PR 合併指標
- (平均合併 6天 17小時) (30 天內合併 9 個 PR)
描述
🔎 Search Terms
"jsdoc class @extends", "static initialization block", "static properties/methods", "class extends", "class is referenced directly or indirectly in its own base expression"
🕗 Version & Regression Information
- Static initialization blocks don't seem to be supported on versions
<= 4.3.5 - From
4.4.2to4.6.4everything seems to work fine - types are correct and no linting errors - Every version from
4.7.2onwards has the behaviour described in this issue
⏯ Playground Link
No response
💻 Code
a.js:
export class A {
static a() {}
}
b.js:
// @ts-check
import { A } from "./a";
/**
* @extends A
*/
export class B extends A { // 'B' is referenced directly or indirectly in its own base expression.ts(2506)
static {
B.a(); // Property 'a' does not exist on type 'typeof B'. ts(2339)
}
constructor() {
super();
B.a(); // Property 'a' does not exist on type 'typeof B'. ts(2339)
}
b() {
B.a(); // Property 'a' does not exist on type 'typeof B'. ts(2339)
}
c = () => {
B.a(); // Property 'a' does not exist on type 'typeof B'. ts(2339)
};
static d() {
B.a(); // Property 'a' does not exist on type 'typeof B'. ts(2339)
}
get e() {
B.a(); // Property 'a' does not exist on type 'typeof B'. ts(2339)
return;
}
set e(value) {
B.a(); // Property 'a' does not exist on type 'typeof B'. ts(2339)
}
}
🙁 Actual behavior
- Linting error under extending class's name:
'B' is referenced directly or indirectly in its own base expression.. - Linting error/unknown type for any use of
B.a().
🙂 Expected behavior
B.a() type is correct across files with no linting errors.
Additional information about the issue
- Removing
@extendsfixes the issue - Removing
B.a()from thestaticblock fixes the issue - Defining
Ain the same file fixes the issue
Possibly related to #51786.