-
Notifications
You must be signed in to change notification settings - Fork 5.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
support for JSDoc @import
#25516
Comments
Actually it looks like this is automatically handled by VSCode (and maybe other IDEs) but only in JS files. The only minor issue is a linter warning "All imports in import declaration are unused. It's possible that Deno might still need to add proper support for |
@mayank99, please allow me to pick this up again. I'm not quite sure what you're referring to when you say "this is automatically handled by VSCode": Am I correct in assuming your type checking only happens within VSCode? As far as I can tell¹, Deno itself (via ¹ tested with Deno 2.0.1 / TypeScript 5.6.2 |
Ah true, I hadn't considered type checking (although I mentioned type declarations). I'll reopen it. |
Thanks, I appreciate that. Just to confirm, and perhaps to simplify analysis, here's a reduced test case - starting with a single JS file to make sure type checking itself works as expected: 📄 /** @typedef {string | null} Entry */
/** @type {Entry[]} */
const items = [];
items.push("hello");
items.push(null);
items.push(123); // 💥 📄 {
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"noEmit": true,
"strict": true
}
} $ deno check --config ./tsconfig.json ./index.js
error: TS2345 [ERROR]: Argument of type '123' is not assignable to parameter of type 'Entry'. After moving this type definition into a separate file, Deno falsely reports everything's fine: 📄 /** @import { Entry } from "./util.js" */
/** @type {Entry[]} */
const items = [];
items.push("hello");
items.push(null);
items.push(123); // 💥 📄 /** @typedef {string | null} Entry */ $ deno check --config ./tsconfig.json ./index.js && echo OK
OK If we now replace that /** @typedef {import("./util.js").Entry} Entry */ (tested with both Deno 1.46.3 and 2.0.1) |
TypeScript 5.5 adds support for
@import
in JSDoc comments. It would be great if Deno could also support this./** @import { SomeType } from "npm:some-module" */
The text was updated successfully, but these errors were encountered: