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

Consider it in the context of a framework like React. The type of setState() is defined as Partial<State>. The framework cannot just copy paste the type definition with properties set to optional, since the state type is defined by the user and specific for each component. Without type helpers there would be no way for a framework to define the type for setState().

I'm not sure how often you would need type helpers in application code, for frameworks and libraries they are a godsend.

Your argument is a bit like saying we don't need parameterized types like Array<T> because you can just copy paste the code for each type.



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

Search: