Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
Closed as not planned
@ernestostifano

Description

@ernestostifano
Issue body actions

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 workingSomething isn't workingexternalThis issue is with another package, not typescript-eslint itselfThis issue is with another package, not typescript-eslint itselfpackage: eslint-pluginIssues related to @typescript-eslint/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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.