Skip to content

Intermediate type hides errors with component doesn't implement $$Props #1830

@kizivat

Description

@kizivat

Describe the bug

I cannot pinpoint what causes this exactly, but when I was trying to implement prop types that are inferred from the value of another one, I ran into a weird issue - weir because it's solved when I create an intermediate type to assign a intersection type to $$Props

type T = $$Generic<SupportedAs>;
+ type Props = RenderProps<T> & { anotherProp: string };
- type $$Props = RenderProps<T> & { anotherProp: string }; // error
+ type $$Props = Props;

While I was trying to create an example I discovered another error which just pretends like a type defined just previous line cannot by found.

You can find both examples in repo: https://github.com/kizivat/svelte-props-error

The original problem can be seen in file https://github.com/kizivat/svelte-props-error/blob/main/src/lib/components/WithoutIntermediateType.svelte while in https://github.com/kizivat/svelte-props-error/blob/main/src/lib/components/IntermediateType.svelte is the solution to the problem.

The second problem I've discovered along the way (not sure if connected) can be seen at https://github.com/kizivat/svelte-props-error/blob/main/src/lib/components/SupportedElementError.svelte

Reproduction

git clone https://github.com/kizivat/svelte-props-error
npm i

Expected behaviour

I would expect bot erroneous cases to work without errors. 🤔

System Info

  • OS: macOS Ventura 13.1
  • IDE: VSCode 1.74.3

Which package is the issue about?

None

Additional Information, eg. Screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions