Open morsh opened 3 years ago
When writing web components (aka custom elements), I need to write something like:
export const createImage = (src) => { const imageElement = document.createElement('img'); imageElement.src = '...'; imageElement.id = 'some-image'; return imageElement; }; class MyCustomElement extends HTMLElement { connectedCallback() { this.appendChild(createImage()); } } customElements.define('my-custom-element', MyCustomElement);
In the above code, HTMLElement; document; this.appendChild; customElements.define are all not defined. A simple solution would be to add "lib": ["es2016", "dom"] to the tsconfig file generated in public/ folder, like so:
HTMLElement
document
this.appendChild
customElements.define
"lib": ["es2016", "dom"]
tsconfig
public/
{ "extends": "corvid-types/configs/tsconfig.public.json", "compilerOptions": { "baseUrl": ".", "lib": [ "es2016", "dom" ], "paths": { "public/*": [ "./*" ] } } }
When writing web components (aka custom elements), I need to write something like:
In the above code,
HTMLElement
;document
;this.appendChild
;customElements.define
are all not defined. A simple solution would be to add"lib": ["es2016", "dom"]
to thetsconfig
file generated inpublic/
folder, like so: