Warning
After a log of discussion and feedback, the proposal was renamed from Safe Assignment Operator
to Try Expressions
.
This proposal intends to address a surging issue regarding the uncommon ergonomics of maintaining subsequent (and possible nested) try/catch
blocks required to correctly execute operations that might fail at any point.
Only the catch (error) {}
part is the actual control flow and no program state requires to be within a try {}
block. Forcing the successful flow to be inside a nested block is not ideal.
- Why Not
data
First? - Polyfilling
- Using
?=
with Functions and Objects WithoutSymbol.result
- Comparison
- Similar Prior Art
- What This Proposal Does Not Aim to Solve
- Current Limitations
- Help Us Improve This Proposal
- Authors
- Inspiration
- License
This proposal is in its early stages, and we welcome your input to help refine it. Please feel free to open an issue or submit a pull request with your suggestions.
Any contribution is welcome!
- This tweet from @LeaVerou
- The frequent oversight of error handling in JavaScript code.
- Effect TS Error Management
- The
tuple-it
npm package, which introduces a similar concept but modifies thePromise
andFunction
prototypes—an approach that is less ideal.
This proposal is licensed under the MIT License.