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

[prefer-readonly-parameter-types] Cannot read property 'flags' of undefined #3405

Closed
Labels
bugSomething isn't workingexternalThis issue is with another package, not typescript-eslint itselfpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin
Milestone
@AriPerkkio

Description

@AriPerkkio

Hello,prefer-readonly-parameter-types rule seems to crash in certain cases. This issue was spotted by automated CI run - it is not blocking my development or anything.

  • 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.

Repro

// .eslintrc.jsmodule.exports={root:true,env:{es6:true,node:true,},parser:"@typescript-eslint/parser",parserOptions:{ecmaVersion:2020,sourceType:"module",ecmaFeatures:{jsx:true,},tsconfigRootDir:__dirname,project:["./tsconfig.json"],},plugins:["@typescript-eslint"],rules:{"@typescript-eslint/prefer-readonly-parameter-types":"error",},};
// tsconfig.json{"compilerOptions": {"target":"es6","allowJs":false,"skipLibCheck":true,"esModuleInterop":true,"allowSyntheticDefaultImports":true,"strict":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"forceConsistentCasingInFileNames":true,"lib": ["esnext","dom"],"module":"commonjs","moduleResolution":"node","outDir":"dist"  },"include": ["./index.ts"]}

This is as minimal as I could narrow the issue down.

typeMyType<T>={[KinkeyofT]:"cat"|"dog"|T[K];};functionmethod<Aextendsany[]=string[]>(value:MyType<A>){returnvalue;}method(["cat","dog"]);method<"mouse"[]>(["cat","mouse"]);

Expected Result

ESLint should not crash.

Actual Result

TypeError: Cannot read property 'flags' of undefinedOccurred while linting /workspaces/eslint-remote-tester/node_modules/.cache-eslint-remote-tester/querycap/webappkit/@querycap/reactutils/must.tsx:7    at Object.isUnionType (/workspaces/eslint-remote-tester/node_modules/tsutils/typeguard/2.8/type.js:69:18)    at unionTypeParts (/workspaces/eslint-remote-tester/node_modules/tsutils/util/type.js:92:19)    at isPropertyReadonlyInType (/workspaces/eslint-remote-tester/node_modules/tsutils/util/type.js:151:21)    at isReadonlyPropertyFromMappedType (/workspaces/eslint-remote-tester/node_modules/tsutils/util/type.js:197:12)    at /workspaces/eslint-remote-tester/node_modules/tsutils/util/type.js:179:21    at someTypePart (/workspaces/eslint-remote-tester/node_modules/tsutils/util/type.js:100:52)    at isReadonlyPropertyIntersection (/workspaces/eslint-remote-tester/node_modules/tsutils/util/type.js:172:12)    at Object.isPropertyReadonlyInType (/workspaces/eslint-remote-tester/node_modules/tsutils/util/type.js:161:43)    at isTypeReadonlyObject (/workspaces/eslint-remote-tester/node_modules/@typescript-eslint/eslint-plugin/dist/util/isTypeReadonly.js:72:28)    at isTypeReadonlyRecurser (/workspaces/eslint-remote-tester/node_modules/@typescript-eslint/eslint-plugin/dist/util/isTypeReadonly.js:127:30)

Additional Info

Crash reports from real projects

Rule: prefer-readonly-parameter-types

  • Message:Cannot read property 'flags' of undefined Occurred while linting /workspaces/eslint-remote-tester/node_modules/.cache-eslint-remote-tester/querycap/webappkit/@querycap/reactutils/must.tsx:7
  • Path:querycap/webappkit/@querycap/reactutils/must.tsx
  • Link
5|6|exportfunctionmust<TPrepareextendsReadonly<Array<any>>>(usePrepare:()=>TPrepare){>7|returnfunction<TProps>(render:(props:TProps, ...prepare:NonNullableArray<TPrepare>)=>JSX.Element|null){8|constC=({"data-prepare":dataPrepare, ...props}:TProps&{["data-prepare"]:NonNullableArray<TPrepare>})=>9|render(propsasany, ...(dataPrepareasany));10|
TypeError: Cannot read property 'flags' of undefinedOccurred while linting /workspaces/eslint-remote-tester/node_modules/.cache-eslint-remote-tester/querycap/webappkit/@querycap/reactutils/must.tsx:7    at Object.isUnionType (/workspaces/eslint-remote-tester/node_modules/tsutils/typeguard/2.8/type.js:69:18)    at unionTypeParts (/workspaces/eslint-remote-tester/node_modules/tsutils/util/type.js:92:19)    at isPropertyReadonlyInType (/workspaces/eslint-remote-tester/node_modules/tsutils/util/type.js:151:21)    at isReadonlyPropertyFromMappedType (/workspaces/eslint-remote-tester/node_modules/tsutils/util/type.js:197:12)    at /workspaces/eslint-remote-tester/node_modules/tsutils/util/type.js:179:21    at someTypePart (/workspaces/eslint-remote-tester/node_modules/tsutils/util/type.js:100:52)    at isReadonlyPropertyIntersection (/workspaces/eslint-remote-tester/node_modules/tsutils/util/type.js:172:12)    at Object.isPropertyReadonlyInType (/workspaces/eslint-remote-tester/node_modules/tsutils/util/type.js:161:43)    at isTypeReadonlyObject (/workspaces/eslint-remote-tester/node_modules/@typescript-eslint/eslint-plugin/dist/util/isTypeReadonly.js:72:28)    at isTypeReadonlyRecurser (/workspaces/eslint-remote-tester/node_modules/@typescript-eslint/eslint-plugin/dist/util/isTypeReadonly.js:127:30)

Versions

packageversion
@typescript-eslint/eslint-plugin4.23.0
@typescript-eslint/parser4.23.0
TypeScript4.2.4
ESLint7.26.0
nodev14.15.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingexternalThis issue is with another package, not typescript-eslint itselfpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp