BareDOM includes TypeScript declarations for every component. Types are auto-generated from component metadata and ship alongside the ESM files — no additional setup required.
- Typed element interfaces extending
HTMLElementwith all properties and methods - Typed custom events with full
detailpayload types HTMLElementTagNameMapaugmentation sodocument.querySelector('x-button')returnsXButton- Custom Elements Manifest (
custom-elements.json) for IDE tooling and HTML intellisense
import '@vanelsas/baredom/x-button';
import '@vanelsas/baredom/x-alert';
// querySelector returns typed XButton
const btn = document.querySelector('x-button')!;
btn.disabled = true; // type-checked
btn.loading = true; // autocomplete works
// Event listeners have typed detail payloads
btn.addEventListener('press', (e) => {
console.log(e.detail.source); // string — fully typed
});
// Custom events on other components
const alert = document.querySelector('x-alert')!;
alert.addEventListener('x-alert-dismiss', (e) => {
console.log(e.detail.reason); // string
console.log(e.detail.type); // string
});
// Components with methods
import '@vanelsas/baredom/x-modal';
const modal = document.querySelector('x-modal')!;
modal.show(); // typed method
modal.hide(); // typed methodThe custom-elements.json manifest enables HTML intellisense in editors that support it. For VS Code, install the Lit Plugin or the Custom Elements Language Server to get attribute autocomplete and validation in HTML templates.