@shikchen/typed-hype
v0.2.0
Published
A tiny, fully type-safe hyperscript utility for creating DOM elements with TypeScript.
Readme
typed-hype
A tiny, fully type-safe hyperscript utility for creating DOM elements with TypeScript.
Installation
npm install @shikchen/typed-hype
# or
yarn add @shikchen/typed-hype
# or
pnpm add @shikchen/typed-hype
# or
bun add @shikchen/typed-hypeMotivation
Modern web frameworks (React, Vue, Svelte, Angular, Lit, etc.) are powerful, but often overkill for simpler tasks like code playgrounds, browser extensions, or small vanilla JS/TS projects.
While vanilla DOM manipulation works, it can be verbose. Traditional hyperscript offers a more concise syntax, but it lacks strong type safety as its DefinitelyTyped definitions are quite loose. React's createElement() and similar JSX alternatives exist, but they often bring along dependencies or concepts (like VDOM) that aren't needed for simple DOM creation.
Features
- Lightweight: Tiny footprint with zero dependencies.
- Type-Safe: Leverages TypeScript for comprehensive type checking of HTML tags, attributes, CSS styles, and event handlers. Get great autocompletion in your editor.
- Simple API: A familiar hyperscript-style function (
h) for creating elements programmatically. - Developer Friendly: Reduces boilerplate and catches errors at compile time, not runtime. Its predictable API is also well-suited for AI-assisted code generation.
