diff --git a/packages/documentation/copy/en/javascript/JSDoc Reference.md b/packages/documentation/copy/en/javascript/JSDoc Reference.md index 76bdfc182523..0642f3090fdc 100644 --- a/packages/documentation/copy/en/javascript/JSDoc Reference.md +++ b/packages/documentation/copy/en/javascript/JSDoc Reference.md @@ -16,6 +16,7 @@ Note: #### Types - [`@type`](#type) +- [`@import`](#import) - [`@param`](#param-and-returns) (or [`@arg`](#param-and-returns) or [`@argument`](#param-and-returns)) - [`@returns`](#param-and-returns) (or [`@return`](#param-and-returns)) - [`@typedef`](#typedef-callback-and-param) @@ -23,7 +24,6 @@ Note: - [`@template`](#template) - [`@satisfies`](#satisfies) - #### Classes - [Property Modifiers](#property-modifiers) `@public`, `@private`, `@protected`, `@readonly` @@ -198,7 +198,8 @@ function walk(p) { } ``` -import types can be used in type alias declarations: +import types can be used in type alias declarations (though an +[`@import`](#import) declaration may be preferable): ```js twoslash // @filename: types.d.ts @@ -240,6 +241,30 @@ export const userAccount = { var x = require("./accounts").userAccount; ``` +### `@import` + +Rather than write out full [import types](#import), which can become cumbersome, +you can use `@import` to import a type from another file, exactly as you would +use an ECMAScript `import`: + +```js twoslash +// @filename: types.d.ts +export type Pet = { + name: string, +}; +// @filename: main.js +// ---cut--- +/** + * @import { Pet } from "./types" + */ + +/** + * @type {Pet} + */ +var myPet; +myPet.name; +``` + ### `@param` and `@returns` `@param` uses the same type syntax as `@type`, but adds a parameter name.