4 ms·
To be honest I think it's a big mistake on the part of typescript to not have a JSON.parse<T>.
by eterm 7y ago
To be honest I think it's a big mistake on the part of typescript to not have a JSON.parse<T>.
- matt_kantor 7y agoThat would just obscure the lie. I'd rather see an explicit `as T` cast at the call site to make the "trust me, typechecker, I know what shape this is" claim be in-your-face instead of hidden behind a type parameter. (This reply assumes you're not asking for TypeScript to make a major philosophical shift and start generating runtime code to validate types. If you are, that's a discussion worth having but goes way deeper than `JSON.parse`.)