feat: highlight the TypeScript generics attribute on script tags #47

Merged
corneliusio merged 1 commit from feat/generics-attribute into master 2026-08-21 16:09:46 +00:00
corneliusio commented 2026-08-15 07:22:03 +00:00 (Migrated from github.com)

The generics attribute holds a TypeScript type parameter list. Previously it was only an HTML string; now the quoted value is parsed as TypeScript: parameter names, const modifiers, extends constraints, and defaults, reusing the default TS package's type-expression contexts (verified present in ST 4143 through latest).

The attribute is pushed rather than set, so it composes with a lang attribute on either side, and quote termination survives braces (generics="Item extends { text: string }") and string-literal type defaults.

Addresses finding 4 of the syntax audit. Includes a review fix from gpt-5.6: const type parameters (generics="const T extends readonly string[]") scope as a modifier, not a parameter name.

New syntax tests pass on ST builds 4143 and latest.

The [`generics` attribute](https://svelte.dev/docs/svelte/typescript#Generic-$props) holds a TypeScript type parameter list. Previously it was only an HTML string; now the quoted value is parsed as TypeScript: parameter names, `const` modifiers, `extends` constraints, and defaults, reusing the default TS package's type-expression contexts (verified present in ST 4143 through latest). The attribute is pushed rather than set, so it composes with a `lang` attribute on either side, and quote termination survives braces (`generics="Item extends { text: string }"`) and string-literal type defaults. Addresses finding 4 of the syntax audit. Includes a review fix from gpt-5.6: `const` type parameters (`generics="const T extends readonly string[]"`) scope as a modifier, not a parameter name. New syntax tests pass on ST builds 4143 and latest.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
repos/svelte-sublime!47
No description provided.