@b9g/jsx-web-types — typed JSX intrinsic elements (#60) - #362
Open
brainkim wants to merge 2 commits into
Open
Conversation
brainkim
marked this pull request as ready for review
June 23, 2026 19:12
brainkim
commented
Jun 24, 2026
brainkim
force-pushed
the
jsx-web-types-update
branch
3 times, most recently
from
July 14, 2026 06:53
8e825dd to
aef0618
Compare
brainkim
commented
Jul 16, 2026
brainkim
commented
Jul 16, 2026
|
|
||
| export interface IntrinsicElements { | ||
| [tag: string]: any; | ||
| // Crank-specific prop value conventions, layered onto the platform types |
Member
Author
There was a problem hiding this comment.
This is pretty cool. The design makes me feel like a cat bathing in the sun.
brainkim
commented
Jul 16, 2026
| type="text" | ||
| copy={force ? false : "value"} | ||
| value={value} | ||
| // @ts-expect-error - handler types the event as InputEvent; the native oninput prop uses the base Event |
Member
Author
There was a problem hiding this comment.
The handler prop derives its event type from lib.dom’s GlobalEventHandlersEventMap, and lib.dom types oninput as the base Event, not InputEvent (long-standing quirk — the runtime fires an InputEvent, but the static type is widened). So a callback annotated (ev: InputEvent) is not assignable to the (ev: Event) => … the prop expects, hence the @ts-expect-error. The test pins that gap so we notice if the generated types ever start narrowing it.
brainkim
added a commit
that referenced
this pull request
Jul 16, 2026
Per review on #362: acronyms retain their case (acrocase.org), so resolveDomLib → resolveDOMLib, mdnUrl → mdnURL, isFragmentUrl → isFragmentURL, formattedHtml → formattedHTML. The mdnURL locals now match the mdnURL object keys they feed, which collapse to shorthand. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds the @b9g/jsx-web-types workspace package and wires it into Crank's JSX.IntrinsicElements, giving first-class typing for HTML, SVG, and MathML intrinsic elements and their attributes. Element and global-attribute data is generated from BCD and MDN rather than hand-maintained, with a corrections layer covering the SVG presentation and MathML global-attribute gaps upstream still has. Unknown intrinsic tags now error, not just unknown attributes.
Per review on #362: acronyms retain their case (acrocase.org), so resolveDomLib → resolveDOMLib, mdnUrl → mdnURL, isFragmentUrl → isFragmentURL, formattedHtml → formattedHTML. The mdnURL locals now match the mdnURL object keys they feed, which collapse to shorthand. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
brainkim
force-pushed
the
jsx-web-types-update
branch
from
August 11, 2026 22:49
2e1b3a0 to
29ab3b4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduces
@b9g/jsx-web-typesand wires it into Crank'sJSX.IntrinsicElements(#60). Spec-driven, framework-agnostic types for HTML, SVG, and MathML intrinsic elements.What it is
.d.tspackage: element → attributes/properties, ARIA, microdata/RDFa, global attributes, and a DOM event map. Each attribute carries its MDN description.class,onclick). A separate camelCase variant (@b9g/jsx-web-types/camel-case) re-keys them for React/Inferno (className,htmlFor, …), with names sourced from React's ownpossibleStandardNames.js.JSX.IntrinsicElements extends WebIntrinsicElements<…>, supplying its own intrinsic attributes (key/ref/prop:/attr:), children attribute, and object-style/classvalue overrides via theTPropOverridesparameter — so Crank's conventions live in the parameters, not the base types.Everything is sourced — no hand-coded platform data
Generation is a reproducible function of authoritative sources:
@mdn/browser-compat-data)global_attributes, deprecated/experimental status,mdn_urlcheerio, cached indata/mdn-cache.json(offline-capable; network only on a cache miss)aria-datalib.dom.d.ts*EventMapinterfacests-morphscripts/parse-rdfa-w3c.ts→data/rdfa-attributes.jsonscripts/parse-microdata-mdn.ts→data/microdata-attributes.jsonpossibleStandardNames.jsscripts/parse-camel-case-names.ts→src/camel-case.generated.d.tsXMLAttributesW3C setEvery
.d.tsanddata/*.jsonis regenerable from these and stamped do-not-edit; there is no hand-frozen platform data.Descriptions surface in editors (LSP)
Each attribute's MDN JSDoc reaches hover/completion. The prop types are composed so TypeScript preserves per-attribute doc comments (homomorphic mapped types; multi-namespace tags resolved by precedence rather than unioned), verified end-to-end through Crank JSX with the TypeScript language service —
<div class>,<a href>,<label for>, etc. all show their descriptions.Children
Void elements aren't specially typed: every element accepts children (the runtime ignores stray ones), so there's no void set or
TIsVoidplumbing to maintain.Tests
bun run testtypechecks bothsrc/and the type-level test suite intests/. Roottsc --noEmitis clean.🤖 Generated with Claude Code