Repository navigation
fix(octane): type Strong host prop wrappers against Strong hosts - #2282
Merged
Merged
Conversation
A Strong module's hosts take the Strong JSX types, but ComponentProps<"span"> and the other React-shaped host prop types it imported from octane still described compatibility hosts, so a shadcn-style wrapper spreading its props onto <span> failed octane-tsc with TS2322 on dangerouslySetInnerHTML. The Strong TypeScript view now reads octane through a type-only octane/strong entry that narrows those types to the Strong host contract: TrustedHTML for dangerouslySetInnerHTML and no suppression props. The wrapper type-checks and its callers supply the brand, so the TrustedHTML guarantee holds. The narrowed types remain assignable to the compatibility ones. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 29, 2026 10:37
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | 4d2945e | Commit Preview URL Branch Preview URL |
Oct 29 2026, 10:39 AM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | 4d2945e | Commit Preview URL Branch Preview URL |
Oct 29 2026, 10:39 AM |
Contributor
Benchmark report🟢 No byte growth, no added work, and no timing changes beyond ±3%. Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)No changes across 111 measured values. Public-import reachability bundles (bytes)No changes across 141 measured values. |
6 of 7 tasks
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.
Summary
"use strong"module, a shadcn-style wrapper that spreadsComponentProps<"span">(orHTMLAttributes<T>,SVGProps<T>, …) onto its host now type-checks. Its callers must passtrustHTML(…)to the wrapper'sdangerouslySetInnerHTML, as they would to the host.octanethrough a new type-onlyoctane/strongentry. That entry re-exportsoctaneand narrows its React-shaped host prop types to the Strong host contract.Why
Found while migrating Memos with
@octanejs/codemod --strong(#2280): 12 UI wrappers (ui/badge,dialog,sheet,input,label,textarea, …) failedoctane-tscwith TS2322. The compiler accepted each module and granted Strong mode, so only the typecheck failed. Nearly every shadcn or Base UI app has these wrappers, so without a fix a migrated UI kit cannot be Strong.The error is correct as far as it goes. The compatibility
ComponentProps<"span">accepts a raw{ __html }from callers, so a value of that type can never be assignable to a Strong host. The props type has to change; the Strong host contract cannot loosen. I weighed three options:ComponentPropsand friends against the Strong host contract in Strong modules (this PR)octane's public API.octane's public API is React names only.This extends what Strong already does: its type view selects the Strong JSX types automatically.
ComponentProps<"span">is React's name for "what<span>accepts", so in a Strong module it now means what a Strong<span>accepts.Changes
packages/octane/src/strong.d.ts(new, types only, exported asoctane/strong) re-exportsoctaneand narrows each host prop type:ComponentProps,ComponentPropsWithRef,ComponentPropsWithoutRef,DOMAttributes,DetailedHTMLProps,HTMLProps,SVGProps,SVGAttributes,SVGLine/TextElementAttributes, every*HTMLAttributes, andJSX. In the narrowed types:dangerouslySetInnerHTMLrequiresTrustedHTML;suppressHydrationWarningandsuppressNativeChangeWarningarenever.The narrowing is an intersection, so each Strong type stays assignable to its compatibility type, and a Strong wrapper can still spread its props onto a compatibility component such as a Base UI primitive.
ComponentProps<typeof Component>keeps the component's authored props.compileToVolarMappings: when the virtual TSX selects@jsxImportSource octane/strong, it rewritesimport … from 'octane'to'octane/strong', after every pass that recognises imports by theiroctanesource. Runtime compilation and the inspection entry are unchanged.package.jsonadds./strong(source and publish);build.mjscopies the declaration intodist.public-types.tsgains a one-line pointer to the Strong counterparts.Docs:
docs/strong-compiler-checks.md(Trusted HTML) and the website Strong mode guide.Changeset:
octanepatch.Validation
strong-html.test.tsextends the real-TypeScript Strong JSX harness with wrapper cases, all type-checked by a realts.Program:ComponentProps<"span">,ComponentPropsWithoutRef<'div'>,React.InputHTMLAttributes(namespace import, mixed with a value import), andReact.SVGPropsare clean;trustHTMLpasses, a raw{ __html }fails namingTrustedHTML, and a spreadsuppressHydrationWarningfails;.tshelper importing fromoctane/strongworks;Omit+nullshape: the spread onto the compatibility component fails.vitest --project octaneover the 12 Strong and Volar compiler files (strong-*,volar,native-reads,lazy-ref-strong,bundler-compiler): 2,364 passed.octane-tsc -p packages/octane/tsconfig.json -p packages/octane/typetests/tsconfig.json -p packages/devtools/tsconfig.json -p packages/mdx/tsconfig.json -p website/tsconfig.json: clean. The website iscompiler.strong: true(137.tsrxmodules), and--listFilesconfirms its program loadsstrong.d.ts.pnpm typecheck:coverage,pnpm format:files:check,pnpm sync(it only bumped theoctaneexport count indocs/packages.md)pnpm test, fullpnpm typecheck,pnpm format:check: not run locally, per the local load rule; CI covers them.perf-review:node scripts/perf-review-scan.mjsfound no candidates. The change is type-only plus one editor-only AST pass, which runs once per Strong module in the type view. Runtime output, compiled output, and bundles are unchanged.concise-code: src +126 −9 (runtime +0).strong.d.ts: about 90 lines, one alias per React host prop type. It mirrors the existing list inpublic-types.tsand cannot be derived generically. One new subpath,octane/strong, whose caller is the type view.ComponentProps*(3 lines):HTMLAttributes/SVGPropswrappers hit the same TS2322;Risk / follow-ups
packages/codemod): no change needed for.tsrxoutput; keep emittingimport type { ComponentProps } from 'octane'. A.tsmodule that declares host props consumed by Strong wrappers (for examplebutton-variants.tswithtype ButtonProps = ComponentProps<'button'> & …) is not Strong-viewed and still resolves the compatibility types. Under--strong, the codemod could emit those type imports fromoctane/strong, keeping value imports onoctane.dangerouslySetInnerHTML={{ __html }}to a Strong wrapper now needstrustHTML(…). That is the intended guarantee, but it is newly visible.octaneimport (such as a misspelled export) names"octane/strong"in its message.export … from 'octane're-exports andimport('octane')type queries in Strong modules keep the compatibility types.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Note
Low Risk
Type-checking and editor-only AST rewriting only; no runtime or bundle output changes. Callers of Strong wrappers may newly need trustHTML for innerHTML props.
Overview
Fixes TS2322 on shadcn-style Strong wrappers that spread
ComponentProps<'span'>,HTMLAttributes<T>, or similar onto a host while Strong JSX already requiresTrustedHTMLon the element.Adds a type-only
octane/strongentry that re-exportsoctaneand narrows every React-shaped host prop alias:dangerouslySetInnerHTMLmust beTrustedHTML, andsuppressHydrationWarning/suppressNativeChangeWarningare excluded. Host intrinsics still useComponentProps<typeof MyComponent>for custom components, and the narrowed types stay assignable to compatibility props so a Strong wrapper can still spread onto a Base UI primitive.When the Volar type view uses
@jsxImportSource octane/strong,compileToVolarMappingsrewritesimport … from 'octane'tooctane/strongso authored imports pick up the Strong host contract without changing runtime emit. Plain.tshelpers can import host prop types directly fromoctane/strong.Docs, changeset, build/publish wiring, and
strong-html.test.tscover wrapper, caller, and compat-spread cases.Reviewed by Cursor Bugbot for commit 4d2945e. Bugbot is set up for automated code reviews on this repo. Configure here.