diff --git a/internal/compiler/program.go b/internal/compiler/program.go index 794d2fa96d..2c926a2ec3 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -247,7 +247,13 @@ func (p *Program) initCheckerPool() { if p.opts.CreateCheckerPool != nil { p.checkerPool = p.opts.CreateCheckerPool(p) } else { - p.checkerPool = newCheckerPool(core.IfElse(p.SingleThreaded(), 1, 4), p) + checkers := 4 + if p.SingleThreaded() { + checkers = 1 + } else if p.Options().Checkers != nil { + checkers = min(max(*p.Options().Checkers, 1), 256) + } + p.checkerPool = newCheckerPool(checkers, p) } } diff --git a/internal/core/compileroptions.go b/internal/core/compileroptions.go index ab1936ca76..28e1a797e5 100644 --- a/internal/core/compileroptions.go +++ b/internal/core/compileroptions.go @@ -148,6 +148,7 @@ type CompilerOptions struct { PprofDir string `json:"pprofDir,omitzero"` SingleThreaded Tristate `json:"singleThreaded,omitzero"` Quiet Tristate `json:"quiet,omitzero"` + Checkers *int `json:"checkers,omitzero"` sourceFileAffectingCompilerOptionsOnce sync.Once sourceFileAffectingCompilerOptions SourceFileAffectingCompilerOptions diff --git a/internal/diagnostics/diagnostics_generated.go b/internal/diagnostics/diagnostics_generated.go index 9c9757528d..e0f6117de7 100644 --- a/internal/diagnostics/diagnostics_generated.go +++ b/internal/diagnostics/diagnostics_generated.go @@ -4255,3 +4255,7 @@ var Do_not_print_diagnostics = &Message{code: 100000, category: CategoryMessage, var Run_in_single_threaded_mode = &Message{code: 100001, category: CategoryMessage, key: "Run_in_single_threaded_mode_100001", text: "Run in single threaded mode."} var Generate_pprof_CPU_Slashmemory_profiles_to_the_given_directory = &Message{code: 100002, category: CategoryMessage, key: "Generate_pprof_CPU_Slashmemory_profiles_to_the_given_directory_100002", text: "Generate pprof CPU/memory profiles to the given directory."} + +var Set_the_number_of_checkers_per_project = &Message{code: 100003, category: CategoryMessage, key: "Set_the_number_of_checkers_per_project_100003", text: "Set the number of checkers per project."} + +var X_4_unless_singleThreaded_is_passed = &Message{code: 100004, category: CategoryMessage, key: "4_unless_singleThreaded_is_passed_100004", text: "4, unless --singleThreaded is passed."} diff --git a/internal/diagnostics/extraDiagnosticMessages.json b/internal/diagnostics/extraDiagnosticMessages.json index b735a67695..0574edff7a 100644 --- a/internal/diagnostics/extraDiagnosticMessages.json +++ b/internal/diagnostics/extraDiagnosticMessages.json @@ -11,6 +11,14 @@ "category": "Message", "code": 100002 }, + "Set the number of checkers per project.": { + "category": "Message", + "code": 100003 + }, + "4, unless --singleThreaded is passed.": { + "category": "Message", + "code": 100004 + }, "Non-relative paths are not allowed. Did you forget a leading './'?": { "category": "Error", "code": 5090 diff --git a/internal/tsoptions/declscompiler.go b/internal/tsoptions/declscompiler.go index 2161f77343..7ef3119264 100644 --- a/internal/tsoptions/declscompiler.go +++ b/internal/tsoptions/declscompiler.go @@ -233,6 +233,13 @@ var commonOptionsWithBuild = []*CommandLineOption{ Category: diagnostics.Command_line_Options, Description: diagnostics.Generate_pprof_CPU_Slashmemory_profiles_to_the_given_directory, }, + { + Name: "checkers", + Kind: CommandLineOptionTypeNumber, + Category: diagnostics.Command_line_Options, + Description: diagnostics.Set_the_number_of_checkers_per_project, + DefaultValueDescription: diagnostics.X_4_unless_singleThreaded_is_passed, + }, } var optionsForCompiler = []*CommandLineOption{ diff --git a/internal/tsoptions/parsinghelpers.go b/internal/tsoptions/parsinghelpers.go index 91944af6a7..2583ed4147 100644 --- a/internal/tsoptions/parsinghelpers.go +++ b/internal/tsoptions/parsinghelpers.go @@ -443,6 +443,8 @@ func parseCompilerOptions(key string, value any, allOptions *core.CompilerOption allOptions.SingleThreaded = ParseTristate(value) case "quiet": allOptions.Quiet = ParseTristate(value) + case "checkers": + allOptions.Checkers = parseNumber(value) default: // different than any key above return false diff --git a/testdata/baselines/reference/tsbuild/commandLine/help.js b/testdata/baselines/reference/tsbuild/commandLine/help.js index 8c6e197bcd..35fbc66be7 100644 --- a/testdata/baselines/reference/tsbuild/commandLine/help.js +++ b/testdata/baselines/reference/tsbuild/commandLine/help.js @@ -126,6 +126,9 @@ Run in single threaded mode. --pprofDir Generate pprof CPU/memory profiles to the given directory. +--checkers +Set the number of checkers per project. + --verbose, -v Enable verbose logging. diff --git a/testdata/baselines/reference/tsc/commandLine/help-all.js b/testdata/baselines/reference/tsc/commandLine/help-all.js index a43fd20900..a2b8184ea2 100644 --- a/testdata/baselines/reference/tsc/commandLine/help-all.js +++ b/testdata/baselines/reference/tsc/commandLine/help-all.js @@ -17,6 +17,9 @@ Show all compiler options. --build, -b Build one or more projects and their dependencies, if out of date +--checkers +Set the number of checkers per project. + --help, -h Print this message.