Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jsdoc Type alias circularly references itself #39372

Closed
awerlogus opened this issue Jul 2, 2020 · 4 comments · Fixed by #40861
Closed

Jsdoc Type alias circularly references itself #39372

awerlogus opened this issue Jul 2, 2020 · 4 comments · Fixed by #40861
Assignees
Labels
Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.

Comments

@awerlogus
Copy link

TypeScript Version: 4.0.0-dev.20200701

Search Terms: Jsdoc type alias circularly references itself

I'm trying to describe json type in .js file using jsdoc.

// Type alias 'JsonArray' circularly references itself.
/** @typedef {ReadonlyArray<Json>} JsonArray */
/** @typedef {{ readonly [key: string]: Json }} JsonRecord */
// Type alias 'Json' circularly references itself.
/** @typedef {boolean | number | string | null | JsonRecord | JsonArray | readonly []} Json */

It shows me some errors that JsonArray and Json types circularly reference to itself.

Tried the same in .ts file. There got no errors.

type JsonArray = ReadonlyArray<Json>
type JsonRecord = { readonly [key: string]: Json }
// OK
type Json = boolean | number | string | null | JsonRecord | JsonArray | readonly []

Expected behaviour: Json types in .js and .ts files should work identical.

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Jul 9, 2020
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 4.1 milestone Jul 9, 2020
@sandersn
Copy link
Member

sandersn commented Sep 30, 2020

Note that this didn't work in Typescript prior to 3.7, so it might be just a matter of making sure those changes work for JS.

Edit: For easy reference, here is the PR: #33050

@sandersn
Copy link
Member

There is code in getAliasSymbolForTypeNode for @typedef, but it doesn't work: it doesn't skip past the typedef type expression correctly.

@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Sep 30, 2020
@jcorbin
Copy link

jcorbin commented Oct 26, 2020

When will this fix be released? Will there be a 4.0.4 patch, or must we wait for 4.1 minor?

@sandersn
Copy link
Member

It's not in 4.0.5, so it'll only be in 4.1 and above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants