Repository navigation
Ship custom element tag-name typing in the published declarations - #958
Merged
Merged
Conversation
Bundle Size Budgets
Bundle and package sizeWeb bundle sizes cover shipped runtime JavaScript. Package sizes cover the full published archive, including any source maps, declarations, and documentation it contains.
Web package files (uncompressed)These are uncompressed file sizes; they do not sum to the compressed package size above.
How sizes are measuredMeasured from the PR base SHA and PR head SHA. Web bundle rows sum shipped |
kiftio
added this pull request to stack #959
October 8, 2026 14:29
kiftio
marked this pull request as ready for review
October 8, 2026 14:31
API Extractor (rollupTypes) drops `declare global` blocks, so the
published declarations lost the HTMLElementTagNameMap augmentation.
TypeScript consumers got a plain HTMLElement from
document.createElement("shopify-checkout") and had to cast.
Append the augmentation to the rolled-up dist/index.d.ts after the
declaration build, and fail the build if ShopifyCheckout moves out of it.
Replace the hard-coded shopify-checkout augmentation with entries collected from each component's per-file declarations, appended once to the rolled-up entry (API Extractor drops `declare global`; microsoft/rushstack#1709). The build fails if a mapped class isn't exported from the entry or two classes claim one tag. The e2e helpers now resolve the element type through HTMLElementTagNameMap["shopify-checkout"] instead of casting to the class, so the e2e typecheck (which runs against the built package) fails if the published typing goes missing.
Locator.evaluate infers the element type from the callback parameter, so annotating it with HTMLElementTagNameMap["shopify-checkout"] replaces the casts and keeps the e2e typecheck tied to the published tag typing.
kiftio
force-pushed
the
dk/web-tag-name-types
branch
from
October 8, 2026 19:25
1c1c658 to
1f48c42
Compare
markmur
approved these changes
Oct 9, 2026
This was referenced Oct 9, 2026
kiftio
added a commit
that referenced
this pull request
Oct 9, 2026
Replace vite-plugin-dts (API Extractor) with rolldown-plugin-dts, which keeps `declare global` augmentations in the bundled declarations (microsoft/rushstack#1709). The tag-name collection workaround from #958 (scripts/tag-name-map.ts and its tests) is deleted. The HTMLElementTagNameMap entry moves from register.ts to the class module it describes: both the package root and the component entry import that module, so either import types <shopify-checkout>, and the component entry declaration stays a shim onto the root as before. The custom-elements manifest is unchanged. With #961 (Vite 8.3, Rolldown >= 1.2) and #962 (protocol declarations emittable in isolation), the plugin runs on its default isolated- declarations generator with two config lines: an oxc exclude for emitted declarations and `sideEffects: true`. No tsc-mode workarounds remain. Output: one rolled-up dist/index.d.ts with the same 26 exports as before, the protocol package still inlined, no external imports. Package file set is unchanged. The full web build is ~0.8 s end to end.
kiftio
added a commit
that referenced
this pull request
Oct 9, 2026
Enable isolatedDeclarations for the protocol TypeScript package so every exported value carries a type that can be emitted without type inference across files: - The generated catalog (`checkoutProtocolCatalogPayloadDecoders`, `notificationDescriptors`, `requestDescriptors`) now has explicit named types instead of `satisfies`. The three new type aliases are additive. - `EmbeddedCheckoutProtocol` is annotated with `typeof` queries instead of relying on `as const` inference over shorthand properties. - Codegen passes --isolatedDeclarations to the declaration emit so the committed .d.ts files stay compliant. The committed declarations are shorter (named mapped types rather than expanded object types) but structurally identical: Checkout Kit Web's rolled-up dist/index.d.ts is byte-for-byte unchanged. This removes the protocol-package reasons that rolldown-plugin-dts needed tsc-mode workarounds for in the #958 spike.
kiftio
added a commit
that referenced
this pull request
Oct 9, 2026
Replace vite-plugin-dts (API Extractor) with rolldown-plugin-dts, which keeps `declare global` augmentations in the bundled declarations (microsoft/rushstack#1709). The tag-name collection workaround from #958 (scripts/tag-name-map.ts and its tests) is deleted. The HTMLElementTagNameMap entry moves from register.ts to the class module it describes: both the package root and the component entry import that module, so either import types <shopify-checkout>, and the component entry declaration stays a shim onto the root as before. The custom-elements manifest is unchanged. With #961 (Vite 8.3, Rolldown >= 1.2) and #962 (protocol declarations emittable in isolation), the plugin runs on its default isolated- declarations generator with two config lines: an oxc exclude for emitted declarations and `sideEffects: true`. No tsc-mode workarounds remain. Output: one rolled-up dist/index.d.ts with the same 26 exports as before, the protocol package still inlined, no external imports. Package file set is unchanged. The full web build is ~0.8 s end to end.
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.
What changes are you making?
The published types lose every custom element's tag-name typing; today that means
<shopify-checkout>. Each component declares its tag in adeclare global { interface HTMLElementTagNameMap … }block, but API Extractor (vite-plugin-dtswithrollupTypes) dropsdeclare globalwhen it bundles the declarations. This is a known limitation: microsoft/rushstack#1709, open since 2020, withHTMLElementTagNameMapcalled out in the thread. TypeScript consumers got a plainHTMLElementfromdocument.createElement("shopify-checkout")and had to cast:scripts/tag-name-map.tsrestores it with the workaround used in #1709, made generic:beforeWriteFile), collect every component'sHTMLElementTagNameMapentries from its per-file declarations, parsed with the TypeScript compiler API.dist/index.d.ts.New components get their typing without config changes; each component's
register.tsstays the only place its tag is written.Note
Alternative considered: replacing API Extractor with
rolldown-plugin-dts, which keepsdeclare globaland so would make this workaround unnecessary. A spike produced an identical public API (diffed with the TypeScript checker) — the same types, from a different tool — at the cost of: a pre-1.0 dependency (0.28.x) in the publish path, six config workarounds to inline the protocol package's types the way API Extractor'sbundledPackagesdoes, ~1.5 s slower builds, and (at the time) a Rolldown ≥ 1.2 requirement that Vite 8.0 did not meet. Vite 8.3 has since removed that last blocker, but the others stand, and this workaround is 120 tested lines that delete cleanly. Reassess when the plugin reaches 1.0 or the protocol-package type layout changes for other reasons.It sits at the bottom of the Web stack so #940 builds on it directly. #940 extends the typing to the new
@shopify/checkout-kit/shopify-checkoutentry and adds strict consumer type tests for both import styles.How to test
pnpm testruns thescripts/tag-name-map.test.tsunit tests (collection, sorting, the missing-export, conflicting-tag and double-append failures). Vitest now includesscripts/**/*.test.ts.HTMLElementTagNameMap["shopify-checkout"]instead of casting to the class. CI'spnpm --dir test/e2e typecheckruns against the built package, so it fails if the published typing goes missing. I verified this by removing the augmentation fromdist/index.d.ts:TS2339: Property 'shopify-checkout' does not exist on type 'HTMLElementTagNameMap'.pnpm lint,pnpm build,pnpm verify,pnpm compare-snapshotand the Playwright suite (16/16) pass.