2
我試圖在打字稿中擴展HTMLElement。我嘗試了不同的方法,他們都工作,但我不斷得到一個類型腳本錯誤:在TypeScript中擴展HTMLElement
參數精靈不能分配給參數類型節點;
當我做:
document.body.appendChild(createSprite());
interface Sprite extends HTMLElement { } function createSprite() : Sprite { return <Sprite> document.createElement("div"); } document.body.appendChild(createSprite());
你的代碼生成我。你有最新版的Typescript編譯器嗎? –