Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

153
Vistas
why does tsc dump the "extends ..." part of the following Typescript class when compiling to JavaScript?

why does tsc dump the "implements ..." part of the following Typescript class when compiling to JavaScript ?

tsc version: Version 4.6.2 / Node version: v17.4.0

compilation command:

tsc -t es6 test.ts

// test.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);

// test.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 Respuestas
Responde la pregunta

0

Apparently the workaround is as follows:


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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda