Comment by mpoteat
2 hours ago
Actually, it's even simpler: you should just be able to use signature overloading:
myFunc(x: true): number
myFunc(x: false): string
The article's assertion that TypeScript can't represent this is quite false.
2 hours ago
Actually, it's even simpler: you should just be able to use signature overloading:
myFunc(x: true): number
myFunc(x: false): string
The article's assertion that TypeScript can't represent this is quite false.
No comments yet
Contribute on Hacker News ↗