Reputation: 199
In @types/urijs, there exists a type that references HTMLElement
new (value?: string | URIOptions | HTMLElement): URI;
Is there a way to ignore the HTMLElement
type if I do not want to include lib:dom
in my tsconfig.json
?
The ideal type locally would be string | URIOptions
Upvotes: 1
Views: 637
Reputation: 249756
There is a proposal to support placeholder types as described here. Unfortunately it is not yet implemented
You will need to make a sort of forward declaration interface to satisfy the types in that library:
declare global {
interface HTMLElement {}
}
Now this does mean you will have a global empty interface named HTMLElement
which may lead to other issues, since HTMLElement
is the empty object type ({}
) any other type will be assignable to it.
Another option would be to declare HTMLElement
as never
:
declare global {
type HTMLElement = never
}
Although this will be incompatible with modules that add augmentations for the HTMLElement
interface.
A decent compromise might be to declare a guard property in the interface to ensure it is not compatible with other types:
declare global {
interface HTMLElement {
guard: "DO NOT INSTANTIATE"
}
}
Upvotes: 2