News for hackers. Stuff that matters.
Re:From TypeScript to ReScript by the_gipsy on Wednesday January 12, 2022 @07:12AM (#29905296)
For what it's worth, Elm does the runtime checks by means of forcing you to write "de/encoders" that must match the types.
Re:From TypeScript to ReScript by smt88 on Wednesday January 12, 2022 @08:36AM (#29906116)
So does TypeScript if you have strict settings. Your input data will be untyped and you will be forced to determine its type before you use it.
Re:From TypeScript to ReScript by the_gipsy on Wednesday January 12, 2022 @04:15PM (#29912767)
TypeScript does nothing like that with any strict settings, because it doesn't provide any JSON parsing alternative, so that is always unsafe.

I bet there are runtime checkers that use some kind of reflection, that would be the next best thing. But I also bet that those force you to annotate/decorate everything.

Re:From TypeScript to ReScript by hermanradtke on Wednesday January 12, 2022 @12:47PM (#29910265)
I do not know of a way to make this a compiler error:

    const user: User = JSON.parse(…);
Re:From TypeScript to ReScript by dhucerbin on Wednesday January 12, 2022 @06:17PM (#29914176)
You can redefine all definitions from lib.d.ts and similar. In my projects, parse function returns unknown, so I need to parse/validate/decode it in runtime to satisfy types.