This is a discrepancy vis-Γ -vis TypeScript's official tooling (i.e. tsc and the language server used by IDEs).
Combined with the fact that such silent failures are very subtle and hard to identify, this seems like a significant issue.
reduced test case
Starting with a single JS file to make sure type checking itself works as expected:
π `index.js`
```javascript
/** @typedef {string | null} Entry */
/** @type {Entry[]} */
const items = [];
items.push("hello");
items.push(null);
items.push(123); // π₯
```
π `tsconfig.json`
```json
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"noEmit": true,
"strict": true
}
}
```
```shell
$ 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:
π `index.js`
```javascript
/** @import { Entry } from "./util.js" */
/** @type {Entry[]} */
const items = [];
items.push("hello");
items.push(null);
items.push(123); // π₯
```
π `util.js`
```javascript
/** @typedef {string | null} Entry */
```
```shell
$ deno check --config ./tsconfig.json ./index.js && echo OK
OK
```
If we now replace that `@import` line with an old-style `@typedef` import, Deno correctly reports the type error again:
```javascript
/** @typedef {import("./util.js").Entry} Entry */
```
As discussed in #25516 (and also on Discord and elsewhere),
deno check
incorrectly reports type checking was successful when using TypeScript's@import
with JSDoc.This is a discrepancy vis-Γ -vis TypeScript's official tooling (i.e.
tsc
and the language server used by IDEs).Combined with the fact that such silent failures are very subtle and hard to identify, this seems like a significant issue.
reduced test case
Starting with a single JS file to make sure type checking itself works as expected: π `index.js` ```javascript /** @typedef {string | null} Entry */ /** @type {Entry[]} */ const items = []; items.push("hello"); items.push(null); items.push(123); // π₯ ``` π `tsconfig.json` ```json { "compilerOptions": { "allowJs": true, "checkJs": true, "noEmit": true, "strict": true } } ``` ```shell $ 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: π `index.js` ```javascript /** @import { Entry } from "./util.js" */ /** @type {Entry[]} */ const items = []; items.push("hello"); items.push(null); items.push(123); // π₯ ``` π `util.js` ```javascript /** @typedef {string | null} Entry */ ``` ```shell $ deno check --config ./tsconfig.json ./index.js && echo OK OK ``` If we now replace that `@import` line with an old-style `@typedef` import, Deno correctly reports the type error again: ```javascript /** @typedef {import("./util.js").Entry} Entry */ ```Version: tested with both Deno 1.46.3 and 2.0.6