Skip to content

JSDoc @typedef not hoisted out of classes or interfaces #2002

@ahejlsberg

Description

@ahejlsberg

Steps to reproduce

Compile the following .js file with --declaration:

class C {
    /** @typedef {string} Foo */
    /** @type {Foo} */
    foo = "abc"
}

Behavior with typescript@5.8

Generates this .d.ts file:

declare class C {
    /** @typedef {string} Foo */
    /** @type {Foo} */
    foo: string;
}
type Foo = string;

Behavior with tsgo

Generates this invalid .d.ts file:

declare class C {
    type Foo = string;
    /** @typedef {string} Foo */
    /** @type {Foo} */
    foo: Foo;
}

Metadata

Metadata

Assignees

Labels

Domain: JSRelated to JS parsing, checkingbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions