npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ts-remove-any

v0.2.5

Published

`ts-remove-any` will replace automatically some implicit (and explicit) `any`s with a compatible type.

Downloads

144

Readme

ts-remove-any

ts-remove-any will replace automatically some implicit (and explicit) anys with a compatible type.

Motivation

If you have an existing TypeScript project, you may want to turn noImplicitAny on, as it really helps to find errors at build time instead of waiting for the program to crash.

But if your project was not started with this option activated, you may be discouraged by the number of errors appearing when turning it on.

If that's the case, ts-remove-any is here for you: it will rewrite part of your code, replacing implicit anys by a (probably) compatible type.

This project is conservative in the sense that it tries to minimize the number of fixes you have to do afterward. It means that it won't fix all your implicit anys, only those with a good chance to not be wrong. But even like this, there may still be some errors; it's to be expected, as any is an escape hatch usually used to prevent TypeScript to check properly the code.

This project cannot completely eliminate the need for manual code fixes, but it can assist in this task.

Usage

Run the following command at the root folder of your project:

npx ts-remove-any

Don't forget to run your formatter (eg. prettier) and typechecker (eg. tsc) afterward, ts-remove-any may reformat your code, and leave some type errors.

The execution can be quite slow; if you wan to monitor the advancement of the execution, add the verbose flag.

npx ts-remove-any -v

More options are available, and can be found from the cli help.

| Option | Effect | |--------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | -v | increase the verbosity, ie. the amount of logs displayed. Can be double to see even more logs: -v -v | | -p | the path of tsconfig.json file to use | | -f | a pattern against which the file name and path will be matched. Useful if you want to run ts-remove-any only on one file, or group of files | | -r | don't revert the code in case of errors. ts-remove-any may generate invalid types, this option will ensure that we keep those types. They may be used as a basis for a manual fix | | -d | dry-run, don't apply any change, but display a log of the changes that would be made | | -e | also replace the explicit anys | | --help | display a contextual help |

You may have to increase the memory available to node, as this project uses a lot of memory. It can done with the following command:

NODE_OPTIONS=--max-old-space-size=8192 npx ts-remove-any

It could be useful to run the script multiple times, until the number of changes done are 0: each time ts-remove-any removes some anys, new types are available to analysis and remove other anys.

This is not done automatically as you may want to check intermediate results between run, to ensure types generated are valid.

Release procedure

./script/release.sh