Skip to content

Implement externalModuleIndicator #979

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jun 10, 2025
Merged
Prev Previous commit
Next Next commit
Fix some crashes
  • Loading branch information
jakebailey committed May 29, 2025
commit 864482b8820220054a339600cefa74ac8c145b79
5 changes: 5 additions & 0 deletions internal/checker/checker_test.go
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@ foo.bar;`

parsed, errors := tsoptions.GetParsedCommandLineOfConfigFile("/tsconfig.json", &core.CompilerOptions{}, host, nil)
assert.Equal(t, len(errors), 0, "Expected no errors in parsed command line")
host = compiler.NewCachedFSCompilerHost(parsed.CompilerOptions(), cd, fs, bundled.LibPath())

p := compiler.NewProgramFromParsedCommandLine(parsed, host)
p.BindSourceFiles()
@@ -70,6 +71,8 @@ func TestCheckSrcCompiler(t *testing.T) {
host := compiler.NewCompilerHost(nil, rootPath, fs, bundled.LibPath())
parsed, errors := tsoptions.GetParsedCommandLineOfConfigFile(tspath.CombinePaths(rootPath, "tsconfig.json"), &core.CompilerOptions{}, host, nil)
assert.Equal(t, len(errors), 0, "Expected no errors in parsed command line")
host = compiler.NewCachedFSCompilerHost(parsed.CompilerOptions(), rootPath, fs, bundled.LibPath())

p := compiler.NewProgramFromParsedCommandLine(parsed, host)
p.CheckSourceFiles(t.Context())
}
@@ -84,6 +87,8 @@ func BenchmarkNewChecker(b *testing.B) {
host := compiler.NewCompilerHost(nil, rootPath, fs, bundled.LibPath())
parsed, errors := tsoptions.GetParsedCommandLineOfConfigFile(tspath.CombinePaths(rootPath, "tsconfig.json"), &core.CompilerOptions{}, host, nil)
assert.Equal(b, len(errors), 0, "Expected no errors in parsed command line")
host = compiler.NewCachedFSCompilerHost(parsed.CompilerOptions(), rootPath, fs, bundled.LibPath())

p := compiler.NewProgramFromParsedCommandLine(parsed, host)

b.ReportAllocs()
7 changes: 3 additions & 4 deletions internal/compiler/host.go
Original file line number Diff line number Diff line change
@@ -54,10 +54,6 @@ func (h *compilerHost) DefaultLibraryPath() string {
return h.defaultLibraryPath
}

func (h *compilerHost) SetOptions(options *core.CompilerOptions) {
h.options = options
}

func (h *compilerHost) GetCurrentDirectory() string {
return h.currentDirectory
}
@@ -78,5 +74,8 @@ func (h *compilerHost) GetSourceFile(fileName string, path tspath.Path) *ast.Sou
if tspath.FileExtensionIs(fileName, tspath.ExtensionJson) {
return parser.ParseJSONText(fileName, path, text)
}
if h.options == nil {
panic("GetSourceFile called without CompilerOptions set")
}
return parser.ParseSourceFile(fileName, path, text, h.options.SourceFileAffecting(), scanner.JSDocParsingModeParseForTypeErrors)
}
1 change: 1 addition & 0 deletions internal/compiler/program_test.go
Original file line number Diff line number Diff line change
@@ -288,6 +288,7 @@ func BenchmarkNewProgram(b *testing.B) {

parsed, errors := tsoptions.GetParsedCommandLineOfConfigFile(tspath.CombinePaths(rootPath, "tsconfig.json"), &core.CompilerOptions{}, host, nil)
assert.Equal(b, len(errors), 0, "Expected no errors in parsed command line")
host = NewCompilerHost(parsed.CompilerOptions(), rootPath, fs, bundled.LibPath())

opts := ProgramOptions{
Host: host,