generics= attribute presentWhen a component has both a <script lang="ts" module> block containing type X = unknown declarations and a <script generics="X ..."> instance block whose generic parameter names match those aliases, svelte-check-rs strips the type alias declarations from the generated TypeScript. Any other code referencing the stripped aliases (e.g. default generic parameters) then fails:
src/lib/DataTable.svelte:5:31
Error: Cannot find name 'TValue'. (ts(TS2304))
src/lib/DataTable.svelte:11:47
Error: Cannot find name 'TData'. (ts(TS2304))
src/lib/DataTable.svelte:11:67
Error: Cannot find name 'TValue'. (ts(TS2304))
Native svelte-check preserves the aliases and produces no errors.
The stripping only happens when:
unknown (e.g. type TData = unknown)<script generics="..."> has the same nameAliases with other values (Record<string, unknown>, unions, interfaces) are preserved.
<script lang="ts" module>
type TData = unknown;
type TValue = unknown;
export interface Column<T = TValue> {
key: string;
label: string;
format?: (value: T) => string;
}
export interface DataTableProps<TPropData = TData, TPropValue = TValue> {
columns: Column<TPropValue>[];
data: TPropData[];
}
</script>
<script generics="TData extends unknown, TValue extends unknown" lang="ts">
let { columns, data }: DataTableProps<TData, TValue> = $props();
</script>
--emit-ts)// === MODULE SCRIPT ===
// type TData = unknown; ← STRIPPED
// type TValue = unknown; ← STRIPPED
export interface Column<T = TValue> { // TValue not found
key: string;
label: string;
format?: (value: T) => string;
}
export interface DataTableProps<TPropData = TData, TPropValue = TValue> { // TData, TValue not found
columns: Column<TPropValue>[];
data: TPropData[];
}
pnpm install
npx svelte-check-rs