Skip to content

Bug: @typescript-eslint/typescript-estree (and indeed, all @typescript-eslint/ I tested) is incompatible with typescript 4.9.5 #8244

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

Closed
4 tasks done
dgoldstein0 opened this issue Jan 13, 2024 · 2 comments
Labels
bug Something isn't working triage Waiting for team members to take a look

Comments

@dgoldstein0
Copy link

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Relevant Package

typescript-estree

Playground Link

No response

Repro Code

// tsconfig.json
{
    "compilerOptions": {
        "moduleResolution": "node",
        "module": "esnext",
        "lib": ["es2020"],
        "target": "es2020"
    }
}
// package.json
{
  "name": "test_tseslint",
  "packageManager": "yarn@3.4.1",
  "private": true,
  "dependencies": {
    "@typescript-eslint/typescript-estree": "6.18.1",
    "typescript": "4.9.5"
  }
}
// test.ts
import type { AST_NODE_TYPES } from "@typescript-eslint/typescript-estree";

install this with npm install (yarn works too) then run tsc



### ESLint Config

_No response_

### tsconfig

```jsonc
{
    "compilerOptions": {
        "moduleResolution": "node",
        "module": "esnext",
        "lib": ["es2020"],
        "target": "es2020"
    }
}

Expected Result

I expect to be able to import @typescript-eslint/typescript-estree without a module resolution error

Actual Result

$ ./node_modules/.bin/tsc
test.ts:1:37 - error TS2307: Cannot find module '@typescript-eslint/typescript-estree' or its corresponding type declarations.

1 import type { AST_NODE_TYPES } from "@typescript-eslint/typescript-estree";
                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 1 error in test.ts:1


ERROR: //tools:node did not exit successfully.
If you suspect that there's a problem with the tool, try contacting the team that owns it: web-build

Additional Info

If I upgrade to the latest typescript (5.3.3 - I suspect any >= 5 can work) and set moduleResolution: bundler, then I am able to get past the module resolution error (and instead encounter #8047).

Based on --traceResolution, I originally thought part of the problem is the typeVersions which is not giving versions for typescript >=4.7

======== Resolving module '@typescript-eslint/typescript-estree' from '/home/dgoldstein/src/test_tseslint/test.ts'. ========
Explicitly specified module resolution kind: 'NodeJs'.
Loading module '@typescript-eslint/typescript-estree' from 'node_modules' folder, target file type 'TypeScript'.
Found 'package.json' at '/home/dgoldstein/src/test_tseslint/node_modules/@typescript-eslint/typescript-estree/package.json'.
'package.json' has a 'typesVersions' field with version-specific path mappings.
'package.json' does not have a 'typesVersions' entry that matches version '4.9'.
File '/home/dgoldstein/src/test_tseslint/node_modules/@typescript-eslint/typescript-estree.ts' does not exist.
File '/home/dgoldstein/src/test_tseslint/node_modules/@typescript-eslint/typescript-estree.tsx' does not exist.
File '/home/dgoldstein/src/test_tseslint/node_modules/@typescript-eslint/typescript-estree.d.ts' does not exist.
'package.json' does not have a 'typings' field.
'package.json' does not have a 'types' field.
'package.json' does not have a 'main' field.
File '/home/dgoldstein/src/test_tseslint/node_modules/@typescript-eslint/typescript-estree/index.ts' does not exist.
File '/home/dgoldstein/src/test_tseslint/node_modules/@typescript-eslint/typescript-estree/index.tsx' does not exist.
File '/home/dgoldstein/src/test_tseslint/node_modules/@typescript-eslint/typescript-estree/index.d.ts' does not exist.
Directory '/home/dgoldstein/src/test_tseslint/node_modules/@types' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript-eslint__typescript-estree'
Directory '/home/dgoldstein/src/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript-eslint__typescript-estree'
Directory '/home/dgoldstein/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript-eslint__typescript-estree'
Directory '/home/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript-eslint__typescript-estree'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript-eslint__typescript-estree'
Loading module '@typescript-eslint/typescript-estree' from 'node_modules' folder, target file type 'JavaScript'.
File '/home/dgoldstein/src/test_tseslint/node_modules/@typescript-eslint/typescript-estree/package.json' exists according to earlier cached lookups.
File '/home/dgoldstein/src/test_tseslint/node_modules/@typescript-eslint/typescript-estree.js' does not exist.
File '/home/dgoldstein/src/test_tseslint/node_modules/@typescript-eslint/typescript-estree.jsx' does not exist.
'package.json' does not have a 'main' field.
File '/home/dgoldstein/src/test_tseslint/node_modules/@typescript-eslint/typescript-estree/index.js' does not exist.
File '/home/dgoldstein/src/test_tseslint/node_modules/@typescript-eslint/typescript-estree/index.jsx' does not exist.
Directory '/home/dgoldstein/src/node_modules' does not exist, skipping all lookups in it.
Directory '/home/dgoldstein/node_modules' does not exist, skipping all lookups in it.
Directory '/home/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript-eslint/typescript-estree' was not resolved. ========

but downgrading typescript just gives a different failed resolution trace. I think the real problem is that @typescript-eslint/ packages have started expressing their package.json in a way that only the newer forms of moduleResolution (node16, nodenext, and bundler) understand.

Versions

package version
@typescript-eslint/typescript-estree 6.18.1
TypeScript 4.9.5
node 16.18.0
@dgoldstein0 dgoldstein0 added bug Something isn't working triage Waiting for team members to take a look labels Jan 13, 2024
@auvred
Copy link
Member

auvred commented Jan 13, 2024

Duplicate of #7185, #7279

As mentioned in the pinned issue: #7284, you can try to set "moduleResolution" to the "NodeNext" or "Node16" ("Bundler" was introduced in TS v5.0, but "NodeNext"/"Node16" should work for this too)

{
    "compilerOptions": {
-       "moduleResolution": "node",
+       "moduleResolution": "NodeNext",
        "module": "esnext",
        "lib": ["es2020"],
        "target": "es2020"
    }
}

@dgoldstein0
Copy link
Author

ok this is my mistake then. I unfortunately didn't come across that pinned issue in my search. Fwiw I mistakenly thought that node16/nodenext were TS >=5.0 options (whoops), and annoyingly the TSconfig reference docs don't say when each value was introduced.

That said... I also have never seen a library that drops support for node <16 also start requiring moduleResolution: node16 - for every other package I've ever seen, dropping support for node <16 means that the new version may fail at runtime, not at typecheck time. So @typescript-eslint/ is definitely an outlier here - I've been using moduleResolution: node with 100s of other packages with no problems at all.

@dgoldstein0 dgoldstein0 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 17, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working triage Waiting for team members to take a look
Projects
None yet
Development

No branches or pull requests

2 participants