Skip to content

Jsdoc Type alias circularly references itself #39372

Closed
@awerlogus

Description

@awerlogus

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.

Metadata

Metadata

Assignees

Labels

Fix AvailableA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions