Skip to content
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

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from

Conversation

remcohaszing
Copy link
Contributor

This replaces the documentation for using @typedef and import() to alias a type.

This replaces the documentation for using `@typedef` and `import()` to
alias a type.
@jakebailey jakebailey added the deploy-preview Enables automatic deployments to preview environments on a PR label Jun 28, 2024
Copy link
Contributor

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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`@import` can be used for type-only imports:
The `@import` tag can lets us reference exports from other files.

Comment on lines +244 to +245
```

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```
```
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.

@rwalle rwalle mentioned this pull request Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deploy-preview Enables automatic deployments to preview environments on a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants