Skip to content
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

Module augmentation: TypeScript overrides declarations instead of merging them #41351

Closed
mikeconley12 opened this issue Oct 31, 2020 · 2 comments

Comments

@mikeconley12
Copy link

TypeScript Version: 4.1.0-dev.20201031

Search Terms: "declare module", "module augmentation"

Code

codesandbox

Expected behavior: TypeScript should merge two separate declarations of the ParsedPath interface.

Actual behavior: TypeScript overrides the declaration of the ParsedPath interface. This behavior can be fixed by uncommenting the line export type Foo = ""; in types.ts file.

Playground Link: codesandbox

Related Issues:

@MartinJohns
Copy link
Contributor

I'm not too sure about the internal details, but you see this behavior because types.ts is not a module. You can only augment modules within modules or declaration files. Once you add an import or export statement it's a module. Alternatively you can make types.ts a decaration file by renaming it to types.d.ts.

@mikeconley12
Copy link
Author

Thanks for the explanation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants