3 ms·
I think it's a lot harder to get past TypeScript's type checker. It's probably possible, but I can't think of a way to do it off the top of my head without cas
by recursive 10y ago
I think it's a lot harder to get past TypeScript's type checker. It's probably possible, but I can't think of a way to do it off the top of my head without casting to any. It's a lot easier to show correctly executing javascript programs that would be rejected by the type checker.
- evmar 10y agoHere's one that TypeScript gets wrong. It's kind of a canonical example of a program that is difficult to get right in a type system. (It's how I found the Flow example linked upthread.) let x: number[] = []; let y: Object[] = x; y.push('a'); let bad = x.pop(); // bad has type number but is actually a string.