Skip to content
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

add ParentNode['replaceChildren'] to dom.generated.d.ts #43456

Closed
btoo opened this issue Mar 31, 2021 · 4 comments
Closed

add ParentNode['replaceChildren'] to dom.generated.d.ts #43456

btoo opened this issue Mar 31, 2021 · 4 comments
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript
Milestone

Comments

@btoo
Copy link

btoo commented Mar 31, 2021

lib Update Request

Configuration Check

My compilation target is ES2021 and my lib is lib.dom.d.ts.

Missing / Incorrect Definition

ParentNode.replaceChildren()

Sample Code

document.body.replaceChildren();
document.body.replaceChildren('hello world', document.createElement('button'));

Documentation Link

MDN
WHATWG

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript labels Mar 31, 2021
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Mar 31, 2021
@Ragzouken
Copy link

relevant issue from the repository the types are generated from: microsoft/TypeScript-DOM-lib-generator#985

@kidlj
Copy link

kidlj commented Nov 26, 2022

Has this been merged into upstream? I have n.parentNode.replaceChildren successfully executed but TypeScript reports error:

TS2339: Property 'replaceChildren' does not exist on type 'ParentNode'.

for the following code:

function mount(n: Node) {
	for (let p = n.parentNode; p != null && p.nodeName != "HTML"; p = p.parentNode) {
		(<ParentNode>p).replaceChildren(n)
		n = p
	}
}

Also if I don't force casting (<ParentNode>p), it reports:

TS2339: Property 'replaceChildren' does not exist on type 'Node & ParentNode'.

Don't know why.

@kidlj
Copy link

kidlj commented Nov 26, 2022

Well, don't compile in production mode. I have to use type casting (<any>p).replaceChildren(n) for it to build.

@jakebailey
Copy link
Member

This was fixed back in #44684 for TS 4.4+. The examples in this thread all compile. Playground Link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants