Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
4 tasks done
ernestostifano opened this issue May 21, 2025 · 2 comments
Closed
4 tasks done
Labels
bug Something isn't working external This issue is with another package, not typescript-eslint itself locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@ernestostifano
Copy link

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
@ernestostifano ernestostifano added bug Something isn't working triage Waiting for team members to take a look labels May 21, 2025
@bradzacher
Copy link
Member

I can't reproduce this in our playground
https://typescript-eslint.io/play/#ts=5.8.2&fileType=.tsx&code=CYUwxgNghgTiAEBbA9sArhBByRBPAtCuplvAN4BQ88AlogA7IwAu58Awsg8gHYg%2BsAvvABmMLvCxwoYZlgDcFKqLQ9ZNXvBAAPZiBg8oEAGKr1vABSwA5gC4OXRnwHwAPvB4YIASnsA3ZBpgRWUdRhY2HT0DI1M1Zg0eeEFFQQogA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1ukQBNYmvAIYtaRUrTIcmyfJXyxELVBkiJo0DtEjgwAXxAGgA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

So this indicates that it's a problem with your setup - for whatever reason we can't find the types for your common.types.js file.

Which aligns with the error message you're seeing - it mentions the type is an "error" type because TS cannot resolve the types because it cannot find the file.

@ernestostifano
Copy link
Author

@bradzacher thanks for your feedback. You can't replicate it because you are using a non-relative import within the declaration statement and the issue happens when doing a relative import (you cannot have multi-file environments in the playground).

But then, relative imports within module declaration scope are actually not allowed and that error was being suppressed by having skipLibCheck on.

Here you can find additional details: microsoft/TypeScript#61744

I think we can close this issue.

Thanks!

@bradzacher bradzacher closed this as not planned Won't fix, can't repro, duplicate, stale May 23, 2025
@bradzacher bradzacher added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin external This issue is with another package, not typescript-eslint itself and removed triage Waiting for team members to take a look labels May 23, 2025
@github-actions github-actions bot added the locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. label May 31, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working external This issue is with another package, not typescript-eslint itself locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

2 participants