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

> Having to write two type definitions for Component Props: one TS interface/type, and one as the JS object sucks.

Uh, you don't have to? TS inference works with the JS objects. There's no need to provide the generic argument here.

Also check out this: https://github.com/vuejs/rfcs/blob/sfc-improvements/active-r... (auto-generating runtime types from TS interface)



Holy shit, Evan You replied to my comment.

Happy Vue user since 2016.

> TS inference works with the JS objects. There's no need to provide the generic argument here.

That's totally valid -- I am just being nitpicky and complaining because if possible I'd prefer to do it the other way: TS type -> JS object

> auto-generating runtime types from TS interface

Whoa. Well, that solves that then.


I just looked at the sample code you provided. Having no experience with Vue (only React and Angular), but heavy TS user, something came to my eye:

Is it correct that `declare const props` will not only get used to type-check stuff but also emit code based on that?

I think thats unintuitive. TS basically means "take away all the static types and you get what the compiler emits". A lot of developers won't be able to distinguish between TS and the magic that some framework does. I've made similar observations when working with Angular devs.

Correct my if I've mistaken something. /2c




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

Search: