Improve pattern matching by inferring results of operations #50112
Labels
Suggestion
An idea for TypeScript
Too Complex
An issue which adding support for may be too complex for the value it adds
Suggestion
It would be amazing for the compiler to be able to infer the result of expressions e.g.:
🔍 Search Terms
pattern matching, infer result
✅ Viability Checklist
My suggestion meets these guidelines:
⭐ Suggestion
It would be great for tsc to be able to infer the result of primitive operations and cast them to a const e.g.:
📃 Motivating Example
Why?
To unleash us to do something like:
or
Why would this be important?
IMO such a powerful compiler could greatly help the developer experience and the reduce the number of bugs.
I'm a TDD practitioner and I greatly enjoy the feedback loop provided by this practice, but static compiler issues are by far most the best feedback we can get.
I'm quite convinced that introducing this behaviour would make us code way faster.
The text was updated successfully, but these errors were encountered: