microsoft / microsoft/TypeScript

Overload missing from createElementNS

Open Beginner friendly
#63,556 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Domain: lib.d.ts Possible Improvement
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

### ⚙ Compilation target

ESNext

### ⚙ Library

6.0.0

### Missing / Incorrect Definition

overload is missing for the `createElementNS` in case provide `"http://www.w3.org/1999/xhtml"` as `namespaceURI`.
```ts
// missing createElementNS(namespaceURI: "http://www.w3.org/1999/xhtml", qualifiedName: K): HTMLElementTagNameMap[K];
createElementNS(namespaceURI: "http://www.w3.org/1999/xhtml", qualifiedName: string): HTMLElement;
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: K): SVGElementTagNameMap[K];
createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: string): SVGElement;
createElementNS(namespaceURI: "http://www.w3.org/1998/Math/MathML", qualifiedName: K): MathMLElementTagNameMap[K];
```

### Sample Code

```TypeScript
document.createElementNS("http://www.w3.org/1999/xhtml", 'div'); // HTMLElement instead of HTMLDivElement
```

### Documentation Link

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the DOM library declaration for Document.createElementNS and compare its existing namespace-specific overloads. Add the missing XHTML overload shown in the issue, then run the relevant TypeScript library or compiler tests to verify that an XHTML tag such as "div" is inferred as HTMLDivElement rather than HTMLElement.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
75/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.