You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Take following code:
let count = 5;
let doubled: number;
$: doubled = count * 2;
It's unnecessarily verbose, the TS could infer the type for us if the preprocessor could turn this in to a appropriate TS.
If you leave the let doubled: number; out it says it's any and with TS that is not wanted.
Describe the solution you'd like
Ideal would be to infer the type correctly so it could be written just:
let count = 5;
$: doubled = count * 2;
// TypeScript type-checker could be made to see this code as:
let doubled = count * 2;
// so that type inference would work correclty.
In a case where even TypeScript can't infer, then it would be second most natural to use this format:
let count = 5;
$: doubled: number = count * 2;
In a way for TypeScript the $: appears as let
It was mentioned in here: sveltejs/svelte#4518 that preprocessor does the conversion first to typescript. Would it be possible to do something so that type could be inferred?
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Take following code:
It's unnecessarily verbose, the TS could infer the type for us if the preprocessor could turn this in to a appropriate TS.
If you leave the
let doubled: number;
out it says it'sany
and with TS that is not wanted.Describe the solution you'd like
Ideal would be to infer the type correctly so it could be written just:
In a case where even TypeScript can't infer, then it would be second most natural to use this format:
In a way for TypeScript the
$:
appears aslet
It was mentioned in here: sveltejs/svelte#4518 that preprocessor does the conversion first to typescript. Would it be possible to do something so that type could be inferred?
The text was updated successfully, but these errors were encountered: