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-incremental-strict-mode

v0.5.2

Published

Type check specified files/folders with strict mode

Downloads

22

Readme

ts-incremental-strict-mode

Enable TypeScript strict mode in your project incrementally!

codecov Code Climate maintainability npm

Enabling TypeScript strict mode in a project where it has not been enforced can be a painful task.

With ts-incremental-strict-mode you can incrementally type check your project files with strict mode enabled, or enforce strict mode only on specific folders.

Installation

ts-incremental-strict-mode supports at least Node 8 and above.

npm

npm install ts-incremental-strict-mode --save-dev

yarn

yarn add ts-incremental-strict-mode --dev

Usage

If you are using npm, you can replace yarn with npx.

Basic usage

yarn ts-incremental-strict-mode <file paths>
yarn ts-incremental-strict-mode --help

With lint-staged

"lint-staged": {
    "*{ts,tsx}": ["ts-incremental-strict-mode"]
}

Glob patterns

ts-incremental-strict-mode supports same glob syntax as the include and exclude fields in tsconfig.

Type check all files within src folder and it's subfolders

yarn ts-incremental-strict-mode 'src'

You can exclude folders with a negation pattern

yarn ts-incremental-strict-mode 'src' '!**/__tests__'

Disable checks

ts-incremental-strict-mode supports all the strict mode options that the TypeScript compiler provides.

This mean it's possible to disable some of the checks if wanted.

yarn ts-incremental-strict-mode --strictNullChecks false --noImplicitAny false <file paths>

For a full list see options

Custom tsconfig path

By default, ts-incremental-strict-mode will try to resolve a config file in the path that it is ran from. If it can't find a tsconfig.json, it will look in a directory above until it finds it.

If you have a tsconfig with a special name or you need to specify a configuration for some other reason, you can pass the config file path via the --config flag.

yarn ts-incremental-strict-mode --config <path to custom tsconfig> <file paths>

Options

| Option | Type | Description | | ---------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | noImplicitAny | boolean | Raise error on expressions and declarations with an implied any type. Default value true | | noImplicitThis | boolean | Raise error on this expressions with an implied any type. Default value true | | alwaysStrict | boolean | Parse in strict mode and emit "use strict" for each source file. Default value true | | strictBindCallApply | boolean | Enable stricter checking of the bind, call, and apply methods on functions. Default value true | | strictNullChecks | boolean | In strict null checking mode, the null and undefined values are not in the domain of every type and are only assignable to themselves and any (the one exception being that undefined is also assignable to void). Default value true | | strictFunctionTypes | boolean | Disable bivariant parameter checking for function types. Default value true | | strictPropertyInitialization | boolean | Ensure non-undefined class properties are initialized in the constructor. This option requires --strictNullChecks be enabled in order to take effect. Default value true | | config | filepath | Path to your tsconfig file. If not specified, ts-incremental-strict-mode will try to resolve a tsconfig.json file in the directory you run ts-incremental-strict-mode. If not found it will move to the directory above until it finds a tsconfig. | | verbose | boolean | Output the files to be type checked in to console. Useful for testing glob patterns. Default value false |

Troubleshooting

I'm getting an error about missing types

ts-incremental-strict-mode works by creating a temporary tsconfig, and uses the files you specified in the files property. If you have defined types, you need to add them to your tsconfig or include them in your command.

For example with create-react-app, you would run

yarn ts-incremental-strict-mode src/index.tsx src/react-app-env.d.ts

Development setup

Getting started with development of ts-incremental-strict-mode is quite straightforward.

git clone https://github.com/rikumantysalo/ts-incremental-strict-mode.git
cd ts-incremental-strict-mode
yarn

To run tests (these will be ran automatically when you push to a remote!)

yarn test