Skip to content

Bug: @typescript-eslint/no-redundant-type-constituents issue within declare module statement #11233

@ernestostifano

Description

@ernestostifano

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.

Issue Description

./src/modules.d.ts

declare module 'my-module' {
    import {EMyEnum} from './common.types.js';

    // INCORRECT: ESLINT HIGHLIGHTS AN ERROR
    function externalFunction(arg: EMyEnum | null): void;

    export {externalFunction};
}
ESLint: 'EMyEnum' is an 'error' type that acts as 'any' and overrides all other types in this union type. (@typescript-eslint/no-redundant-type-constituents)

It also seems to be an issue in TS:

./src/index.ts

import {externalFunction} from 'my-module';
import {internalFunction} from './utilities.js';

// INCORRECT: TS DOES NOT HIGHLIGHT THE ERROR
externalFunction('TEST');

// CORRECT: TS HIGHLIGHTS ERROR BECAUSE THE ARGUMENT MUST BE AN ENUM
internalFunction('TEST');

./src/utilities.ts

import {EMyEnum} from './common.types.js';

function internalFunction(arg: EMyEnum | null): void {
    console.log(arg);
}

export {internalFunction};

./src/common.types.ts

enum EMyEnum {
    Value = 'value'
}

export {EMyEnum};

Reproduction Repository Link

https://github.com/ernestostifano/typescript-eslint-issue-1

Repro Steps

  1. Clone the repo.
  2. See README.md.

Versions

package version
@typescript-eslint/eslint-plugin 8.32.1
TypeScript 5.8.3
ESLint 9.27.0
node 22.6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingexternalThis issue is with another package, not typescript-eslint itselflocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions