Skip to content

eslint-typegen types are not compatible with ESLint types #2788

Open
@G-Rath

Description

@G-Rath

Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have read the FAQ and my problem is not listed.

Tell us about your environment

  • ESLint version: 9.31.0
  • eslint-plugin-vue version: 10.3.0
  • Vue version: -
  • Node version: 20.19.0
  • Operating System: Linux

Please show your full configuration:
(see reproduction repository - no special settings, just plain strict-mode typescript)

What did you do?

Updated eslint-plugin-vue

What did you expect to happen?
Everything to continue working, and for there to be no type errors

What actually happened?

Lots of type errors

Error: node_modules/eslint/lib/types/index.d.ts(1374,3): error TS2411: Property ''vue/array-bracket-newline'' of type 'RuleEntry<VueArrayBracketNewline> | undefined' is not assignable to 'string' index type 'RuleEntry<any[]>'.
Error: node_modules/eslint/lib/types/index.d.ts(1374,3): error TS2411: Property ''vue/array-bracket-spacing'' of type 'RuleEntry<VueArrayBracketSpacing> | undefined' is not assignable to 'string' index type 'RuleEntry<any[]>'.
Error: node_modules/eslint/lib/types/index.d.ts(1374,3): error TS2411: Property ''vue/array-element-newline'' of type 'RuleEntry<VueArrayElementNewline> | undefined' is not assignable to 'string' index type 'RuleEntry<any[]>'.
Error: node_modules/eslint/lib/types/index.d.ts(1374,3): error TS2411: Property ''vue/arrow-spacing'' of type 'RuleEntry<VueArrowSpacing> | undefined' is not assignable to 'string' index type 'RuleEntry<any[]>'.
Error: node_modules/eslint/lib/types/index.d.ts(1374,3): error TS2411: Property ''vue/attribute-hyphenation'' of type 'RuleEntry<VueAttributeHyphenation> | undefined' is not assignable to 'string' index type 'RuleEntry<any[]>'.
Error: node_modules/eslint/lib/types/index.d.ts(1374,3): error TS2411: Property ''vue/attributes-order'' of type 'RuleEntry<VueAttributesOrder> | undefined' is not assignable to 'string' index type 'RuleEntry<any[]>'.
Error: node_modules/eslint/lib/types/index.d.ts(1374,3): error TS2411: Property ''vue/block-lang'' of type 'RuleEntry<VueBlockLang> | undefined' is not assignable to 'string' index type 'RuleEntry<any[]>'.
Error: node_modules/eslint/lib/types/index.d.ts(1374,3): error TS2411: Property ''vue/block-order'' of type 'RuleEntry<VueBlockOrder> | undefined' is not assignable to 'string' index type 'RuleEntry<any[]>'.
Error: node_modules/eslint/lib/types/index.d.ts(1374,3): error TS2411: Property ''vue/block-spacing'' of type 'RuleEntry<VueBlockSpacing> | undefined' is not assignable to 'string' index type 'RuleEntry<any[]>'.
Error: node_modules/eslint/lib/types/index.d.ts(1374,3): error TS2411: Property ''vue/block-tag-newline'' of type 'RuleEntry<VueBlockTagNewline> | undefined' is not assignable to 'string' index type 'RuleEntry<any[]>'.
Error: node_modules/eslint/lib/types/index.d.ts(1374,3): error TS2411: Property ''vue/brace-style'' of type 'RuleEntry<VueBraceStyle> | undefined' is not assignable to 'string' index type 'RuleEntry<any[]>'.
Error: node_modules/eslint/lib/types/index.d.ts(1374,3): error TS2411: Property ''vue/camelcase'' of type 'RuleEntry<VueCamelcase> | undefined' is not assignable to 'string' index type 'RuleEntry<any[]>'.
Error: node_modules/eslint/lib/types/index.d.ts(1374,3): error TS2411: Property ''vue/comma-dangle'' of type 'RuleEntry<VueCommaDangle> | undefined' is not assignable to 'string' index type 'RuleEntry<any[]>'.
...

The issue is because the original type (RulesRecord) defines an index meaning you cannot have optional properties - removing the ? from the properties resolves the issue.

See this playground showcasing the issue both when merging directly into the interface and when using extends (which results in the error being put on the original interface, masking it somewhat).

Note that in the playground you cannot reproduce the issue using ESLint itself due to how packages work in the playground.

Repository to reproduce this issue

https://github.com/G-Rath/bug-eslint-vue

  1. clone repo
  2. run npm ci
  3. run npm run typescript

Alternatively, look at the GitHub Actions runs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions