TypeScript-DOM-lib-generator icon indicating copy to clipboard operation
TypeScript-DOM-lib-generator copied to clipboard

cloneNode Return Type Must Be Active Class, Not Base Class (Node)

Open andria-dev opened this issue 1 year ago • 11 comments

The cloneNode return type is incorrect as per #283, #302, https://github.com/microsoft/TypeScript/issues/17818 and #1578. The type before this PR indicated that cloneNode returned a Node, which then broke any class that extended Node. In reality, cloneNode will return an instance of whatever the current class type is, a.k.a. this (DocumentFragment#cloneNode returns a DocumentFragment, not a Node).

This PR solves this issue by changing the return type of Node#cloneNode to this.

andria-dev avatar May 12 '24 01:05 andria-dev