-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document the JSDoc @import tag #3170
base: v2
Are you sure you want to change the base?
Conversation
This replaces the documentation for using `@typedef` and `import()` to alias a type.
Azure Static Web Apps: Your stage site is ready! Visit it here: https://victorious-plant-05c166c10-3170.centralus.5.azurestaticapps.net |
@@ -240,6 +221,28 @@ export const userAccount = { | |||
var x = require("./accounts").userAccount; | |||
``` | |||
|
|||
### `@import` | |||
|
|||
`@import` can be used for type-only imports: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`@import` can be used for type-only imports: | |
The `@import` tag can lets us reference exports from other files. |
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
``` | |
``` | |
These tags don't actually import files at runtime, and the symbols they bring into scope can only be used within JSDoc comments for type-checking. | |
```js twoslash | |
// @filename: dog.js | |
export class Dog { | |
woof() { | |
console.log("Woof!"); | |
} | |
} | |
// @filename: main.js | |
/** @import { Dog } from "./dog.js"; | |
const d = new Dog(); // error! |
You'll need to add the appropriate expected error to that code block though.
This replaces the documentation for using
@typedef
andimport()
to alias a type.