Skip to content

feat: emit cross-file types and generics on svelte - #76

Merged
alexgrozav merged 4 commits into
milestone-m5-uxf-443from
svelte-types-generics-uxf-464
Oct 29, 2026
Merged

alexgrozav merged 4 commits into
milestone-m5-uxf-443from
svelte-types-generics-uxf-464

Conversation

@alexgrozav

@alexgrozav alexgrozav commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Cross-file types and generic components on Svelte, its types lane (ADR-0067, ADR-0068). Svelte's output changes, and so do the docs examples that quote it.

  • Type imports. A component imports the types it reads by name, under the source's names: a child's from its output beside the child (import Field, { type FieldProps } from "./Field.svelte"), a .ts module's or a package's from the specifier as written (import type { TimeInterval } from "rxjs"). The types come from codegen's shared helper.
  • Exported types in <script module>. An output that exports a type now declares its types and type imports in <script lang="ts" module>, with the module's other type exports and re-exports (export type { Tone } from "./types"), so a consumer imports them from the component's file. As ADR-0068 says, this moves every Svelte golden that exports a type (about 95 outside types/ and generics/): the declarations move from the instance script to the module script, and nothing renders differently.
  • Generics. A generic component writes its type parameters in the instance script's generics (<script lang="ts" generics="T extends string">), and a scoped slot's props that name one stay Snippet<[{ item: T }]>. An attribute can't hold its own quote, so every string literal in the type parameters is double-quoted, a template literal stays in backticks, a ' inside either is written \u0027 (the same type), and the attribute is single-quoted where the text holds a ". A hole in a template literal is read as code again.
  • codegen's formatter finds a script block whose quoted attribute holds a >, as generics="T extends Array<string>" does. Before, it reported such an output as unparsable, on Vue's generic too.
  • Docs. The 13 Svelte examples on the components pages that quote a moved golden are copied again from it.
  • Consumers and tests. Svelte consumer fixtures for the 12 types and generics cases, type and generic misuses among them, and the scoped-slot misuse caught as TS2339. Svelte's quarantine is empty again, and its package tests check these cases again, with each case's .ts modules written beside the re-emitted outputs.

Parity matrix

  • Every project, run from a checkout whose path holds no .ts: 1402 files, 8829 tests passed, 242 skipped. The summary reports no problem and no stale entry.
  • cases/types and cases/generics, all seven browser projects: 84 files, 132 tests passed, 1 skipped (Astro, interactivity).

Checklist

  • The title follows Conventional Commits, as in feat(web): sell the next framework on the homepage.
  • pnpm format:check, pnpm lint, pnpm check-types and pnpm test pass. (The first three pass. In place of pnpm test: @unframework/target-svelte's tests and the whole integration suite, both green, from a checkout whose path holds no .ts.)
  • Changes to a published package: a changeset from pnpm changeset (see .changeset/README.md).
  • Homepage changes: pnpm build, then pnpm --filter web lighthouse, still scores at least 0.95 in every category.

Svelte imports the types a component reads by name, under the source's
names: a child's from its output beside the child, a `.ts` module's or a
package's from the specifier as written (ADR-0067). An output that
exports a type declares its types and type imports in `<script module>`,
with the module's type exports, so consumers import them from the
component's file (ADR-0068). That moves every Svelte golden that exports
a type. A generic component writes its type parameters in the instance
script's `generics`.

The Svelte consumer fixtures cover the types and generics cases, its
quarantine entries are gone, and its package tests check the cases
again, with the `.ts` modules beside the re-emitted outputs.

Co-authored-by: multica-agent <github@multica.ai>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://svelte-types-generics-uxf-464-unframework.blue-water-0397.workers.dev (commit b802841)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://b603c557-unframework.blue-water-0397.workers.dev b802841 2026-10-29T09:32:24.737Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://a8309401-unframework.blue-water-0397.workers.dev ebfa8d2 2026-10-29T08:49:15.963Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://6c9f18d3-unframework.blue-water-0397.workers.dev af2cfc3 2026-10-28T12:50:01.793Z Visit the dashboard ↗

alexgrozav and others added 3 commits October 29, 2026 10:34
… examples

A `generics` attribute cannot hold its own quote, so a constraint with
both quote kinds wrote an attribute Svelte could not parse. Every string
literal in the type parameters is now double-quoted, a `'` inside one
written `'`, which names the same type, and the attribute is
single-quoted where it holds a literal.

The 13 Svelte examples on the components pages are copied again from
their goldens, whose exported types moved to `<script module>`.

Co-authored-by: multica-agent <github@multica.ai>
A `'` inside a template literal type started a string literal for the
rewriter, so `` `don't` `` became a different type. Template literals
now stay in backticks, a `'` inside one written `'`, which names
the same character.

Co-authored-by: multica-agent <github@multica.ai>
A template literal's hole is code, so a `'` string inside it is written
double-quoted like any other, never as `'`, which would break the
type. The formatter finds a script block whose quoted attribute holds a
`>`, as a generic constraint such as `Array<string>` does, where it
reported the output as unparsable on Svelte and Vue alike.

Co-authored-by: multica-agent <github@multica.ai>
@alexgrozav
alexgrozav merged commit 7e84330 into milestone-m5-uxf-443 Oct 29, 2026
49 checks passed
@alexgrozav
alexgrozav deleted the svelte-types-generics-uxf-464 branch October 29, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant