Skip to content

Commit 8634168

Browse files
authored
docs(linter): add troubleshooting section for type-aware linting (#708)
Add documentation for debugging unexpected errors and slow performance when using type-aware linting, including example debug log output and interpretation guidance.
1 parent 1fec47b commit 8634168

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

src/docs/guide/usage/linter/type-aware.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,62 @@ List of supported rules:
8383
- [typescript/unbound-method](/docs/guide/usage/linter/rules/typescript/unbound-method)
8484
- [typescript/use-unknown-in-catch-callback-variable](/docs/guide/usage/linter/rules/typescript/use-unknown-in-catch-callback-variable)
8585

86+
## Troubleshooting
87+
88+
### Debugging Unexpected Errors
89+
90+
If you encounter unexpected errors or rules not triggering when expected, types may not be resolving correctly. Run with `--type-check` to verify that all imports are being resolved:
91+
92+
```bash
93+
oxlint --type-aware --type-check
94+
```
95+
96+
This will report TypeScript errors alongside lint diagnostics, helping identify missing or unresolved types.
97+
98+
**Common causes of unresolved types:**
99+
100+
- **Monorepo with bundler (tsdown, tsup, etc.)**: Pre-build dependent packages so their types are available. For example, if package `A` depends on package `B`, build `B` first so its `.d.ts` files exist.
101+
- **Missing dependencies**: Ensure all dependencies are installed (`npm install` / `pnpm install`)
102+
103+
### Debugging Slow Performance
104+
105+
If type-aware linting is running slower than expected:
106+
107+
1. **Update to the latest versions** of both `oxlint` and `oxlint-tsgolint`
108+
109+
2. **Enable debug logging** to see detailed timing information:
110+
111+
```bash
112+
OXC_LOG=debug oxlint --type-aware
113+
```
114+
115+
Example output (showing key timing milestones):
116+
117+
```
118+
2025/01/01 12:00:00.000000 Starting tsgolint
119+
2025/01/01 12:00:00.001000 Starting to assign files to programs. Total files: 259
120+
2025/01/01 12:00:01.000000 Done assigning files to programs. Total programs: 8. Unmatched files: 75
121+
2025/01/01 12:00:01.001000 Starting linter with 12 workers
122+
2025/01/01 12:00:01.001000 Workload distribution: 8 programs
123+
2025/01/01 12:00:01.002000 [1/8] Running linter on program: /path/to/project/jsconfig.json
124+
...
125+
2025/01/01 12:00:01.100000 [4/8] Running linter on program: /path/to/project/tsconfig.json
126+
2025/01/01 12:00:02.500000 Program created with 26140 source files
127+
2025/01/01 12:00:14.000000 /path/to/project/oxlint-plugin.mts
128+
...
129+
2025/01/01 12:00:14.100000 [5/8] Running linter on program: /path/to/project/apps/tsconfig.json
130+
...
131+
2025/01/01 12:00:15.000000 Linting Complete
132+
Finished in 16.4s on 259 files with 161 rules using 12 threads.
133+
```
134+
135+
**How to interpret the log:**
136+
137+
- **File assignment phase** (`Starting to assign files...``Done assigning files...`): Maps source files to their tsconfig projects. This phase should be fast. If slow, please file an issue.
138+
- **Program linting** (`[N/M] Running linter on program...`): Each TypeScript project is linted separately. Programs that take significantly longer may indicate expensive type resolution or an overly large project.
139+
- Look for programs with an unusually high number of source files (e.g., `Program created with 26140 source files`). This may indicate misconfigured tsconfig `includes`/`excludes` pulling in unnecessary files like `node_modules`.
140+
- Each file path logged indicates when that file is being linted. Large time gaps between files may indicate expensive type resolution for certain files.
141+
86142
## TypeScript Compatibility
87143

88144
tsgolint is based on [typescript-go](https://github.com/microsoft/typescript-go) (Microsoft's TypeScript v7.0 rewrite in Go), not the original TypeScript compiler written in TypeScript.

0 commit comments

Comments
 (0)