This project and the components are written in TypeScript. We recommend using TypeScript for your project as well.
The components work in a JavaScript app as they are. A WebJs app runs TypeScript with no build step: when the server loads or serves a .ts file it strips the types (with Node's built-in module.stripTypeScriptTypes on Node 24 and later, and with amaro on Bun) and leaves the code where it was. So a JavaScript app imports the kit's .ts files directly, from .js pages and components, and the browser receives plain JavaScript.
add always writes .ts files. Leave tsx out of components.json, since the config schema is strict and an unknown key is an error.
Importing from JavaScript
Write the import with the .ts extension, as every import in a WebJs app carries its extension:
import { html } from '@webjsdev/core';
import { buttonClass } from '#components/ui/button.ts';
export default function Page() {
return html`<button class=${buttonClass({ variant: 'outline' })}>Button</button>`;
}
A Tier-2 element registers itself when its module loads, so importing it is the whole wiring, from a .js file as from a .ts one:
import '#components/ui/dialog.ts';
Import aliases
The # import aliases come from the imports field of package.json, which Node and Bun resolve at runtime. A JavaScript app needs no jsconfig.json for them:
{
"imports": {
"#*": "./*"
}
}
See Package Imports for the details.
Editing the components
The files add copies into your project are yours to edit. Their TypeScript is erasable on purpose: type annotations, interfaces and import type lines, with no enum, no value namespace and no constructor parameter properties. That is the syntax WebJs can strip without changing a character's position, so you can edit a component's code without touching its types, and the file keeps running.
The scaffold's tsconfig.json sets erasableSyntaxOnly, so an edit to a copied component that breaks the rule is reported in your editor before it reaches the server.