TypeScript is not useful with fallback #15184
-
I believe Svelte transpiles the TypeScript code on the fly by Consider the below example with TypeScript and user doesn't provide the property which is required:
The core idea of TypeScript is static type checking—catching errors before runtime. Imagine if:
The result is actually more or less the same without TypeScript. Unless I explicitly make a fallback for the required property:
But then again, why still need TypeScript in this case since already provided fallback. The difference is that we need to manually compile the TypeScript and it will fails for the above case for regular TypeScript application. But with Svelte and other frameworks, this is not the case. My question is:
This might not a question directly related to Svelte but I'd like to know the thoughts of the developers from the ecosystem of Svelte and other professionals. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
My personal view on this is that if people don't use something correctly while having all the tools to do otherwise, that is their problem. The types, My one criticism towards Svelte would be that type checking does not happen by default and you need to separately run |
Beta Was this translation helpful? Give feedback.
My personal view on this is that if people don't use something correctly while having all the tools to do otherwise, that is their problem.
The types,
svelte-check
and the extensions are there to help them prevent mistakes, if people choose to not make use of those and run into trouble because of it, that is simply the consequence of their own actions.My one criticism towards Svelte would be that type checking does not happen by default and you need to separately run
svelte-check
. I think ideally that would be integrated directly into the compilation step.