add-function-return-types
v3.4.1
Published
A CLI tool to add explicit return types to TypeScript functions
Downloads
1,202
Maintainers
Readme
add-function-return-types
A CLI tool to add explicit return types to TypeScript functions.
Usage
Install the tool globally using npm:
npm install -g add-function-return-types
add-function-return-types [options]
Or use it directly with npx:
npx add-function-return-types [options]
By default, the tool:
- Uses the current working directory as the root path.
- Processes all .ts and .tsx files in the current directory recursively.
- Ignores node_modules and .d.ts files.
- Saves the files with updated return types.
Options
Base options
--shallow
: Only process current directory.--overwrite
: Overwrite functions with existing return types.
Ignore
--ignore-files <patterns>
: Comma-separated list of file glob patterns to ignore.--ignore-functions <names>
: Comma-separated list of function or method names to ignore during processing.--ignore-any
: Ignore functions that return the any type.--ignore-unknown
: Ignore functions that return the unknown type.--ignore-anonymous-objects
: Ignore functions that return anonymous object types.--ignore-anonymous-functions
: Ignore anonymous functions (functions without names).--ignore-expressions
: Ignore function expressions (functions that are not part of a declaration).--ignore-functions-without-type-parameters
: Ignore functions that don't have generic type parameters.--ignore-higher-order-functions
: Ignore functions that immediately return another function expression.--ignore-typed-function-expressions
: Ignore function expressions that already have type annotations on the variable.--ignore-iifes
: Ignore immediately-invoked function expressions.--ignore-concise-arrow-function-expressions-starting-with-void
: Ignore arrow functions that start with the void keyword.
Example
add-function-return-types --ignore-files "src/generated/**,tests/**" --ignore-functions "map,filter"
Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request on GitHub.
License
This project is licensed under the MIT License.