Replace Throw Statements with Direct Function Calls
This codemod simplifies error handling and redirects in your TypeScript project by replacing throw error() and throw redirect() statements with direct calls to error() and redirect(). This change aligns with modern practices and results in cleaner, more readable code.
Transformations
This codemod performs the following transformations:
- Error Handling: Transforms throw error(status, message) into error(status, message).
- Redirects: Transforms throw redirect(status, url) into redirect(status, url).
Usage
To apply this codemod, run the workflow script on your TypeScript files. Ensure you have the necessary dependencies installed and your project is configured to use this codemod.
Example
Before
typescript
After
typescript
License
MIT License