Skip to content

Fix nil dereference in resolveHelpersModule via checkExternalEmitHelpers#3879

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-check-external-emit-helpers
Draft

Fix nil dereference in resolveHelpersModule via checkExternalEmitHelpers#3879
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-check-external-emit-helpers

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 15, 2026

resolveHelpersModule passes the result of GetImportHelpersImportSpecifier directly to resolveExternalModule without a nil check. The synthetic tslib import specifier is only created during file loading when specific conditions hold (JS file, or non-declaration file with isolatedModules or already-detected external module status). In language service scenarios, checkExternalEmitHelpers can run on files where the specifier was never created, causing a nil dereference in IsStringLiteralLike.

Changes

  • internal/checker/checker.go: In resolveHelpersModule, fall back to file.AsNode() when GetImportHelpersImportSpecifier returns nil. This gives resolveExternalModule a valid location node for determining the importing source file and default resolution mode.

  • testdata/tests/cases/compiler/checkExternalEmitHelpersCrash.ts: Compiler test exercising checkExternalEmitHelpers with importHelpers: 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).

Copilot AI and others added 2 commits May 15, 2026 23:21
…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
Copilot AI requested a review from DanielRosenwasser May 15, 2026 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.

Crash via checkExternalEmitHelpers

2 participants