String content erased when inferring slot/event type from props
See original GitHub issueThe following Svelte code fails to check with svelte-check
v2.2.3.
<!-- Component.svelte -->
<script lang="typescript">
export let variant: "foo" | "bar"
export let style: string
</script>
<!-- index.svelte -->
<script lang="typescript">
import Component from "./Component.svelte";
</script>
<Component
variant="foo"
style={`${
1
}`}
on:click={() => {}}
/>
It shows the error
Error: Type '""' is not assignable to type '"foo" | "bar"'. (ts)
on:click={() => {}}
/>
The example looks artificial but this layout is produced by prettier if the expression inside ${}
is long.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Loss of function parameter typing when inferring props of ...
Tf you hover on exampleFunction to get the intellisense for it, the correct type is observed. It seems to be lost on the...
Read more >Infer type from parent props - reactjs - Stack Overflow
Let me explain better with an example: suppose I have <Parent> and <Child> components, and an interface IMyComplexObject . interface ...
Read more >Useful Patterns by Use Case - React TypeScript Cheatsheets
Strategy: extract a component's props by inferring them. Example: // ReactUtilityTypes.d.ts declare type $ElementProps<T> = T extends React.
Read more >Notes on TypeScript: Inferring React PropTypes
In this part of the "Notes on TypeScript" we will learn how we can leverage TypeScript to infer these component prop-types.
Read more >Notes on TypeScript: Inferring React PropTypes | by A. Sharif
When inferring these prop-type definitions, we can see that the returned type ... Type 'string' is not assignable to type 'number'
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The multiline problem is fixed now.
The empty string part is released. You can try it again. I’ll leave this open for the multi-line problem.