JSDoc tag

@import

  • Checked by TypeScript
  • Since TypeScript 5.5

/** @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

cart.js cart.ts TypeScript 5.9.3 TypeScript 5.9.3, run 21 October 2026: No errors. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. No errors. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. No errors. checked 21 October 2026
/** @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);
Importing types from another module with @import.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "nodenext",
    "types": []
  },
  "include": ["*.js"]
}
cart.js Error confirmed 5.9.3 TypeScript 5.9.3, run 21 October 2026: cart.js(2,15): error TS2724: '"./models.js"' has no exported member named 'Prodcut'. Did you mean 'Product'? 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. cart.js(2,15): error TS2724: '"./models.js"' has no exported member named 'Prodcut'. Did you mean 'Product'? 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. cart.js(2,15): error TS2724: '"./models.js"' has no exported member named 'Prodcut'. Did you mean 'Product'? checked 21 October 2026
/** @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;
}
Importing a name the module does not export.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "nodenext",
    "types": []
  },
  "include": ["*.js"]
}
cart.js Error confirmed 5.9.3 TypeScript 5.9.3, run 21 October 2026: cart.js(9,26): error TS1361: 'Cart' cannot be used as a value because it was imported using 'import type'. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. cart.js(9,26): error TS1361: 'Cart' cannot be used as a value because it was imported using 'import type'. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. cart.js(9,26): error TS1361: 'Cart' cannot be used as a value because it was imported using 'import type'. checked 21 October 2026
/** @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'.
An @import name is a type, not a value.
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 @import line (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 import statement; a class imported that way is usable both as a value and as a type.
  • The error for using an @import name as a value talks about import 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

Last reviewed 20 October 2026.