@module inventory is a JSDoc documentation tag that names a file's module in the documentation that the JSDoc tool builds. TypeScript 5.9 does not act on it: importing "inventory" from another file still fails to resolve, because TypeScript finds modules by path and by package name, never by tag.
The tag is harmless documentation. To make a module importable by a bare name, publish it as a package (or a workspace package), map it with paths, or describe it with declare module in a .d.ts file.
At a glance
| Use | JSDoc in a .js file | TypeScript in a .ts file |
|---|---|---|
| Importing a module | import { stock } from "./inventory.js"; | import { stock } from "./inventory.js"; |
| Naming a module for consumers | // a .d.ts file
declare module "inventory" { … } | declare module "inventory" { … } |
Examples
import { stock } from "inventory";error TS2307: Cannot find module 'inventory' or its corresponding type declarations.
export const message = `${stock} in stock`;jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": ["*.js"]
} import { stock } from "./inventory.js";
export const message = `${stock} in stock`;jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": ["*.js"]
} How we tested it
The first example puts @module inventory in inventory.js and imports "inventory" from a second file. tsc reports TS2307 ("Cannot find module 'inventory' or its corresponding type declarations"). The second example imports "./inventory.js" by path and passes, with the tag still in place.
Where module names come from
A relative specifier (./inventory.js) is a path. A bare specifier (inventory) is looked up in node_modules through package.json, or in paths if the config maps it. With module: nodenext, relative imports in ES modules need the file extension, just as Node.js does at run time.
Gotchas
- Do not confuse
@modulewith themoduleandmoduleDetectionoptions injsconfig.json; those decide how files are treated, not what they are called.
Questions
Does @module change how TypeScript resolves imports?
No. TypeScript 5.9 resolves imports from the path or package name only; @module is shown in hovers and otherwise ignored.
Sources
- @module · JSDoc
- Modules: theory · TypeScript handbook
- JSDoc Reference · TypeScript handbook
Last reviewed 20 October 2026.