Hacker News new | past | comments | ask | show | jobs | submit login

During development it would be helpful to have type checking enabled at runtime behind some flag or configuration. I want code to fail fast and early in my development environment. In production the code will be stripped and minified.

I read the FAQ in the proposal but don't understand the challenges in adding type introspection at runtime. It seems weird to add all this syntax and not have any way to leverage it during runtime. Although maybe it wouldn't be that useful? Still making up my mind about this.

Glad to see that these questions are at least being considered and explored as part of the proposal.

Great job from everyone involved, this proposal shows a lot of promise and it makes me excited for the future of JS.




> It seems weird to add all this syntax and not have any way to leverage it during runtime.

Just because they're not leveraging them today, it doesn't mean that they won't do it tomorrow. If a proposal requires a big effort to implement it, it will probably never become adopted.


I think it means exactly that. If JS will get type hints that are not checked at runtime then we will never get runtime validation for these type hints since it will break a lot of existing code that has would have "wrong" type hints.


Maybe a special string flag like “use strict” — “use types”?


I personally do not want to give developers the option to make type errors a user problem.


Type errors are a user problem already, if they make their way into production.


Not necessarily — maybe the error is an incorrect argument to a function that’s never used, for example.

The issue is, what should the browser do if it encounters a type error? Should it just refuse to interpret the entire script? That’s super heavy-handed when it’s possible that the error doesn’t even matter in practice.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: