Repository navigation
feat: emit cross-file types and generics on svelte - #76
Merged
Merged
Conversation
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>
🚀 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 deploymentPreview Deployments by commit
|
… 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>
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 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.
import Field, { type FieldProps } from "./Field.svelte"), a.tsmodule's or a package's from the specifier as written (import type { TimeInterval } from "rxjs"). The types come from codegen's shared helper.<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 outsidetypes/andgenerics/): the declarations move from the instance script to the module script, and nothing renders differently.generics(<script lang="ts" generics="T extends string">), and a scoped slot's props that name one staySnippet<[{ 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.>, asgenerics="T extends Array<string>"does. Before, it reported such an output as unparsable, on Vue'sgenerictoo.typeand 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.tsmodules written beside the re-emitted outputs.Parity matrix
.ts: 1402 files, 8829 tests passed, 242 skipped. The summary reports no problem and no stale entry.cases/typesandcases/generics, all seven browser projects: 84 files, 132 tests passed, 1 skipped (Astro,interactivity).Checklist
feat(web): sell the next framework on the homepage.pnpm format:check,pnpm lint,pnpm check-typesandpnpm testpass. (The first three pass. In place ofpnpm test:@unframework/target-svelte's tests and the whole integration suite, both green, from a checkout whose path holds no.ts.)pnpm changeset(see.changeset/README.md).pnpm build, thenpnpm --filter web lighthouse, still scores at least 0.95 in every category.