-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Allow augmented declaration merging of type aliases. #28078
Comments
@nkappler write interface XRegistry {
A:A
B:B
C:C
}
type X= XRegistry[keyof XRegistry];
//... And in the other file
declare module "someModule" {
interface XRegistry { D:D }
} Instead. |
@weswigham Thanks for that solution, I had that in mind too, however it feels a little clumsy. |
I'd hardly call it clumsy, afaik we use it in the Dom lib for some things. But yeah, merging aliases doesn't make nearly as much sense as interfaces. As you've written it, file parse order would matter. And generally speaking, two arbitrary types don't "merge" cleanly. Eg, what would a merge of |
How would we make this approach work to extend an external type like this: someModule.ts
someFile.ts
The first commit here is my initial attempt at using the approach @weswigham recommended. The use case is related to this SO question. |
I want to extend a type alias declared in node_modules/@types
File "index.d.ts":
My File:
This does not work at the moment, and I don't know if there is a good workaround for what I want to achieve, because I want to call a generic function from that module which expects a parameter of type
X
and I want to pass it aD
.The text was updated successfully, but these errors were encountered: