Skip to content

Fix nil host with watch and incremental #1455

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 1 commit into from
Jul 24, 2025
Merged

Fix nil host with watch and incremental #1455

merged 1 commit into from
Jul 24, 2025

Conversation

sheetalkamat
Copy link
Member

Fixes #1453

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes issue #1453 where the watcher would have a nil host when using both --watch and --incremental flags with a tsconfig.json file. The fix ensures the compiler host is always initialized regardless of whether a config file is present.

  • Removes conditional host initialization that was causing nil pointer issues
  • Adds test coverage for the watch + incremental + tsconfig combination
  • Updates baseline with expected output for the new test scenario

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
internal/execute/watcher.go Removes the conditional check that prevented host initialization when a config file was present
internal/execute/tscwatch_test.go Adds a new test case covering the watch + tsconfig + incremental scenario
testdata/baselines/reference/tscWatch/commandLineWatch/watch-with-tsconfig-and-incremental.js Baseline output for the new test case showing successful compilation

if w.configFileName == "" {
w.host = compiler.NewCompilerHost(w.sys.GetCurrentDirectory(), w.sys.FS(), w.sys.DefaultLibraryPath(), nil)
}
w.host = compiler.NewCompilerHost(w.sys.GetCurrentDirectory(), w.sys.FS(), w.sys.DefaultLibraryPath(), nil)
Copy link
Preview

Copilot AI Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The host initialization is now unconditional, but when w.configFileName is not empty, the host might need to be configured differently based on the config file settings. Consider if the host should use configuration-specific settings when a config file is present.

Copilot uses AI. Check for mistakes.

@jakebailey jakebailey enabled auto-merge July 24, 2025 23:04
@jakebailey jakebailey added this pull request to the merge queue Jul 24, 2025
Merged via the queue into main with commit 5ab1364 Jul 24, 2025
22 checks passed
@jakebailey jakebailey deleted the watchIncremental branch July 24, 2025 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tsgo --incremental --watch crashes
2 participants