Skip to content

Bug: Type for values of SharedConfigs should allow an array #10213

Closed
@trygveaa

Description

@trygveaa

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

Relevant Package

utils

Playground Link

No response

Repro Code

const plugin: TSESLint.FlatConfig.Plugin = {
  configs: {},
}

plugin.configs = {
  recommended: [
    {
      plugins: {
        example: plugin,
      },
    },
  ],
}

ESLint Config

No response

tsconfig

No response

Expected Result

The code should type check without errors. The code is a stripped down version of the example given on https://eslint.org/docs/latest/extend/plugins#configs-in-plugins except that I've replaced Object.assign with a direct assignment because Object.assign doesn't type check that it can be assigned.

You can see in that example that they set the recommended config to an array, but that's not allowed by the SharedConfigs type used by TSESLint.FlatConfig.Plugin["configs"]. If you replace TSESLint.FlatConfig.Plugin with ESLint.Plugin you can also see that it type checks without errors.

Actual Result

Type checking complains that an array can't be assigned to the type Config (the type for the values of SharedConfigs).

Additional Info

No response

Versions

package version
@typescript-eslint/utils 8.11.0
TypeScript 5.6.3
ESLint 9.13.0
node 20.17.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: utilsIssues related to the @typescript-eslint/utils package

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions