All Projects → allegro → typescript-strict-plugin

allegro / typescript-strict-plugin

Licence: MIT license
Typescript plugin that allows turning on strict mode in specific files or directories.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to typescript-strict-plugin

monoreact
📦 React workspaces implementation
Stars: ✭ 13 (-92.17%)
Mutual labels:  typescript-library
Gojs
JavaScript diagramming library for interactive flowcharts, org charts, design tools, planning tools, visual languages.
Stars: ✭ 5,739 (+3357.23%)
Mutual labels:  typescript-library
fnts
λ Minimal Functional Programming Utilities for TypeScript & JavaScript
Stars: ✭ 75 (-54.82%)
Mutual labels:  typescript-library
react-native-navigation-drawer-extension
Drawer API built on top of wix react-native-navigation for iOS and Android (with TypeScript!)
Stars: ✭ 151 (-9.04%)
Mutual labels:  typescript-library
tall
Promise-based, No-dependency URL unshortner (expander) module for Node.js
Stars: ✭ 56 (-66.27%)
Mutual labels:  typescript-library
Ts Toolbelt
ts-toolbelt is the largest, and most tested type library available right now, featuring +200 utilities. Our type collection packages some of the most advanced mapped types, conditional types, and recursive types on the market.
Stars: ✭ 3,099 (+1766.87%)
Mutual labels:  typescript-library
avro-typescript
TypeScript Code Generator for Apache Avro Schema Types
Stars: ✭ 19 (-88.55%)
Mutual labels:  typescript-library
imtool
🖼️ Client-side canvas-based image manipulation library.
Stars: ✭ 38 (-77.11%)
Mutual labels:  typescript-library
React Flow
Highly customizable library for building interactive node-based UIs, editors, flow charts and diagrams
Stars: ✭ 8,348 (+4928.92%)
Mutual labels:  typescript-library
tiny-typed-emitter
Fully type-checked NodeJS EventEmitter
Stars: ✭ 96 (-42.17%)
Mutual labels:  typescript-library
ng2-rest
Isomorphic, simple, robust REST API library for Browser and NodeJS, ( ts / js ) apps
Stars: ✭ 26 (-84.34%)
Mutual labels:  typescript-library
validate-polish
Utility library for validation of PESEL, NIP, REGON, identity card etc. Aimed mostly at Polish enviroment. [Polish] Walidacja numerów pesel, nip, regon, dowodu osobistego.
Stars: ✭ 31 (-81.33%)
Mutual labels:  typescript-library
ifto
A simple debugging module for AWS Lambda (λ) timeout
Stars: ✭ 72 (-56.63%)
Mutual labels:  typescript-library
deno-aws api
From-scratch Typescript client for accessing AWS APIs
Stars: ✭ 33 (-80.12%)
Mutual labels:  typescript-library
necktie
Necktie – a simple DOM binding tool
Stars: ✭ 43 (-74.1%)
Mutual labels:  typescript-library
KosherZmanim
Port of the KosherJava zmanim library to TypeScript
Stars: ✭ 29 (-82.53%)
Mutual labels:  typescript-library
Useworker
⚛️ useWorker() - A React Hook for Blocking-Free Background Tasks
Stars: ✭ 2,233 (+1245.18%)
Mutual labels:  typescript-library
Strict-DataBinding
善用 DataBinding 彻底解决 “View 实例的 Null 安全一致性问题”
Stars: ✭ 84 (-49.4%)
Mutual labels:  strict-mode
alls
Just another library with the sole purpose of waiting till all promises to complete. Nothing more, Nothing less.
Stars: ✭ 13 (-92.17%)
Mutual labels:  typescript-library
microbundle-ts-pkg
A TypeScript npm package skeleton/starter project with microbundle, node:test and prettier
Stars: ✭ 20 (-87.95%)
Mutual labels:  typescript-library

Typescript strict mode plugin

Typescript plugin that allows turning on strict mode in specific files or directories.

Do I need this plugin?

typescript-strict-plugin was created mainly for existing projects that want to incorporate typescript strict mode, but project is so big that refactoring everything would take ages.

Our plugin allows adding strict mode to a TypeScript project without fixing all the errors at once. By adding //@ts-strict-ignore comment at the top of a file, its whole content will be removed from strict type checking. To ease migrating a project to use this plugin, you can use update-strict-comments script, which adds the ignore comment to all files that contain at least one strict error.

TypeScript plugins don't work at compile-time. They will show errors in your IDE, but they won't appear during compilation. To check strict errors in marked files you can use tsc-strict script. This command line tool is created to check for files that should be checked with strict rules in compilation time. It finds all relevant files and checks for strict typescript errors only for that files. Therefore, we have strict errors inside our files and during build time.

How to install

Use npm:

npm i --save-dev typescript-strict-plugin

or yarn

yarn add -D typescript-strict-plugin

add plugin to your tsconfig.json:

{
 "compilerOptions": {
   ...
   "strict": false,
   "plugins": [
    {
     "name": "typescript-strict-plugin"
    }
   ]
 }
}

and run the migration script

./node_modules/.bin/update-strict-comments

That's it! You should be able to see strict typechecking in files without the @ts-strict-ignore comment. To make these files strict too, just remove its' ignore comments.

Configuration

Plugin takes one extra non-mandatory argument paths that is an array of relative or absolute paths of directories that should be included. To add strict mode to files from ignored paths you can insert //@ts-strict comment.

{
  "compilerOptions": {
    ...
    "strict": false,
    "plugins": [
      {
        "name": "typescript-strict-plugin",
        "paths": [
          "./src",
          "/absolute/path/to/source/"
        ]
      }
    ]
  }
}

All files contained in those paths will be strictly checked. Yay!

To add cli tool to your build time you can add a script to scripts list in package.json

{
  "scripts": {
    ...,
    "typecheck": "tsc && tsc-strict",
  },
}

Then you can simply run

yarn tsc-strict

All your strict files should be checked from command line.

You can also pass some tsc arguments to the tsc-strict to override default compiler options e.g.

yarn tsc-strict --strictNullChecks false

would not check for the strict null check in your files. The tsc-strict accepts all the arguments that regular tsc command accepts.

Migrating to v2

Because of difficulties with migrating large projects to strict mode with original //@ts-strict comment, we've taken an another approach. Now in version 2.0+ typescript files are strict by default, and to ignore a file, you can use special //@ts-strict-ignore comment. It allows to have strict mode in newly created files without remembering about adding strict comment at the top of it. Version 2.0 comes with a new script update-strict-comments, which detects all files with at least one strict error and adds the ignore comment to ease the migration. To update from v1 to v2, you just need to run:

update-strict-comments

VSCode support

VSCode supports this plugin out of the box. However, sometimes it can use its own typescript version instead of the project one, resulting in not reading the local tsconfig. If you are using VSCode be sure to have Use workspace version option selected in Typescript: Select Typescript Version... command available in the command pallete.

image

Testing the plugin

Manually

run

npm i

inside root folder and sample-project folder and then run

npm run build

or

npm run dev

and restart typescript service inside sample-project. Files in sample-project folder should use a local plugin. After you made changes to a plugin you should probably restart typescript service in order to reload the plugin.

Tests

In order to run tests run

npm run test

Contributing

Feel free to create PR's and issues.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].