Answer the question
In order to leave comments, you need to log in
What front-end framework works best with typescript in templates?
Pseudocode:
<template>
<for image in imageList> // Type error: imageList can be null;
<img src="image.url" height="image.height">
</for>
</template>
<core>
class ImageList {
imageList: null | Image[],
}
</core>
Type Error: imageList can be null;
Answer the question
In order to leave comments, you need to log in
React and its peers do best, as tsx is part of typescript itself.
In second place is Angular, which has its own template validator that calls typescript for type information. There are truths and peculiarities , but with strict settings it checks very well.
In third place is Svelte, everything works here through compiling the component into tsx, which is already checked by typescript. The trouble here is that Svelte itself is a compiler that waits for html and js as input, and not anything else, so when building a project, typechecking requires a separate step, which is usually skipped so as not to slow down the build. In fact, there is enough typescript work in the IDE + CLI utilities for type checking.
Also, the typescript preprocessor for svelte has jambs with the removal of type imports, since this feature can be disabled and shifted to typescript itself using the import type statement. For the same reason, the const enum import does not work (with the usual enum, which leave artifacts in js, everything is ok).
In general, svelte works very well with typescript.
Ember and Vue don't have type checking in their templates. True, for vue, this particular example will not be a problem, since it does a runtime check for null and undefined in v-for.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question