Circular reference error happens in jsdoc but not in typescript.
See original GitHub issueBug Report
🔎 Search Terms
circularly references itself jsdoc ts2456
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about
circular
⏯ Playground Link
Playground link (js) Playground link (ts)
💻 Code
Foo.js
/** @typedef {Object.<string, Foo>} Foo */
Foo.ts
type Foo = {
[x: string]: Foo;
};
🙁 Actual behavior
Type alias 'Foo' circularly references itself. ts(2456)
happens in Foo.js
. The TypeScript equivalent works fine.
🙂 Expected behavior
Both Foo.ts
and Foo.js
work without errors.
Related issues
I found some related issues but they are either closed or use a different example.
#39372 - Closed (fixed)
#45641 - Seems very similar but uses Array<>
and typescript rather than jsdoc. I’m not sure if the root cause is the same so this might be a duplicate.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:6
Top Results From Across the Web
Circular reference error happens in jsdoc but not in typescript ...
Type alias 'Foo' circularly references itself. ts(2456) happens in Foo.js . The TypeScript equivalent works fine. Expected behavior. Both Foo.
Read more >Using `import type` statement to fix circular dependency ...
The example above will create a circular reference which currently does not work in the JavaScript runtime I'm using. The file B.js really...
Read more >Documentation - Project References - TypeScript
Project references are a new feature in TypeScript 3.0 that allow you to structure your TypeScript programs into smaller pieces.
Read more >The reasons I don't use Typescript - DEV Community
There really is no "I want to learn just enough JSDoc TS" - you've got to ... But of course such error will...
Read more >API with NestJS #61. Dealing with circular dependencies
A circular dependency between Node.js modules happens when two files ... import/no-cycle, and it ensures that no circular dependencies are ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The workaround is to use TypeScript in the JSDoc comment, rather than
Object.<string, Foo>
notation:(playground)
Seems like that’s because
Json[]
is also in there. Another way to work around this is to add an extra type just for the array:(playground)