Skip to content
Closed
Changes from all commits
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
29 changes: 27 additions & 2 deletions packages/documentation/copy/en/javascript/JSDoc Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ 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)
- [`@callback`](#typedef-callback-and-param)
- [`@template`](#template)
- [`@satisfies`](#satisfies)


#### Classes

- [Property Modifiers](#property-modifiers) `@public`, `@private`, `@protected`, `@readonly`
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down