Skip to content

Svelte component type not extracted correctly #1897

@jirihon

Description

@jirihon

Describe the bug

With the new version of the Svelte for VS code extension (107.1.0) my component typings stopped working. The previous version 107.0.2 works without any error. It seems that the component type is not extracted correctly from the svelte file.

Reproduction

  1. Create a component with a property feature: string
  2. Create variable of type ComponentType<SvelteComponentTyped<{ feature: string }>>
  3. Assing the component to the variable

Test.svelte

<script lang="ts">
    export let feature: string;
</script>

test.ts

import type { ComponentType, SvelteComponentTyped } from 'svelte';
import Test from './Test.svelte';

const x: ComponentType<SvelteComponentTyped<{ feature: string }>> = Test;

Gives this error:

Types of construct signatures are incompatible.
  Type 'new (options: ComponentConstructorOptions<Record<string, any>>) => SvelteComponentDev' is not assignable to type 'new (options: ComponentConstructorOptions<{ feature: string; }>) => SvelteComponentTyped<{ feature: string; }, any, any>'.
    Construct signature return types 'SvelteComponentDev' and 'SvelteComponentTyped<{ feature: string; }, any, any>' are incompatible.
      The types of '$$prop_def' are incompatible between these types.
        Property 'feature' is missing in type 'Props' but required in type '{ feature: string; }'.

Expected behaviour

No type error.

System Info

  • OS: Ubuntu 22.04
  • IDE: VSCode
  • TypeScript: 4.9.3
  • Svelte: 3.55.1
  • SvelteKit: 1.8.3

Which package is the issue about?

Svelte for VS Code extension

Additional Information, eg. Screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions