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

friendly tips: runtime type checks are available https://github.com/gcanti/io-ts https://github.com/pelotom/runtypes


Why would you want runtime checks over static checks? The one thing I can think of is type asserting input from other js code, but surely you just want that on the entry function to your code, not in the internal bits.


TS compiled can still be faulty if the app is injected with data of different type

Runtime type checks is the lost link between static checks at compile time and arbitrary i/o data type in compiled js code.

You define a type in a similar way you would define TS types. At compile time it would give you the typescript type checks. At runtime it will help you determine if data has the correct type exactly as your typescript app expected.

There is extra work though, handling error if there is a faulty data type


Runtime type checking is necessary to ensure data received from untrustworthy sources matches compiletime types.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: