Skip to content

Cannot use records inside new generics="T extends { key: string }" attribute #2039

Closed
@Nick-Mazuk

Description

@Nick-Mazuk

Describe the bug

Using the new generics notation introduced in #2020, you cannot use records the generics attribute because the generics attribute is parsed as an HTML string, not as TypeScript code.

Reproduction

<script lang='ts' generics='T extends { foo: string }'>

</script>

Gives the error:

Error: Expected } (svelte)
<script lang="ts" generics="T extends { key: string }">

Expected behaviour

This entire string is parsed as JS and not as a string with interpolation.

System Info

  • OS: macOS 13.3.1
  • IDE: VS Code
  • Svelte Check: 3.4.3

Which package is the issue about?

svelte-check

Additional Information, eg. Screenshots

There is a workaround, but I don't think this is ideal.

<script lang='ts' context='module'>
    type Foo = { foo: string }
</script>

<script lang='ts' generics='T extends Foo'>

</script>

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedFixed in master branch. Pending production release.bugSomething isn't workingupstream

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions