@b9g/jsx-web-types — typed JSX intrinsic elements (#60)#362
Open
brainkim wants to merge 1 commit into
Open
Conversation
brainkim
commented
Jun 24, 2026
| // node_modules layout. require.resolve can land in a package store that omits | ||
| // the bundled lib files (e.g. Bun's .bun store), so we also walk up from this | ||
| // script looking for node_modules/typescript/lib, which handles hoisting. | ||
| function resolveDomLib(): string { |
Member
Author
There was a problem hiding this comment.
@claude Please use acrocase: https://acrocase.org
7fdbc62 to
8e825dd
Compare
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.
8e825dd to
aef0618
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