Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions src/tsc-silent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const argv: Argv = require("yargs")
.array("suppress").default("suppress", [])
.string("compiler").default("compiler", "node_modules/typescript/lib/typescript.js")
.string("project").alias("project", "p")
.string("createSourceFile")
.boolean("watch").default("watch", false).alias("watch", "w")
.boolean("stats").default("stats", false)
.boolean("help")
Expand Down Expand Up @@ -71,6 +72,11 @@ const formatHost: ts.FormatDiagnosticsHost = {
getNewLine: () => ts.sys.newLine
};

if (argv.createSourceFile) {
const originalCreateSourceFile = ts.createSourceFile;
ts.createSourceFile = require(`${process.cwd()}/${argv.createSourceFile}`)(originalCreateSourceFile);
}

if (argv.watch) {
let watchDiagnostics: ts.Diagnostic[] = [];
const createProgram = ts.createSemanticDiagnosticsBuilderProgram;
Expand Down Expand Up @@ -253,20 +259,24 @@ function printUsage() {
console.log(" [--watch]");
console.log();
console.log("Synopsis:");
console.log(" --project, -p Path to tsconfig.json");
console.log(" --project, -p Path to tsconfig.json");
console.log();
console.log(" --compiler Path to typescript.js.");
console.log(" By default, uses `./node_modules/typescript/lib/typescript.js`.");
console.log();
console.log(" --compiler Path to typescript.js.");
console.log(" By default, uses `./node_modules/typescript/lib/typescript.js`.");
console.log(" --suppress Suppressed erros.");
console.log(" E.g. `--suppress 7017@src/js/ 2322,2339,2344@/src/legacy/`.")
console.log();
console.log(" --suppress Suppressed erros.");
console.log(" E.g. `--suppress 7017@src/js/ 2322,2339,2344@/src/legacy/`.")
console.log(" --suppressConfig Path to supressed errors config.");
console.log(" See documentation for examples.");
console.log();
console.log(" --suppressConfig Path to supressed errors config.");
console.log(" See documentation for examples.");
console.log(" --watch, -w Run in watch mode.");
console.log();
console.log(" --watch, -w Run in watch mode.");
console.log(" --stats Print number of suppressed errors per path and error code.");
console.log();
console.log(" --stats Print number of suppressed errors per path and error code.");
console.log(". --createSourceFile Custom module to use in place of the default TypeScript logic,
console.log(" it expects a module that exports a single function, with the");
console.log(" original TypeScript function as sole argument.");
console.log();
console.log("Description:");
console.log("The purpose of the wrapper is to execute TypeScript compiler but suppress some error messages");
Expand Down