add-return-type
v0.4.3
Published
Codemod to add the return type to functions and class methods
Maintainers
Readme
add-return-type
Codemod to add the return type to functions and class methods
Usage
Step 1. Run codemod.
cd <path/to/your/project>
pnpx add-return-type <arguments>Step 2. Fix formatting.
# Run prettier
pnpm prettier . --writeArguments
Pass --root to run the codemod somewhere else (i.e. not in the current directory).
pnpx add-return-type --root <path/to/your/project>By default, the codemod only considers functions and class methods that have the lint error of @typescript-eslint/explicit-function-return-type.
To consider all functions and class methods, pass --search-method all.
pnpx add-return-type --search-method allLimitations
The codemod is designed to cover typical cases. It is not designed to cover one-off cases.
To better meet your needs, consider cloning the repo and running the codemod locally.
cd <path/to/cloned/repo>
# Compile TypeScript
pnpm build
# Run codemod
./dist/bin/add-return-type.js --root <path/to/your/project>Compatibility
- Node.js v22 or above
Contributing
See the Contributing guide for details.
License
This project is licensed under the MIT License.
