Skip to content

Unable to define SVG elements conflicting with HTML #20149

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

Closed
falsandtru opened this issue Nov 20, 2017 · 2 comments
Closed

Unable to define SVG elements conflicting with HTML #20149

falsandtru opened this issue Nov 20, 2017 · 2 comments
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed

Comments

@falsandtru
Copy link
Contributor

falsandtru commented Nov 20, 2017

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;
}

related: #20134, #14783

@falsandtru falsandtru changed the title Unable to define SVG elements Unable to define SVG elements conflicting with HTML Nov 20, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Nov 20, 2017

We should not include Diff in the library. For ones that conflict having them default to the HTMLElement seems like a reasonable compromise.

@mhegazy mhegazy added the Design Limitation Constraints of the existing architecture prevent this from being fixed label Nov 20, 2017
@falsandtru
Copy link
Contributor Author

We can resolve this issue without Diff type by removing ElementTagNameMap: microsoft/TypeScript-DOM-lib-generator#326

@mhegazy mhegazy closed this as completed Nov 21, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed
Projects
None yet
Development

No branches or pull requests

2 participants