0095. Every typed position in markup is checked by TypeScript, through the script view
- Status: Accepted (Mik, 17 Nov 2026)
- Date: 2026-11-14
- Decided by: integrator (internal only), pending Mik's approval as a language change
- Planning item: none
Context
Mik asked for strong types that fail loudly, and nothing that feels like Angular: no template language with types of its own, no string-typed magic, no error that only shows when the page runs. Before this record the editor's script view (decision 0026) typed a page's expressions, but a prop passed to a component, an attribute's value, a binding and a word like type="emial" were not checked by anything, and the build ran no type checker at all.
Decision
Markup has no type system of its own. Every typed position becomes ordinary TypeScript in the script view (crates/script-view), checked with the script block it belongs to:
| Markup | Checked as |
|---|---|
{post.caption} | __duolith_text(post.caption): a string, number or bigint, or nothing; a boolean, object or function would show as "false" or "[object Object]" |
src={post.image} | __duolith_attribute<string>(post.image): the attribute's new accepts type |
type="email" | the same, with the word as a string literal, when accepts is a set of words |
on:input={type} | __duolith_on<{ readonly value: string }>(type): the event's receives (decision 0027) |
bind:value={draft} | draft = __duolith_bind<string>(draft): both directions |
<show when={user}>…<otherwise> | if (user) { … } else { … }: the children see user narrowed |
<list each as index key> | a for … of loop over __duolith_items or __duolith_entries; key is a string or number |
<Card title="x" bind:open={o}> | __duolith_place(Card, { title: "x", open: (o) }) and o = __duolith_bound(Card, "open") |
| a component file | export default __duolith_component<Props, "defaulted">(), typed by its props<...>() |
route() in pages/post/[id].duo | route<{ readonly id: string }>(); a layout's and a component's route() keep the general type |
- **
accepts** is a new optional field on an attribute inspec/language/elements.yaml, besidevalueandreceives: the TypeScript type its value must have, such asbooleanor"text" | "email". Whenacceptsis a set of words, a quoted value is checked by TypeScript as that word.placementanddetentwritten as words keep their own analyzer checks (E0152, E0153). - A quoted value must be one the attribute can take (E0355). Quoted text is always a string, so TypeScript alone would let
<slider min="abc">and<button disabled="false">through: the first breaks the slider, the second ships a disabled button. The analyzer checks every quoted value againstaccepts: a wordacceptslists passes; fornumber, the text must be a number (rows="3"stays valid,rows="many"is an error); forboolean, any quoted text is an error, with the fixdisabled={false}ordisabledalone. This is a language change:zoomable="false"andlazy="false"were valid and are now E0355, and the language definition and the guide now writezoomable={false}. - Undefined means left out. An attribute or prop given
undefinedis the same as one not written, as it is at run time (mount.tsremoves the attribute,component.tsapplies the default). Markup cannot leave an attribute out on a condition, so this is how a page passes "maybe". - The structural checks (E0101 to E0170) and the type check run together, and both report every error they find. A file with a structural error has its type errors held back, so a missing prop is reported once (E0113), not twice; every other file's type errors are reported in the same run.
- Problems with a whole props object, such as a missing prop, are shown on the component's name; nothing is ever reported in generated text.
Alternatives considered
| Option | Why not |
|---|---|
| A markup type checker of our own | A second type system that drifts from TypeScript's, the Angular template problem |
| Type attributes in the analyzer from a small type language | Cannot follow types through the script (a state's type, a union, a narrowed value) |
| Check only expressions, not quoted words | type="emial" and variant="primry" would still fail only at run time |
Consequences
spec/language/elements.yaml gains accepts on existing attributes, additively. Each new attribute should say what it accepts; one without accepts is checked only as an expression. Deciding current's type showed it also takes page, step, location, date or time, which DatePicker uses; the description now says so. The kit's ChipGroup gained values for its several-at-once mode (decision 0097).