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

allowAutomaticSingleRunInference breaks monorepocompilerOptions.types #4435

Closed
Labels
awaiting responseIssues waiting for a reply from the OP or another partypackage: typescript-estreeIssues related to @typescript-eslint/typescript-estree
@aaronadamsCA

Description

@aaronadamsCA
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I haveread the FAQ and my problem is not listed.

WithallowAutomaticSingleRunInference: true enabled in a medium-sized React monorepo,compilerOptions.types no longer works as expected in one of our packages. My best guess is that the package is being linted using the wrongtsconfig.

Repro

With this config:

/packages/components/tsconfig.json
{"extends":"../../tsconfig.json","include": ["./src/**/*"],"compilerOptions": {"types": ["segment-analytics"]  }}

And this line of code:

window.analytics.track(process.env["FOO"]??"foo");

Expected behaviour

WithoutallowAutomaticSingleRunInference,@typescript-eslint/no-unsafe-member-access gives us exactly the error we'd expect:

Unsafe member access .env on an `any` value

That's because I didn't include"node" incompilerOptions.types, soprocess.env is untyped.

Actual behaviour

WithallowAutomaticSingleRunInference: true, it's a different story:

Unsafe member access .track on an `any` value

Oops. Somehowprocess.env is typed, butwindow.analytics is untyped. Both are incorrect; so clearly ourcompilerOptions.types isn't being respected.

No project references. We do usepaths but they're not involved in this specific situation AFAIK. Ourtsconfig.json inheritance is straightforward; I've included more of our config info below.

This reliably reproduces both locally and in CI, so I'm reasonably confident it isn't an environment issue.

Happy to hear any ideas RE: how we might create a standalone repro or help debug the issue. Access to our private repo could be an option, too.

Additional Info

/tsconfig.json
{"compilerOptions": {"baseUrl":"./","esModuleInterop":true,"forceConsistentCasingInFileNames":true,"incremental":true,"isolatedModules":true,"jsx":"preserve","module":"ESNext","moduleResolution":"Node","noEmit":true,"noImplicitOverride":true,"noPropertyAccessFromIndexSignature":true,"noUncheckedIndexedAccess":true,"noUnusedLocals":true,"noUnusedParameters":true,"paths": {"@reach/router": ["./node_modules/@gatsbyjs/reach-router/es"],"@shopnishe/components": ["./packages/components/src"]// Our other internal packages    },"skipLibCheck":true,"strict":true,"target":"ESNext"  }}
/.eslintrc.cjs
module.exports={extends:"./.eslintrc.base.cjs",overrides:[{files:["*.ts","*.tsx"],parserOptions:{allowAutomaticSingleRunInference:true,tsconfigRootDir:__dirname,project:["./apps/*/tsconfig.json","./packages/*/tsconfig.json"],},extends:["plugin:@typescript-eslint/recommended-requiring-type-checking",],rules:{// Our typed TypeScript rules},},],};
/.eslintrc.base.cjs
module.exports={root:true,extends:["eslint:recommended","plugin:react/recommended","prettier",// Disables conflicting rules in above configs"plugin:react-hooks/recommended","plugin:eslint-comments/recommended","plugin:import/recommended","plugin:jsx-a11y/strict",],parser:"@babel/eslint-parser",parserOptions:{sourceType:"module",},env:{browser:true,es2020:true,node:true,},plugins:["simple-import-sort"],rules:{// Our base rules},overrides:[{// Make sure ESLint can see every possible Node/TypeScript filefiles:["*.cjs","*.js","*.jsx","*.mjs","*.ts","*.tsx"],},{files:["*.ts","*.tsx"],extends:["plugin:@typescript-eslint/recommended","plugin:import/typescript",],plugins:["eslint-plugin-tsdoc"],rules:{// Our non-typed TypeScript rules},},],settings:{// Our eslint-plugin-import settingsreact:{version:"detect",},},};

Versions

packageversion
@typescript-eslint/typescript-estree5.9.0
TypeScript4.5.4
node16.13.1
Environment Info:Node version: v16.13.1npm version: v8.1.2Local ESLint version: v8.6.0 (Currently used)Global ESLint version: Not foundOperating System: linux 4.19.128-microsoft-standard

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting responseIssues waiting for a reply from the OP or another partypackage: typescript-estreeIssues related to @typescript-eslint/typescript-estree

    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