Suggestion: a precise return type of Node.appendChild() #12048
Labels
Bug
A bug in TypeScript
Domain: lib.d.ts
The issue relates to the different libraries shipped with TypeScript
Fixed
A PR has been merged for this issue
Help Wanted
You can do this
Milestone
TypeScript Version: 2.0.6
Code
From lib.es6.d.ts:
Test case:
Expected behavior:
According to Node.appendChild() - MDN:
The return type should be the type of the element being appended, in this case,
HTMLSpanElement
.Actual behavior:
The
appendChild(document.createElement('span'))
just return with the typeNode
.Suggestion
I wonder if it would be better using Generics to define the return type of
appendChild()
, such as:The text was updated successfully, but these errors were encountered: