ts-suppress 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -39
- package/dist/cli.js +3 -2
- package/dist/scope.js +0 -1
- package/dist/test-helpers.js +15 -0
- package/dist/types.js +0 -1
- package/package.json +15 -20
package/README.md
CHANGED
|
@@ -4,67 +4,69 @@ Incremental TypeScript strictness adoption via bulk error suppression.
|
|
|
4
4
|
|
|
5
5
|
Instead of scattering `@ts-ignore` or `@ts-expect-error` comments throughout your codebase, `ts-suppress` captures all TypeScript errors into a single `.ts-suppressions.json` file. This lets you enable stricter compiler options immediately and fix errors at your own pace.
|
|
6
6
|
|
|
7
|
-
## How It Works
|
|
8
|
-
|
|
9
|
-
Each suppression is a fingerprint of a TypeScript error, consisting of:
|
|
10
|
-
|
|
11
|
-
- **file** — relative path to the source file
|
|
12
|
-
- **code** — TypeScript error code (e.g. `2322`)
|
|
13
|
-
- **hash** — hex hash of the diagnostic message text
|
|
14
|
-
- **scope** — dot-separated scope chain (e.g. `MyClass.myMethod`)
|
|
15
|
-
|
|
16
|
-
The `check` command diffs the current diagnostics against the suppression file and reports:
|
|
17
|
-
|
|
18
|
-
- **Unsuppressed errors** — new errors not yet in the suppression file
|
|
19
|
-
- **Stale suppressions** — entries that no longer match any current error (i.e. errors that have been fixed)
|
|
20
|
-
|
|
21
7
|
## Install
|
|
22
8
|
|
|
23
9
|
```bash
|
|
24
|
-
|
|
10
|
+
npm install -D ts-suppress
|
|
25
11
|
```
|
|
26
12
|
|
|
27
|
-
## Usage
|
|
28
|
-
|
|
29
|
-
### `init`
|
|
30
|
-
|
|
31
|
-
Create an empty `.ts-suppressions.json`:
|
|
32
|
-
|
|
33
13
|
```bash
|
|
34
|
-
|
|
14
|
+
pnpm add -D ts-suppress
|
|
35
15
|
```
|
|
36
16
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
17
|
+
```bash
|
|
18
|
+
yarn add -D ts-suppress
|
|
19
|
+
```
|
|
40
20
|
|
|
41
21
|
```bash
|
|
42
|
-
|
|
22
|
+
bun add -d ts-suppress
|
|
43
23
|
```
|
|
44
24
|
|
|
45
|
-
|
|
25
|
+
> **Note:** TypeScript >= 5.9.3 is a peer dependency.
|
|
46
26
|
|
|
47
|
-
|
|
27
|
+
## Usage
|
|
48
28
|
|
|
49
29
|
```bash
|
|
50
|
-
|
|
51
|
-
|
|
30
|
+
# Create an empty .ts-suppressions.json
|
|
31
|
+
npx ts-suppress init
|
|
52
32
|
|
|
53
|
-
|
|
33
|
+
# Snapshot all current TypeScript errors
|
|
34
|
+
npx ts-suppress suppress
|
|
54
35
|
|
|
55
|
-
|
|
36
|
+
# Verify all errors are suppressed and no suppressions are stale (useful in CI)
|
|
37
|
+
npx ts-suppress check
|
|
56
38
|
|
|
57
|
-
|
|
58
|
-
|
|
39
|
+
# Add new suppressions and remove stale ones in a single pass
|
|
40
|
+
npx ts-suppress update
|
|
59
41
|
```
|
|
60
42
|
|
|
61
|
-
Also available as `bunx ts-suppress fix`.
|
|
62
|
-
|
|
63
43
|
## Typical Workflow
|
|
64
44
|
|
|
65
45
|
1. Enable a stricter TypeScript option (e.g. `"strict": true`)
|
|
66
|
-
2. Run `
|
|
46
|
+
2. Run `npx ts-suppress suppress` to baseline all existing errors
|
|
67
47
|
3. Commit `.ts-suppressions.json`
|
|
68
|
-
4. Add `
|
|
48
|
+
4. Add `npx ts-suppress check` to CI
|
|
69
49
|
5. Fix errors over time — `check` will flag stale suppressions as you go
|
|
70
|
-
6. Run `
|
|
50
|
+
6. Run `npx ts-suppress update` to sync the suppression file after fixing errors
|
|
51
|
+
|
|
52
|
+
## How It Works
|
|
53
|
+
|
|
54
|
+
Each suppression is a fingerprint of a TypeScript error, consisting of:
|
|
55
|
+
|
|
56
|
+
- **file** — relative path to the source file
|
|
57
|
+
- **code** — TypeScript error code (e.g. `2322`)
|
|
58
|
+
- **hash** — hex hash of the diagnostic message text
|
|
59
|
+
- **scope** — dot-separated scope chain (e.g. `MyClass.myMethod`)
|
|
60
|
+
|
|
61
|
+
The `check` command diffs the current diagnostics against the suppression file and reports:
|
|
62
|
+
|
|
63
|
+
- **Unsuppressed errors** — new errors not yet in the suppression file
|
|
64
|
+
- **Stale suppressions** — entries that no longer match any current error (i.e. errors that have been fixed)
|
|
65
|
+
|
|
66
|
+
## Acknowledgements
|
|
67
|
+
|
|
68
|
+
Inspired by ideas from [ts-bulk-suppress](https://github.com/tiktok/ts-bulk-suppress) by TikTok, specifically the approach of capturing TypeScript errors into an external suppression file rather than using inline ignore comments.
|
|
69
|
+
|
|
70
|
+
## License
|
|
71
|
+
|
|
72
|
+
MIT
|
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import mri from "mri";
|
|
2
3
|
import { createProject } from "./project.js";
|
|
3
4
|
import { runCheck } from "./commands/check.js";
|
|
4
5
|
import { runInit } from "./commands/init.js";
|
|
@@ -16,7 +17,7 @@ function printHelp() {
|
|
|
16
17
|
const lines = commands.map(([name, desc]) => ` ${name.padEnd(longest + 4)}${desc}`);
|
|
17
18
|
console.log(`ts-suppress v${VERSION}\nIncremental TypeScript strictness adoption via bulk error suppression\n\nCommands:\n${lines.join("\n")}\n\nRun ts-suppress <command> --help for details.`);
|
|
18
19
|
}
|
|
19
|
-
const args =
|
|
20
|
+
const args = mri(process.argv.slice(2), {
|
|
20
21
|
boolean: ["help", "version"],
|
|
21
22
|
alias: { h: "help", v: "version" },
|
|
22
23
|
});
|
package/dist/scope.js
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Project, ScriptTarget } from "ts-morph";
|
|
2
|
+
export function createInMemoryProject(files) {
|
|
3
|
+
const project = new Project({
|
|
4
|
+
useInMemoryFileSystem: true,
|
|
5
|
+
compilerOptions: {
|
|
6
|
+
strict: true,
|
|
7
|
+
target: ScriptTarget.ESNext,
|
|
8
|
+
lib: ["lib.esnext.full.d.ts"],
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
for (const [name, content] of Object.entries(files)) {
|
|
12
|
+
project.createSourceFile(name, content);
|
|
13
|
+
}
|
|
14
|
+
return project;
|
|
15
|
+
}
|
package/dist/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-suppress",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Incremental TypeScript strictness adoption via bulk error suppression",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"migration",
|
|
@@ -31,24 +31,11 @@
|
|
|
31
31
|
"!skills/_artifacts"
|
|
32
32
|
],
|
|
33
33
|
"type": "module",
|
|
34
|
-
"scripts": {
|
|
35
|
-
"build": "tsc -p tsconfig.build.json",
|
|
36
|
-
"test": "bun test",
|
|
37
|
-
"prepublishOnly": "bun run build",
|
|
38
|
-
"fmt": "oxfmt",
|
|
39
|
-
"fmt:check": "oxfmt --check",
|
|
40
|
-
"knip": "knip",
|
|
41
|
-
"lint": "oxlint",
|
|
42
|
-
"lint:fix": "oxlint --fix",
|
|
43
|
-
"prepare": "husky",
|
|
44
|
-
"typecheck": "tsc --noEmit"
|
|
45
|
-
},
|
|
46
34
|
"dependencies": {
|
|
47
|
-
"
|
|
35
|
+
"mri": "^1.2.0",
|
|
48
36
|
"ts-morph": "^27.0.2"
|
|
49
37
|
},
|
|
50
38
|
"devDependencies": {
|
|
51
|
-
"@types/bun": "latest",
|
|
52
39
|
"@types/node": "^24",
|
|
53
40
|
"husky": "^9.1.7",
|
|
54
41
|
"knip": "^5.87.0",
|
|
@@ -56,13 +43,21 @@
|
|
|
56
43
|
"oxfmt": "^0.41.0",
|
|
57
44
|
"oxlint": "^1.56.0",
|
|
58
45
|
"oxlint-tsgolint": "^0.17.0",
|
|
59
|
-
"
|
|
46
|
+
"tsx": "^4.19.4",
|
|
47
|
+
"typescript": "^5.9.3",
|
|
48
|
+
"vitest": "^3.2.1"
|
|
60
49
|
},
|
|
61
50
|
"peerDependencies": {
|
|
62
51
|
"typescript": "^5.9.3"
|
|
63
52
|
},
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "tsc -p tsconfig.build.json",
|
|
55
|
+
"test": "vitest run",
|
|
56
|
+
"fmt": "oxfmt",
|
|
57
|
+
"fmt:check": "oxfmt --check",
|
|
58
|
+
"knip": "knip",
|
|
59
|
+
"lint": "oxlint",
|
|
60
|
+
"lint:fix": "oxlint --fix",
|
|
61
|
+
"typecheck": "tsc --noEmit"
|
|
67
62
|
}
|
|
68
|
-
}
|
|
63
|
+
}
|