/** @import { Product } from "./models.js" */ makes the type Product from another module usable in the JSDoc of this file. It is the JavaScript spelling of import type: TypeScript resolves the module and checks the names, and nothing is imported when the code runs. TypeScript 5.5 added the tag.
Names imported this way are types only. They work inside JSDoc braces and nowhere else; using one as a value, such as new Cart(), is an error.
At a glance
| Use | JSDoc in a .js file | TypeScript in a .ts file |
|---|---|---|
| Named types | /** @import { Product, LineItem } from "./models.js" */ | import type { Product, LineItem } from "./models.js"; |
| A namespace | /** @import * as models from "./models.js" */ | import type * as models from "./models.js"; |
| Without the tag | /** @param {import("./models.js").Product} product */ | function f(product: import("./models.js").Product) {} |
Examples
/** @import { Product, LineItem } from "./models.js" */
/** @import * as models from "./models.js" */
/**
* @param {Product} product
* @param {number} quantity
* @returns {LineItem}
*/
export function lineFor(product, quantity) {
return { sku: product.sku, quantity, total: product.price * quantity };
}
/** @type {models.Product} */
const tee = { sku: "TEE-01", name: "Cotton tee", price: 19.5 };
lineFor(tee, 2);import type { Product, LineItem } from "./models.js";
import type * as models from "./models.js";
export function lineFor(product: Product, quantity: number): LineItem {
return { sku: product.sku, quantity, total: product.price * quantity };
}
const tee: models.Product = { sku: "TEE-01", name: "Cotton tee", price: 19.5 };
lineFor(tee, 2);jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": ["*.js"]
} /** @import { Prodcut } from "./models.js" */error TS2724: '"./models.js"' has no exported member named 'Prodcut'. Did you mean 'Product'?
/** @param {Prodcut} product */
export function priceOf(product) {
return product.price;
}jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": ["*.js"]
} /** @import { Cart } from "./cart-class.js" */
/** @param {Cart} cart */
export function itemCount(cart) {
return cart.lines.length;
}
export const empty = new Cart();error TS1361: 'Cart' cannot be used as a value because it was imported using 'import type'.jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": ["*.js"]
} The forms it takes
The text after @import is an ES import clause: named imports in braces (with as to rename) or a namespace with * as name. The module specifier is resolved exactly like a real import, so it follows your module and moduleResolution settings, file extensions included.
Put the tag in its own comment near the top of the file. It can import from .js modules with @typedefs, from .d.ts files and from packages that ship types.
Before TypeScript 5.5
Older versions use an import type inside the braces: @param {import("./models.js").Product} product, available since TypeScript 2.9. It still works and needs no tag, but it repeats the path at every use, which is why a common workaround was a local alias: /** @typedef {import("./models.js").Product} Product */.
Gotchas
- A misspelled name is reported on the
@importline (TS2724 or TS2305), and every use of it then has an error type, so fix the import first. - The tag does not import the module at run time. If you also need a value from the module, write a normal
importstatement; a class imported that way is usable both as a value and as a type. - The error for using an
@importname as a value talks aboutimport type(TS1361), because that is how TypeScript reads the tag.
Questions
How do I import a type in JSDoc?
With TypeScript 5.5 or later, /** @import { Name } from "./module.js" */ once per file. With older versions, write import("./module.js").Name inside the braces where you use it.
Sources
- TypeScript 5.5: the JSDoc @import tag · TypeScript release notes
- JSDoc Reference: @import · TypeScript handbook
- TypeScript 2.9: import types · TypeScript release notes
Last reviewed 20 October 2026.