Skip to content

Commit

Permalink
feat: support built-in --noCheck options
Browse files Browse the repository at this point in the history
  • Loading branch information
zanminkian committed Dec 15, 2024
1 parent 68c2c34 commit 965844f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/three-books-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rnm/tscx": patch
---

feat: support built-in `--noCheck` options
1 change: 1 addition & 0 deletions packages/tscx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ A `tsc` wrapper with many convenient features. Bring the [nodemon](https://www.n
- 🚨 As for `tsc` built-in options, we only support these options below.
- `--project`
- `--watch`
- `--noCheck`

## Install

Expand Down
5 changes: 5 additions & 0 deletions packages/tscx/src/bin/tscx.cli.mts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ new Command()
"Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'.",
"tsconfig.json",
)
.option(
"--noCheck",
"Disable full type checking (only critical parse and emit errors will be reported).",
false,
)
.option("-w, --watch", "Watch input files.", false)
.option(
"-r, --remove",
Expand Down
10 changes: 8 additions & 2 deletions packages/tscx/src/cmd/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ export function remove(filepath: string) {
return spawn("node", REMOVE_PATH, filepath);
}

export function tsc(options: { project: string }) {
export function tsc(options: { project: string; noCheck: boolean }) {
console.log("Tsc", options);
return spawn("node", TSC_PATH, "--project", options.project);
const args = [
TSC_PATH,
"--project",
options.project,
...(options.noCheck ? ["--noCheck"] : []),
];
return spawn("node", ...args);
}

export function copyfiles(rootDir: string, outDir: string) {
Expand Down
4 changes: 3 additions & 1 deletion packages/tscx/src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { copyfiles, exec, remove, script, tsc } from "./cmd/index.js";

export interface CompilerOptions {
project: string;
noCheck: boolean;
remove: boolean;
copyfiles: boolean;
script?: string;
Expand Down Expand Up @@ -63,14 +64,15 @@ export class Compiler {
private getTasks(): Array<() => childProcess.ChildProcess> {
const {
project,
noCheck,
remove: rm,
copyfiles: cp,
script: scr,
exec: ex,
} = this.options;
return [
...(rm ? [() => remove(this.outDir)] : []),
() => tsc({ project }),
() => tsc({ project, noCheck }),
...(cp ? [() => copyfiles(this.rootDir, this.outDir)] : []),
...(scr ? [() => script(scr)] : []),
...(ex ? [() => exec(ex)] : []),
Expand Down

0 comments on commit 965844f

Please sign in to comment.