Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

164
Visualizações
¿Por qué tsc descarga la parte "extiende ..." de la siguiente clase de TypeScript al compilar en JavaScript?

¿Por qué tsc descarga la parte "implementa..." de la siguiente clase de TypeScript al compilar en JavaScript?

Versión tsc: Versión 4.6.2 / Versión de nodo: v17.4.0

comando de compilación:

 tsc -t es6 test.ts

// prueba.ts

 class MyElement extends HTMLElement implements HTMLDivElement { align: string; constructor() { super(); this.align = "center"; } public connectedCallback(): void { this.style.backgroundColor = "red"; this.style.width = "100px"; this.style.height = "100px"; } } window.customElements.define('my-element', MyElement); const myElement = document.createElement("my-element"); const Content = document.createTextNode("My text!"); myElement.appendChild(Content); // connectedCallback is called when appended to another element document.body.appendChild(myElement);

// prueba.js

 class MyElement extends HTMLElement { constructor() { super(); this.align = "center"; } connectedCallback() { this.style.backgroundColor = "red"; this.style.width = "200px"; this.style.height = "100px"; } } window.customElements.define('my-element', MyElement); const myElement = document.createElement("my-element"); const Content = document.createTextNode("my text!"); myElement.appendChild(Content); // connectedCallback is called when appended to another element document.body.appendChild(myElement);
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Aparentemente, la solución es la siguiente:

 class MyElement extends HTMLDivElement { constructor() { super(); this.style.width = "100px"; this.style.height = "500px"; this.style.backgroundColor = "red"; } } customElements.define('my-element', MyElement, {extends: 'div'}); const myElement = new MyElement(); const Content = document.createTextNode("my text!"); myElement.appendChild(Content); // connectedCallback is called when appended to another element document.body.appendChild(myElement);
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda