typescript-eslint icon indicating copy to clipboard operation
typescript-eslint copied to clipboard

Bug(type-utils): Node.js' `Buffer` cannot be matched with a `{ type: package }` `TypeOrValueSpecifier`

Open abrahamguo opened this issue 4 months ago • 1 comments

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

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

Issue Description

  • Inside TypeOrValueSpecifier => typeDeclaredInDeclarationFile:
  • when declaration.path is /.../typescript-eslint/node_modules/@types/node/buffer.d.ts
  • program.sourceFileToPackageName.get(declaration.path) returns undefined
  • thus, causing the specifier { from: 'package', name: 'Buffer', package: '...anything...' } to not match

It looks like this broke in #6870.

Reproduction Repository Link

https://github.com/abrahamguo/repro/tree/buffer

Repro Steps

  1. clone the repo
  2. npm i
  3. npx eslint index.ts

Versions

package version
@typescript-eslint/eslint-plugin 8.8.0
@typescript-eslint/parser 8.8.0
@typescript-eslint/scope-manager 8.8.0
@typescript-eslint/typescript-estree 8.8.0
@typescript-eslint/type-utils 8.8.0
@typescript-eslint/utils 8.8.0
TypeScript 5.6.2
ESLint 9.11.1
node 22.8.0

abrahamguo avatar Oct 02 '24 12:10 abrahamguo