Interface that shares name with namespace being dropped
See original GitHub issueI’m loving this module so thanks @wessberg. I’m using it to take a slice out of the vscode repo and repackage as its own module.
index.ts:
export interface Something {
type: string;
}
export namespace Something {
export function forUseCase(): Something {
// Something useful
}
}
The resulting bundle’s .d.ts
does not include the Something
interface, only the namespace.
My use-case is in ggoodman/ts-primitives which pulls vscode source in a build script and produces a slice of the overall repo using rollup in-memory.
The issue is that for consuming libraries, the interface CancellationToken
is being stripped from here https://github.com/microsoft/vscode/blob/f8014d495791145f1fac93cc0283737878272129/src/vs/base/common/cancellation.ts#L9-L25
Note that just below is export namespace CancellationToken
. You can see what is being produced on unpkg.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
C# error when class shares name with namespace
As far as I'm aware, you can't declare a namespace variable, or new() a namespace. Foo is a type, and it's being used...
Read more >How to fix Kubernetes namespaces stuck in the terminating state
You might try to delete it from the user interface (UI). To do so, click on the three dots shown at the right...
Read more >How can I move an interface out of a network namespace?
If NAME is present in /var/run/netns it is umounted and the mount point is removed. If this is the last user of the...
Read more >Introducing Linux Network Namespaces - Scott's Weblog
Assigning Interfaces to Network Namespaces · The first part, ip netns exec , is how you execute commands in a different network namespace....
Read more >9. Namespace Management - Robin Documentation
The Kubernetes 'namespace' construct allows a cluster to be partitioned into multiple “virtual clusters”. Names of resources deployed (scoped) to a ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This has been fixed in v1.2.17. I’ve tested a build based on cloning your
ts-primitives
library, and theCancellationToken
is indeed preserved in the output.Hey there. Thanks for submitting this issue! I’m glad you like the library.
What you are actually touching on here is a fundamental aspect of
rollup-plugin-ts
which is that it will deconflict identically named bindings inside the same scope, because it is based on the fundamental assumption that the identifiers may originate from multiple SourceFiles that are brought together and may be identically named.However, TypeScript also supports declaration merging, and this library attempts to figure out when declaration merging or function overloading is happening (in which case it must not deconflict) or not.
In this particular case, I think what’s happening is that
rollup-plugin-ts
mistakenly attempts to deconflict the interface from the NameSpace which leads to something like this:And this is not actually correct. So to fix this, I’ll need to revisit declaration merging vs deconflicting.