Skip to content

Commit 9d3f88d

Browse files
committed
Use nil as trace by default
1 parent efd10bf commit 9d3f88d

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

internal/checker/checker_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ foo.bar;`
3636
fs = bundled.WrapFS(fs)
3737

3838
cd := "/"
39-
host := compiler.NewCompilerHost(cd, fs, bundled.LibPath(), nil, func(msg string) {})
39+
host := compiler.NewCompilerHost(cd, fs, bundled.LibPath(), nil, nil)
4040

4141
parsed, errors := tsoptions.GetParsedCommandLineOfConfigFile("/tsconfig.json", &core.CompilerOptions{}, host, nil)
4242
assert.Equal(t, len(errors), 0, "Expected no errors in parsed command line")
@@ -70,7 +70,7 @@ func TestCheckSrcCompiler(t *testing.T) {
7070

7171
rootPath := tspath.CombinePaths(tspath.NormalizeSlashes(repo.TypeScriptSubmodulePath), "src", "compiler")
7272

73-
host := compiler.NewCompilerHost(rootPath, fs, bundled.LibPath(), nil, func(msg string) {})
73+
host := compiler.NewCompilerHost(rootPath, fs, bundled.LibPath(), nil, nil)
7474
parsed, errors := tsoptions.GetParsedCommandLineOfConfigFile(tspath.CombinePaths(rootPath, "tsconfig.json"), &core.CompilerOptions{}, host, nil)
7575
assert.Equal(t, len(errors), 0, "Expected no errors in parsed command line")
7676
p := compiler.NewProgram(compiler.ProgramOptions{
@@ -87,7 +87,7 @@ func BenchmarkNewChecker(b *testing.B) {
8787

8888
rootPath := tspath.CombinePaths(tspath.NormalizeSlashes(repo.TypeScriptSubmodulePath), "src", "compiler")
8989

90-
host := compiler.NewCompilerHost(rootPath, fs, bundled.LibPath(), nil, func(msg string) {})
90+
host := compiler.NewCompilerHost(rootPath, fs, bundled.LibPath(), nil, nil)
9191
parsed, errors := tsoptions.GetParsedCommandLineOfConfigFile(tspath.CombinePaths(rootPath, "tsconfig.json"), &core.CompilerOptions{}, host, nil)
9292
assert.Equal(b, len(errors), 0, "Expected no errors in parsed command line")
9393
p := compiler.NewProgram(compiler.ProgramOptions{

internal/compiler/host.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ func NewCompilerHost(
5050
extendedConfigCache *collections.SyncMap[tspath.Path, *tsoptions.ExtendedConfigCacheEntry],
5151
trace func(msg string),
5252
) CompilerHost {
53+
if trace == nil {
54+
trace = func(msg string) {}
55+
}
5356
return &compilerHost{
5457
currentDirectory: currentDirectory,
5558
fs: fs,

internal/compiler/program_test.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package compiler
1+
package compiler_test
22

33
import (
44
"path/filepath"
@@ -7,6 +7,7 @@ import (
77
"testing"
88

99
"github.com/microsoft/typescript-go/internal/bundled"
10+
"github.com/microsoft/typescript-go/internal/compiler"
1011
"github.com/microsoft/typescript-go/internal/core"
1112
"github.com/microsoft/typescript-go/internal/repo"
1213
"github.com/microsoft/typescript-go/internal/tsoptions"
@@ -233,14 +234,14 @@ func TestProgram(t *testing.T) {
233234

234235
opts := core.CompilerOptions{Target: testCase.target}
235236

236-
program := NewProgram(ProgramOptions{
237+
program := compiler.NewProgram(compiler.ProgramOptions{
237238
Config: &tsoptions.ParsedCommandLine{
238239
ParsedConfig: &core.ParsedOptions{
239240
FileNames: []string{"c:/dev/src/index.ts"},
240241
CompilerOptions: &opts,
241242
},
242243
},
243-
Host: NewCompilerHost("c:/dev/src", fs, bundled.LibPath(), nil, func(msg string) {}),
244+
Host: compiler.NewCompilerHost("c:/dev/src", fs, bundled.LibPath(), nil, nil),
244245
})
245246

246247
actualFiles := []string{}
@@ -270,18 +271,18 @@ func BenchmarkNewProgram(b *testing.B) {
270271
}
271272

272273
opts := core.CompilerOptions{Target: testCase.target}
273-
programOpts := ProgramOptions{
274+
programOpts := compiler.ProgramOptions{
274275
Config: &tsoptions.ParsedCommandLine{
275276
ParsedConfig: &core.ParsedOptions{
276277
FileNames: []string{"c:/dev/src/index.ts"},
277278
CompilerOptions: &opts,
278279
},
279280
},
280-
Host: NewCompilerHost("c:/dev/src", fs, bundled.LibPath(), nil, func(msg string) {}),
281+
Host: compiler.NewCompilerHost("c:/dev/src", fs, bundled.LibPath(), nil, nil),
281282
}
282283

283284
for b.Loop() {
284-
NewProgram(programOpts)
285+
compiler.NewProgram(programOpts)
285286
}
286287
})
287288
}
@@ -294,18 +295,18 @@ func BenchmarkNewProgram(b *testing.B) {
294295
fs := osvfs.FS()
295296
fs = bundled.WrapFS(fs)
296297

297-
host := NewCompilerHost(rootPath, fs, bundled.LibPath(), nil, func(msg string) {})
298+
host := compiler.NewCompilerHost(rootPath, fs, bundled.LibPath(), nil, nil)
298299

299300
parsed, errors := tsoptions.GetParsedCommandLineOfConfigFile(tspath.CombinePaths(rootPath, "tsconfig.json"), nil, host, nil)
300301
assert.Equal(b, len(errors), 0, "Expected no errors in parsed command line")
301302

302-
opts := ProgramOptions{
303+
opts := compiler.ProgramOptions{
303304
Config: parsed,
304305
Host: host,
305306
}
306307

307308
for b.Loop() {
308-
NewProgram(opts)
309+
compiler.NewProgram(opts)
309310
}
310311
})
311312
}

0 commit comments

Comments
 (0)