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

fix(60908): Unexpected "'Type' is declared but its value is never read." error with jsdoc @import syntax #60921

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add tests
a-tarasyuk committed Jan 19, 2025
commit 58f9d2f24e2aa2d72c122a069f7d69ff00369702
25 changes: 25 additions & 0 deletions tests/baselines/reference/importTag25.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//// [tests/cases/conformance/jsdoc/importTag25.ts] ////

=== types.d.ts ===
export type T = {
>T : Symbol(T, Decl(types.d.ts, 0, 0))

a: number;
>a : Symbol(a, Decl(types.d.ts, 0, 17))

};

=== foo.js ===
/** @import { T } from "./types.d.ts" */

export default async function f() {
>f : Symbol(f, Decl(foo.js, 0, 0))

/** @type {T[]} */
const types = [];
>types : Symbol(types, Decl(foo.js, 4, 6))

return types;
>types : Symbol(types, Decl(foo.js, 4, 6))
}

32 changes: 32 additions & 0 deletions tests/baselines/reference/importTag25.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//// [tests/cases/conformance/jsdoc/importTag25.ts] ////

=== types.d.ts ===
export type T = {
>T : T
> : ^

a: number;
>a : number
> : ^^^^^^

};

=== foo.js ===
/** @import { T } from "./types.d.ts" */

export default async function f() {
>f : () => Promise<T[]>
> : ^^^^^^^^^^^^^^^^^^

/** @type {T[]} */
const types = [];
>types : T[]
> : ^^^
>[] : undefined[]
> : ^^^^^^^^^^^

return types;
>types : T[]
> : ^^^
}

18 changes: 18 additions & 0 deletions tests/cases/conformance/jsdoc/importTag25.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// @noUnusedLocals: true
// @allowJs: true
// @checkJs: true
// @noEmit: true

// @filename: types.d.ts
export type T = {
a: number;
};

// @filename: foo.js
/** @import { T } from "./types.d.ts" */

export default async function f() {
/** @type {T[]} */
const types = [];
return types;
}