Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bug: "Single run" not resolving types / resolving incorrect libs #5136

Closed
Labels
awaiting responseIssues waiting for a reply from the OP or another partyquestionQuestions! (i.e. not a bug / enhancment / documentation)unable to reproissues that a maintainer was not able to reproduce
@milesj

Description

@milesj

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 havesearched for related issues and found none that matched my issue.
  • I haveread the FAQ and my problem is not listed.

Relevant Package

parser

Playground Link

No response

Repro Code

I'm not sure what the conditions are to reproduce this yet.

ESLint Config

module.exports={parser:"@typescript-eslint/parser",parserOptions:{// This path changes based on which folder the eslint binary is running inproject:['path/to/tsconfig.json'],tsconfigRootDir:__dirname,allowAutomaticSingleRunInference:true,},extends:['airbnb','import','react','react-hooks','jest','@typescript-eslint'],reportUnusedDisableDirectives:true,rules:{// Pretty much all the rules provided by the plugins/configs},};

tsconfig

{"compilerOptions": {"allowJs":true,"allowSyntheticDefaultImports":true,"baseUrl":".","esModuleInterop":true,"experimentalDecorators":true,"forceConsistentCasingInFileNames":true,"jsx":"react-jsx","isolatedModules":true,"lib": ["dom","esnext"    ],"module":"CommonJS","moduleResolution":"node","noFallthroughCasesInSwitch":true,"noUnusedLocals":true,"noUnusedParameters":true,"resolveJsonModule":true,"skipLibCheck":true,"sourceMap":true,"strict":true,"target":"ES2020",  },"include": ["**/*"  ]}

Expected Result

When usingallowAutomaticSingleRunInference orTSESTREE_SINGLE_RUN=true, types and lints resolve/pass correctly, in the same manner as if these settings were turned off.

Actual Result

When usingallowAutomaticSingleRunInference orTSESTREE_SINGLE_RUN=true, we've noticed that types (mainly@types) spuriously fail to resolve. For example,useMemo fromimport { useMemo } from 'react' resolves toany, causing our@typescript-eslint/no-unsafe-* to fail.

When looking at the debug logs, we noticed that the resolvedlibs arenot what we configured (theesnext.full is no where to be found in our repo). Once this incorrect lib is used, types start failing. Here's an excerpt from the logs:

eslint:cli-engine Lint <path>/config/atomic.ts +8mstypescript-eslint:typescript-estree:parser parserOptions.project (excluding ignored) matched projects: Set(1) {'<path>/tsconfig.json'} +7mstypescript-eslint:typescript-estree:useProvidedProgram Retrieving ast for <path>/config/atomic.ts from provided program instance(s) +7mstypescript-eslint:parser:parser Resolved libs from program: [ 'dom', 'esnext' ] +8mseslint:cli-engine Lint <path>/config/device.ts +5mstypescript-eslint:typescript-estree:parser parserOptions.project (excluding ignored) matched projects: Set(1) {'<path>/tsconfig.json'} +5mstypescript-eslint:typescript-estree:createIsolatedProgram Getting isolated program in TS mode for: <path>/config/device.ts +41mstypescript-eslint:parser:parser Resolved libs from program: [ 'esnext.full' ] +6mstypescript-eslint:eslint-plugin:utils:types Found an "error" any type +92mstypescript-eslint:eslint-plugin:utils:types Found an "error" any type +1mstypescript-eslint:eslint-plugin:utils:types Found an "error" any type +0mstypescript-eslint:eslint-plugin:utils:types Found an "error" any type +0mstypescript-eslint:eslint-plugin:utils:types Found an "error" any type +1mstypescript-eslint:eslint-plugin:utils:types Found an "error" any type +0mstypescript-eslint:eslint-plugin:utils:types Found an "error" any type +0mseslint:cli-engine Lint <path>/config/keys.ts +17mstypescript-eslint:typescript-estree:parser parserOptions.project (excluding ignored) matched projects: Set(1) {'<path>/tsconfig.json'} +18mstypescript-eslint:typescript-estree:useProvidedProgram Retrieving ast for <path>/config/keys.ts from provided program instance(s) +23mstypescript-eslint:parser:parser Resolved libs from program: [ 'dom', 'esnext' ] +16ms

Notice thatconfig/device.ts creates a new isolated program withesnext.full, instead of reusing an existing program likeconfig/atomic.ts andconfig/keys.ts does, which isdom, esnext. All of these files are in the same program, even the same folder.

HOWEVER! When I run the linter onconfig/device.ts individually, the linting passes correctly.

eslint:cli-engine Lint <path>/config/device.ts +0mstypescript-eslint:typescript-estree:parser parserOptions.project (excluding ignored) matched projects: Set(1) {'<path>/tsconfig.json'} +0mstypescript-eslint:typescript-estree:useProvidedProgram Retrieving ast for <path>/config/device.ts from provided program instance(s) +0mstypescript-eslint:typescript-estree:parser Detected single-run/CLI usage, creating Program once ahead of time for project: <path>/tsconfig.json +0mstypescript-eslint:parser:parser Resolved libs from program: [ 'dom', 'esnext' ] +0mseslint:cli-engine Linting complete in: 3306ms +2s

This leads me to believe that the parser is losing the program? Or handling paths/detection wrong? I did some digging intonode_modules but was unable to find the root cause.

Additional Info

Our codebase has over 10,000 files and this is consistently running out of memory, so this is me digging into alternatives/why it's happening.

Versions

packageversion
@typescript-eslint/eslint-plugin5.26.0
@typescript-eslint/parser5.26.0
@typescript-eslint/scope-manager5.26.0
@typescript-eslint/typescript-estree5.26.0
@typescript-eslint/type-utils5.26.0
@typescript-eslint/utils5.26.0
TypeScript4.6.3
ESLint8.16.0
node16.13.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting responseIssues waiting for a reply from the OP or another partyquestionQuestions! (i.e. not a bug / enhancment / documentation)unable to reproissues that a maintainer was not able to reproduce

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp