I run into `throw undefined;` surprisingly often and it is so so difficult to debug (doing it right now). It's one of the most easiest things a type system could detect.
-
-
Show this threadThanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Those would be nice features. I think the reason why we don't seem them in TS is because they are valid JS. You can throw whatever you want and you can interpolate whatever you want (for example, you might implement your own toString() method).
-
TypeScript and Flow both regularly restrict JavaScript semantics for better type safety. Throwing a primitive is always an anti-pattern and you can wrap interpolated values in String() if you want the coercion semantics.
- 3 more replies
New conversation -
-
-
I wonder if those could be lint rules (separate from TypeScript).
-
Why should they be?
- 3 more replies
New conversation -
-
-
But React suspense throw non Errors
- 1 more reply
New conversation -
-
-
First might be possible if never was made generic such never<Error>. Second is kind of possible with tagged template literals
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Not a great solution, but you could have a custom tag function that only accepts string interpolations and replicates the untagged template functionality.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
It would also be a great job for eslint, or? Then it’s optional and works also in JS.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
he/him 