Skip to content

Incorrect type inference for exported configs object: {} #487

Open
@JoshuaKGoldberg

Description

@JoshuaKGoldberg

Right now, when I try to use the plugin in files with type-aware linting and typescript-eslint's recommendedTypeChecked config, I get:

/Users/josh/repos/typescript-eslint-examples/packages/eslint-plugin-example-typed-linting/eslint.config.mjs
  9:5  error  Unsafe argument of type `any` assigned to a parameter of type `ConfigWithExtends`  @typescript-eslint/no-unsafe-argument

...on lines like:

export default tseslint.config(
    eslintPlugin.configs['flat/recommended'],
);

Example: https://github.com/typescript-eslint/examples/blob/b91625d418f63b4bcc5127f2fb213222dcadf3cc/packages/eslint-plugin-example-typed-linting/eslint.config.mjs

The root cause is that the module's exported config object is inferred from .js to be {}:

configs: {}, // assigned later

Normally for a project that isn't written in TypeScript I'd just send a PR to DefinitelyTyped. But because this project already has #310 in its issues, I figured I'd give this a shot. 🙂

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