Skip to content

TS looses track of enum coming from module declaration #61744

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

Open
ernestostifano opened this issue May 21, 2025 · 1 comment
Open

TS looses track of enum coming from module declaration #61744

ernestostifano opened this issue May 21, 2025 · 1 comment
Labels
Question An issue which isn't directly actionable in code

Comments

@ernestostifano
Copy link

πŸ”Ž Search Terms

"module declaration enum issue", "module declaration enum any"

πŸ•— Version & Regression Information

Difficult to test in previous version because multi-file setup is required for reproduction.

⏯ Playground Link

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

πŸ’» Code

Issue Description

./src/common.types.ts

enum EMyEnum {
    Value = 'value'
}

export {EMyEnum};

./src/utilities.ts

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

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

export {internalFunction};

./src/modules.d.ts

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

    function externalFunction(arg: EMyEnum | null): void;

    export {externalFunction};
}

./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');

Reproduction Repository Link

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

Repro Steps

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

πŸ™ Actual behavior

See above.

πŸ™‚ Expected behavior

See above.

Additional information about the issue

Versions

package version
TypeScript 5.8.3
node 22.6.0
@RyanCavanaugh RyanCavanaugh added the Question An issue which isn't directly actionable in code label May 21, 2025
@RyanCavanaugh
Copy link
Member

You need to turn off skipLibCheck if you're hand-authoring .d.ts files. This line is an error:

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

and thus the import fails (so EMyEnum is just any)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy