feat(cli): Add new check command for type checking and update compiler options handling

This commit is contained in:
2025-05-15 09:31:57 +00:00
parent 6d68f35a9a
commit 960fc5f213
9 changed files with 402 additions and 49 deletions

View File

@ -146,17 +146,42 @@ Example usage with glob patterns:
npx tsbuild emitcheck "src/**/*.ts" "test/**/*.ts"
```
### Check Command
Performs type checking on TypeScript files specified by glob patterns without emitting them:
```bash
npx tsbuild check <glob_pattern> [additional_patterns ...]
```
This command:
1. Efficiently type checks TypeScript files matching the given glob patterns
2. Supports multiple glob patterns and direct file paths
3. Reports any type errors found in the matched files
4. Exits with code 0 if all files pass type checking, or 1 if any have errors
5. Doesn't produce any output files
Example usage:
```bash
npx tsbuild check ts/**/*
```
Example usage with multiple patterns:
```bash
npx tsbuild check "src/**/*.ts" "test/**/*.ts"
```
## Compiler Options
Additional flags can be passed to any command to modify the compilation behavior:
- `--skiplibcheck`: Skip type checking of declaration files (shows warning)
- `--allowimplicitany`: Allow variables to be implicitly typed as `any`
- `--disallowimplicitany`: Disallow variables to be implicitly typed as `any` (implicit any is allowed by default)
- `--commonjs`: Use CommonJS module format instead of ESNext
Example:
```bash
npx tsbuild --skiplibcheck --allowimplicitany
npx tsbuild --skiplibcheck --disallowimplicitany
```
## Default Compiler Options
@ -175,7 +200,7 @@ By default, `@git.zone/tsbuild` uses the following compiler options:
target: ScriptTarget.ESNext,
moduleResolution: ModuleResolutionKind.NodeNext,
lib: ['lib.dom.d.ts', 'lib.es2022.d.ts'],
noImplicitAny: true,
noImplicitAny: false, // Now allowing implicit any by default
esModuleInterop: true,
useDefineForClassFields: false,
verbatimModuleSyntax: true,