denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
98.14k stars 5.4k forks source link

`deno check` ignores `compilerOptions.types` in `deno.json` #27062

Open skeithtan opened 3 days ago

skeithtan commented 3 days ago

Version: Deno 2.1.1

In my deno.json, I have compilerOptions and imports defined like so:

{
  "compilerOptions": {
    "types": ["@testing-library/jest-dom"]
  },
  "imports": {
    "@testing-library/jest-dom": "npm:@testing-library/jest-dom@^6.6.3",
  }
}

And I run deno check to check the entire source with a path to the json file like so: deno check --config ./deno.json ./src/.

But when I run that, it gives me all the errors I expect to be resolved by the types option: (These are functions extended by Testing Library. In Node they would be fixed through tsconfig.json)

TS2339 [ERROR]: Property 'toBeInTheDocument' does not exist on type 'Assertion<HTMLElement>'.
    expect(getByText(/diagnostic/i)).toBeInTheDocument();
                                     ~~~~~~~~~~~~~~~~~

And, more importantly, it goes away when I add this at the top of the file:

// @ts-types="@testing-library/jest-dom"

Or

// @deno-types="@testing-library/jest-dom"

Shouldn't deno check be able to do this automatically through the deno.json file?

However it seems to ignore the reference type directives as well:

/// <reference types="@testing-library/jest-dom" />

or

/// <reference types="@testing-library/jest-dom/types/matchers.d.ts" />
Mqxx commented 1 day ago

compilerOptions.types seems to really buggy at the moment... #23007