Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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?


There 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, 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.


You can use JSX instead of string templates. This way you can get type safety.


Do you know of any examples of this?


JSX is in the docs: 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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: