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

Add support for @import #1226

Closed
Arkellys opened this issue May 9, 2024 · 7 comments · Fixed by #1227 or abdulrahman305/mockoon#4 · May be fixed by junsulee/juice-shop#4
Closed

Add support for @import #1226

Arkellys opened this issue May 9, 2024 · 7 comments · Fixed by #1227 or abdulrahman305/mockoon#4 · May be fixed by junsulee/juice-shop#4

Comments

@Arkellys
Copy link

Arkellys commented May 9, 2024

Clone of this feature request, originally posted on jsdoc-type-pratt-parser.

Motivation

Typescript v5.5 introduces the tag @import, which allows importing types (or other stuff) within JSDoc:

/** @import { SomeType } from "some-module" */

Would it be possible to add support for this new syntax?

Current behavior

With mode: "typescript"

types.js

export const allowImports = true; // Trick to allow importing

/** @typedef {string} TestOne */
/** @typedef {string} TestTwo */

other.js

/**
 * @import { TestOne, TestTwo } from "./types"  🡒  Syntax error in type: TestOne, TestTwo eslint(jsdoc/valid-types)
 * @import { TestOne } from "./types"  🡒  The type 'TestOne' is undefined. eslint(jsdoc/no-undefined-types)
 * @import * as Types from "./types"  🡒  No error
 */

// And regardless of the import used: 

/** 
 * @typedef {TestOne} Test  🡒  The type 'TestOne' is undefined. eslint(jsdoc/no-undefined-types)
 */ 

Except for the errors, the imports works well.

Desired behavior

Being able to use @import without errors.

@brettz9
Copy link
Collaborator

brettz9 commented May 9, 2024

To replicate, I will need your full ESLint config and details (e.g., version of eslint-plugin-jsdoc).

@Arkellys
Copy link
Author

Arkellys commented May 9, 2024

To replicate, I will need your full ESLint config and details (e.g., version of eslint-plugin-jsdoc).

Oh yes sorry, I put it on the other issue and I forgot to add it here, my full config + version used is available on this repository. The JSDoc config specifically is on this file.

To use the latest TypeScript features, I'm using the VSCode plugin JavaScript and TypeScript Nightly.

@brettz9

This comment was marked as outdated.

@brettz9

This comment was marked as outdated.

Copy link

github-actions bot commented May 9, 2024

🎉 This issue has been resolved in version 48.2.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

@brettz9
Copy link
Collaborator

brettz9 commented May 9, 2024

The no-undefined-types rule is currently discouraged if you are using TypeScript checking (which checks for undefined types anyways). If you change your config to "recommended-typescript-flavor" or "recommended-typescript-flavor-error" (for JavaScript; if using TypeScript syntax, use "recommended-typescript" or "recommended-typescript-error"), this rule will be disabled and you will not see the error.

@Arkellys
Copy link
Author

Arkellys commented May 9, 2024

All right, thank you for the information, and the fix! I'll see about adjusting my configuration. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment