5 ms·
How much type safety do you get using Vue with TypeScript compared to Angular 2 or React? For example, if you use a variable with the wrong name or wrong type i
by seanwilson 10y ago
How much type safety do you get using Vue with TypeScript compared to Angular 2 or React? For example, if you use a variable with the wrong name or wrong type in a template, can you set Vue up to give you a compile time error?
- alevans4 10y agoThere is no way to get typing in the template currently that I am aware of. There are various libraries that help with Typescript integration like https://github.com/itsFrank/vue-typescript https://github.com/itsFrank/vue-typescript, but you cannot currently write Typescript as the language in a single page component (again that I am aware of). I'm definitely hoping this is coming this year.
- nmerouze 10y agoYou can use JSX instead of string templates. This way you can get type safety.
- seanwilson 10y agoDo you know of any examples of this?
- nmerouze 10y agoJSX is in the docs: https://vuejs.org/v2/guide/render-function.html#JSX https://vuejs.org/v2/guide/render-function.html#JSX I don't have any concrete example of Vue.js + JSX + TypeScript but I know it's a bit tricky, see this thread: https://forum.vuejs.org/t/vue-2-0-and-tsx/308/8 https://forum.vuejs.org/t/vue-2-0-and-tsx/308/8