Fix nil dereference in resolveHelpersModule via checkExternalEmitHelpers#3879
Draft
Copilot wants to merge 3 commits into
Draft
Fix nil dereference in resolveHelpersModule via checkExternalEmitHelpers#3879Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
…s nil Handle nil return from GetImportHelpersImportSpecifier in resolveHelpersModule by falling back to the source file node. This prevents a nil pointer dereference in resolveExternalModule when the synthetic tslib import specifier wasn't created during file loading (e.g., in language service scenarios). Fixes #1358 Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix crash via checkExternalEmitHelpers
Fix nil dereference in resolveHelpersModule via checkExternalEmitHelpers
May 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resolveHelpersModulepasses the result ofGetImportHelpersImportSpecifierdirectly toresolveExternalModulewithout a nil check. The synthetic tslib import specifier is only created during file loading when specific conditions hold (JS file, or non-declaration file withisolatedModulesor already-detected external module status). In language service scenarios,checkExternalEmitHelperscan run on files where the specifier was never created, causing a nil dereference inIsStringLiteralLike.Changes
internal/checker/checker.go: InresolveHelpersModule, fall back tofile.AsNode()whenGetImportHelpersImportSpecifierreturns nil. This givesresolveExternalModulea valid location node for determining the importing source file and default resolution mode.testdata/tests/cases/compiler/checkExternalEmitHelpersCrash.ts: Compiler test exercisingcheckExternalEmitHelperswithimportHelpers: true.internal/fourslash/tests/checkExternalEmitHelpersCrash_test.go: Fourslash test covering the LS diagnostics path with both async functions and ES decorators (the two crash stacks from the issue).