You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"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.2 to 4.6.4 everything seems to work fine - types are correct and no linting errors
Every version from 4.7.2 onwards has the behaviour described in this issue
⏯ Playground Link
No response
💻 Code
a.js:
exportclassA{statica(){}}
b.js:
// @ts-checkimport{A}from"./a";/** * @extends A */exportclassBextendsA{// '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)};staticd(){B.a();// Property 'a' does not exist on type 'typeof B'. ts(2339)}gete(){B.a();// Property 'a' does not exist on type 'typeof B'. ts(2339)return;}sete(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 @extends fixes the issue
Removing B.a() from the static block fixes the issue
The text was updated successfully, but these errors were encountered:
Daniel-Knights
changed the title
JSDoc: property access within static initialization block of @extends annotated class
JSDoc: property access within static initialization block of @extends annotated class from different file
Jun 20, 2024
JSDoc is bound as a child of its associated declaration and static block declarations are bound as immediately invoked when binding the declaration itself. So this @extends has a flow node pointing to the body of the static block. So when the class' type is requested it tries to resolve the flow node of the super class it received, which leads to resolving the type of the class' in the static block (this bit is circular here).
It's a bug, I'm just saying what happens internally that it's there 😉
🔎 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
<= 4.3.5
4.4.2
to4.6.4
everything seems to work fine - types are correct and no linting errors4.7.2
onwards has the behaviour described in this issue⏯ Playground Link
No response
💻 Code
a.js
:b.js
:🙁 Actual behavior
'B' is referenced directly or indirectly in its own base expression.
.B.a()
.🙂 Expected behavior
B.a()
type is correct across files with no linting errors.Additional information about the issue
@extends
fixes the issueB.a()
from thestatic
block fixes the issueA
in the same file fixes the issuePossibly related to #51786.
The text was updated successfully, but these errors were encountered: