Installation
@vincle/core has zero runtime dependencies. Install it, then configure
TypeScript.
Install#
In an existing project, one with a package.json.
npm install @vincle/core
pnpm add @vincle/core
bun add @vincle/core
Node setup#
Node only. The examples use top-level await, so the project must be an ES
module. Node does not run .tsx files: tsx runs them, typescript checks
types. To type Node APIs (node:fs, process), add "types": ["node"] to
the compilerOptions of the tsconfig.json below.
npm pkg set type=module
npm install -D typescript tsx @types/node
pnpm pkg set type=module
pnpm add -D typescript tsx @types/node
TypeScript configuration#
The same tsconfig.json for npm, pnpm and Bun. jsxImportSource lets JSX files
work without an import.
{
"compilerOptions": {
"target": "es2022",
"module": "preserve",
"moduleResolution": "bundler",
"strict": true,
"noEmit": true,
"jsx": "react-jsx",
"jsxImportSource": "@vincle/core"
}
}
Attributes are typed per element (src on <img>, href on <a>), with
nothing extra to install: see JSX types.
Run a file#
Save the hello world as
index.tsx, add console.log(html) at the end, then run it.
npx tsx index.tsx
npx tsc # type check
pnpm exec tsx index.tsx
pnpm exec tsc # type check
bun index.tsx
bun check # type check, built into Bun
Where to next#
- First render: your first component
- TypeScript setup: Deno, esbuild