Skip to content

Bug: TypeScript type error in generated dts files #104

@danielrentz

Description

@danielrentz

Which packages are affected?

  • @eslint/compat
  • @eslint/config-array
  • @eslint/core
  • @eslint/migrate-config
  • @eslint/object-schema

Environment

Node version: 20
npm version:
ESLint version: 9.9.0
Operating System: Win11

What did you do?

  • using eslint plugins in TS wrapper files
  • upgrading @stylistic/eslint-plugin from 2.3 to 2.4

A weird side effect in package installation starts to give me a type error from THIS package after upgrading @stylistic/eslint-plugin. See below for details.

What did you expect to happen?

My TS code compiles.

What actually happened?

After upgrading @stylistic/eslint-plugin, I get a type error from THIS package.

node_modules/@eslint/compat/dist/esm/index.d.ts:4:63 - error TS2694: Namespace '"node_modules/@types/eslint/index".Rule' has no exported member 'OldStyleRule'.

4 export type FixupLegacyRuleDefinition = import("eslint").Rule.OldStyleRule;
                                                                ~~~~~~~~~~~~

Found 1 error in node_modules/@eslint/compat/dist/esm/index.d.ts:4

The typedef

/** @typedef {import("eslint").Rule.RuleModule} FixupRuleDefinition */
/** @typedef {FixupRuleDefinition["create"]} FixupLegacyRuleDefinition */

in https://github.com/eslint/rewrite/blob/main/packages/compat/src/fixup-rules.js#L11-L12 has been compiled to

export type FixupRuleDefinition = import("eslint").Rule.RuleModule;
export type FixupLegacyRuleDefinition = import("eslint").Rule.OldStyleRule;

in node_modules/@eslint/compat/dist/esm/index.d.ts, i.e. the type lookup expression FixupRuleDefinition["create"] has been resolved to Rule.OldStyleRule;.

However, the type OldStyleRule exists in @types/eslint v8 only but not in v9.

This seems to be a side effect of the @stylistic/eslint-plugin upgrade mentioned above. With @stylistic/eslint-plugin v2.3 I see

> yarn why @types/eslint
├─ @stylistic/eslint-plugin@npm:2.3.0 [3613d]
│  └─ @types/eslint@npm:8.56.11 (via npm:^8.56.10)
│
└─ @types/eslint__js@npm:8.42.3
   └─ @types/eslint@npm:9.6.0 (via npm:*)

but with v2.4 and above I see

> yarn why @types/eslint
├─ @stylistic/eslint-plugin@npm:2.4.0 [3613d]
│  └─ @types/eslint@npm:9.6.0 (via npm:^9.6.0)
│
└─ @types/eslint__js@npm:8.42.3
   └─ @types/eslint@npm:9.6.0 (via npm:*)

i.e. there is no more @types/eslint v8 anymore in node_modules .

Link to Minimal Reproducible Example

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedbugSomething isn't workingrepro:yesIssues with a reproducible example

    Type

    No type

    Projects

    Status

    Complete

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions