Closed
Description
TypeScript Version: master
Expected behavior:
interface SVGElementTagNameMap {
'a': SVGAElement;
}
interface ElementTagNameMap extends HTMLElementTagNameMap, SVGElementTagNameMap {
}
But deriving from both HTMLElementTagNameMap
and SVGElementTagNameMap
still throw an error by conflicts. To resolve this, ElementTagNameMap
has to be defined using Diff type as follows.
interface ElementTagNameMap extends HTMLElementTagNameMap, Diff<SVGElementTagNameMap, HTMLElementTagNameMap> {
}
type Diff<T, U> = Pick<T, DiffKey<keyof T, keyof U>>;
type DiffKey<T extends string, U extends string> = (
& { [P in T]: P; }
& { [P in U]: never; }
& { [x: string]: never; }
)[T];
However, defining ElementTagNameMap
is originally wrong. It should be removed later.
Actual behavior:
interface ElementTagNameMap {
'a': SVGAElement; // error, conflicts with 'a': HTMLAnchorElement;
}