12 ms·
- Full-fledged support for pattern-matching exhaustiveness check, not something you have to bake together using a 'tag' field. This means if you match on i.e. i
by yawaramin 6y ago
- Full-fledged support for pattern-matching exhaustiveness check, not something you have to bake together using a 'tag' field. This means if you match on i.e. integers, the compiler will warn you if you don't include a catch-all default case.
- Simple module system where you don't need to deal with named vs default imports and all the weird bugs getting them mixed up can bring
- TypeScript's inherent JS-like nature can pop up subtle bugs like forgetting to type a pair of parentheses:
function isSupported(): boolean {
return false;
}
function test() {
console.log(true && isSupported); // true
}
Or doing object/array indexing and forgetting to handle the case of 'undefined' because TypeScript doesn't enforce that. Or how any typings from before version 2 are suspect because they were written with the assumption that every type can be implicitly nullable. There are lots of these little footguns all over the place.
- Higher-quality bindings: more stuff captured at the type level, you're not left to deal with bindings full of 'any', 'object', and 'function'
It's not even just about safety though. One of the biggest productivity drivers in Reason is its iteration speed–the compiler is so fast that you can try out changes basically as fast as you can save the file. And there are other things, like how all modules are implicitly available in scope, so you don't need to manage a 'wall of imports' at the top of every file before you can actually get to the code itself.
- Kaze404 6y ago> TypeScript's inherent JS-like nature can pop up subtle bugs like forgetting to type a pair of parentheses FWIW this was just fixed in TypeScript 3.9.
- yawaramin 6y agoInteresting, can you link me? EDIT: I just tried in the TypeScript Playground (v3.9.2), it's actually rather worse than I thought, it prints not 'false' but the actual function itself as a value...
- jordwalke 6y ago- It's Just JavaScript With Types - It's Usable - It Has Full Type Safety Pick two. I think the TypeScript is aware of the tradeoffs, have chosen the first two, and the result is a great developer/IDE experience for JavaScript programs (props!). Reason chooses the last two and creates a great experience for writing very safe web apps.
- Kaze404 6y agohttps://devblogs.microsoft.com/typescript/announcing-typescript-3-9/#uncalled-in-conditionals https://devblogs.microsoft.com/typescript/announcing-typescr... Edit: Apparently the functionality already exists as of 3.7. The update in 3.9 was to add it to ternary operations as well
- yawaramin 6y agoGreat. But looks like it doesn't work inside a boolean expression.