Skip to content

Report "File not found" for missing tripleslash path references#3206

Merged
jakebailey merged 12 commits intomicrosoft:mainfrom
Andarist:fix/report-file-not-found-missing-tripleslash
Mar 25, 2026
Merged

Report "File not found" for missing tripleslash path references#3206
jakebailey merged 12 commits intomicrosoft:mainfrom
Andarist:fix/report-file-not-found-missing-tripleslash

Conversation

@Andarist
Copy link
Contributor

@Andarist Andarist commented Mar 24, 2026

fixes #2081
Closes #3126

@jakebailey
Copy link
Member

jakebailey commented Mar 24, 2026

Is this just #3126? (Perhaps this PR is better, I have not yet looked)

…ound-missing-tripleslash

# Conflicts:
#	testdata/baselines/reference/submodule/compiler/moduleAugmentationDuringSyntheticDefaultCheck.types.diff
@jakebailey
Copy link
Member

On face, does seem like it covers more stuff, yeah. You can probably say "Fixes #2081".

@Andarist
Copy link
Contributor Author

Is this just #3126? (Perhaps this PR is better, I have not yet looked)

I started working on this probably over a week ago - but I also just scrapped this from .diffs so I haven't really checked open PRs/issues 😅 I really should start doing that 🫠

Copy link
Contributor

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 aligns tsgo with tsc by emitting diagnostics when a /// <reference path="..."/> directive points at a missing file (fixing #2081).

Changes:

  • Add triple-slash path reference resolution that produces TS6053 “File not found” (and related) processing diagnostics.
  • Respect noResolve by skipping triple-slash path references and type reference directives when enabled.
  • Update reference baselines across incremental + submodule suites to reflect the new diagnostics/output.

Reviewed changes

Copilot reviewed 73 out of 73 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/compiler/fileloader.go Adds triple-slash reference resolution + diagnostics and supported-extension handling.
internal/compiler/filesparser.go Wires triple-slash reference processing diagnostics into parse tasks; gates reference/type directives behind noResolve.
testdata/baselines/reference/tsc/incremental/when-global-file-is-added,-the-signatures-are-updated.js Baseline updated for new TS6053 output and incremental buildinfo errors flag.
testdata/baselines/reference/submodule/conformance/scannertest1.errors.txt.diff Baseline diff updated/removed due to new missing-reference diagnostic.
testdata/baselines/reference/submodule/conformance/scannertest1.errors.txt Baseline updated to include TS6053 for missing triple-slash reference.
testdata/baselines/reference/submodule/conformance/parserindenter.errors.txt.diff Baseline diff updated/trimmed due to new missing-reference diagnostic.
testdata/baselines/reference/submodule/conformance/parserindenter.errors.txt Baseline updated to include TS6053 for missing triple-slash reference.
testdata/baselines/reference/submodule/conformance/parserharness.errors.txt.diff Baseline diff updated/trimmed due to new missing-reference diagnostics.
testdata/baselines/reference/submodule/conformance/parserharness.errors.txt Baseline updated to include TS6053 for multiple missing triple-slash references.
testdata/baselines/reference/submodule/conformance/parserRealSource9.errors.txt.diff Baseline diff updated/trimmed due to new missing-reference diagnostic.
testdata/baselines/reference/submodule/conformance/parserRealSource9.errors.txt Baseline updated to include TS6053 for missing triple-slash reference.
testdata/baselines/reference/submodule/conformance/parserRealSource8.errors.txt.diff Baseline diff updated/trimmed due to new missing-reference diagnostic.
testdata/baselines/reference/submodule/conformance/parserRealSource8.errors.txt Baseline updated to include TS6053 for missing triple-slash reference.
testdata/baselines/reference/submodule/conformance/parserRealSource7.errors.txt.diff Baseline diff updated/trimmed due to new missing-reference diagnostic.
testdata/baselines/reference/submodule/conformance/parserRealSource7.errors.txt Baseline updated to include TS6053 for missing triple-slash reference.
testdata/baselines/reference/submodule/conformance/parserRealSource6.errors.txt.diff Baseline diff updated/trimmed due to new missing-reference diagnostic.
testdata/baselines/reference/submodule/conformance/parserRealSource6.errors.txt Baseline updated to include TS6053 for missing triple-slash reference.
testdata/baselines/reference/submodule/conformance/parserRealSource5.errors.txt.diff Baseline diff updated/removed due to new missing-reference diagnostic.
testdata/baselines/reference/submodule/conformance/parserRealSource5.errors.txt Baseline updated to include TS6053 for missing triple-slash reference.
testdata/baselines/reference/submodule/conformance/parserRealSource4.errors.txt.diff Baseline diff updated/removed due to new missing-reference diagnostic.
testdata/baselines/reference/submodule/conformance/parserRealSource4.errors.txt Baseline updated to include TS6053 for missing triple-slash reference.
testdata/baselines/reference/submodule/conformance/parserRealSource3.errors.txt.diff Baseline diff updated/removed due to new missing-reference diagnostic.
testdata/baselines/reference/submodule/conformance/parserRealSource3.errors.txt Baseline created/updated to include TS6053 for missing triple-slash reference.
testdata/baselines/reference/submodule/conformance/parserRealSource2.errors.txt.diff Baseline diff updated/removed due to new missing-reference diagnostic.
testdata/baselines/reference/submodule/conformance/parserRealSource2.errors.txt Baseline created/updated to include TS6053 for missing triple-slash reference.
testdata/baselines/reference/submodule/conformance/parserRealSource14.errors.txt.diff Baseline diff updated/removed due to new missing-reference diagnostic.
testdata/baselines/reference/submodule/conformance/parserRealSource14.errors.txt Baseline updated to include TS6053 for missing triple-slash reference.
testdata/baselines/reference/submodule/conformance/parserRealSource13.errors.txt.diff Baseline diff updated/trimmed due to new missing-reference diagnostic.
testdata/baselines/reference/submodule/conformance/parserRealSource13.errors.txt Baseline updated to include TS6053 for missing triple-slash reference.
testdata/baselines/reference/submodule/conformance/parserRealSource12.errors.txt.diff Baseline diff updated/trimmed due to new missing-reference diagnostic.
testdata/baselines/reference/submodule/conformance/parserRealSource12.errors.txt Baseline updated to include TS6053 for missing triple-slash reference.
testdata/baselines/reference/submodule/conformance/parserRealSource11.errors.txt.diff Baseline diff updated/trimmed due to new missing-reference diagnostic.
testdata/baselines/reference/submodule/conformance/parserRealSource11.errors.txt Baseline updated to include TS6053 for missing triple-slash reference.
testdata/baselines/reference/submodule/conformance/parserRealSource10.errors.txt.diff Baseline diff updated/removed due to new missing-reference diagnostic.
testdata/baselines/reference/submodule/conformance/parserRealSource10.errors.txt Baseline updated to include TS6053 for missing triple-slash reference.
testdata/baselines/reference/submodule/conformance/parserRealSource1.errors.txt.diff Baseline diff updated/removed due to new missing-reference diagnostic.
testdata/baselines/reference/submodule/conformance/parserRealSource1.errors.txt Baseline created/updated to include TS6053 for missing triple-slash reference.
testdata/baselines/reference/submodule/compiler/selfReferencingFile3.errors.txt.diff Baseline diff updated/removed due to formatting/output changes.
testdata/baselines/reference/submodule/compiler/selfReferencingFile3.errors.txt Baseline updated to include referenced-span output formatting.
testdata/baselines/reference/submodule/compiler/selfReferencingFile2.errors.txt.diff Baseline diff updated/removed due to formatting/output changes.
testdata/baselines/reference/submodule/compiler/selfReferencingFile2.errors.txt Baseline updated to include TS6053 referenced-span output formatting.
testdata/baselines/reference/submodule/compiler/selfReferencingFile.errors.txt.diff Baseline diff updated/removed due to formatting/output changes.
testdata/baselines/reference/submodule/compiler/selfReferencingFile.errors.txt Baseline updated to include referenced-span output formatting.
testdata/baselines/reference/submodule/compiler/moduleAugmentationDuringSyntheticDefaultCheck.types.diff Baseline diff updated/removed due to output reordering/printing changes.
testdata/baselines/reference/submodule/compiler/moduleAugmentationDuringSyntheticDefaultCheck.types Baseline updated to include additional emitted sections.
testdata/baselines/reference/submodule/compiler/moduleAugmentationDuringSyntheticDefaultCheck.symbols.diff Baseline diff updated/removed due to output reordering/printing changes.
testdata/baselines/reference/submodule/compiler/moduleAugmentationDuringSyntheticDefaultCheck.symbols Baseline updated to include additional symbol sections.
testdata/baselines/reference/submodule/compiler/moduleAugmentationDuringSyntheticDefaultCheck.js.diff Baseline diff updated/removed due to output reordering/printing changes.
testdata/baselines/reference/submodule/compiler/moduleAugmentationDuringSyntheticDefaultCheck.js Baseline updated to include additional emitted JS section.
testdata/baselines/reference/submodule/compiler/invalidTripleSlashReference.errors.txt.diff Baseline diff updated/removed due to new missing-reference diagnostics formatting.
testdata/baselines/reference/submodule/compiler/invalidTripleSlashReference.errors.txt Baseline updated to include TS6053 for invalid triple-slash references.
testdata/baselines/reference/submodule/compiler/fileReferencesWithNoExtensions.js.diff Baseline diff updated/removed due to output ordering changes.
testdata/baselines/reference/submodule/compiler/fileReferencesWithNoExtensions.js Baseline updated to reflect emitted output ordering.
testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.types.diff Baseline diff updated/removed due to output changes.
testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.types Baseline updated to include additional file section output.
testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.symbols.diff Baseline diff updated/removed due to output changes.
testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.symbols Baseline updated to include additional file section output.
testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js.diff Baseline diff updated/removed due to output changes.
testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.js Baseline updated to include additional emitted JS section.
testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.errors.txt.diff Baseline diff updated to reflect changed error set/ordering.
testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans7.errors.txt Baseline updated to reflect changed error set/ordering.
testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.types.diff Baseline diff updated/removed due to output changes.
testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.types Baseline updated to include additional file section output.
testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.symbols.diff Baseline diff updated/removed due to output changes.
testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.symbols Baseline updated to include additional file section output.
testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js.diff Baseline diff updated/removed due to output changes.
testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.js Baseline updated to include additional emitted JS section.
testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.errors.txt.diff Baseline diff updated to reflect changed error set/ordering.
testdata/baselines/reference/submodule/compiler/duplicateIdentifierRelatedSpans6.errors.txt Baseline updated to reflect changed error set/ordering.
testdata/baselines/reference/submodule/compiler/declarationEmitInvalidReferenceAllowJs.errors.txt.diff Baseline diff updated/removed due to new diagnostic formatting/output.
testdata/baselines/reference/submodule/compiler/declarationEmitInvalidReferenceAllowJs.errors.txt Baseline updated to include TS6231 output formatting.
testdata/baselines/reference/submodule/compiler/declarationEmitInvalidReference2.errors.txt.diff Baseline diff updated/removed due to new diagnostic formatting/output.
testdata/baselines/reference/submodule/compiler/declarationEmitInvalidReference2.errors.txt Baseline updated to include TS6053 output formatting.

@Andarist Andarist requested a review from jakebailey March 24, 2026 22:48
canonicalFileName := tspath.GetCanonicalFileName(fileName, p.opts.Host.FS().UseCaseSensitiveFileNames())
if !allowNonTsExtensions {
supported := false
for _, ext := range core.Flatten(p.supportedExtensionsWithJsonIfResolveJsonModule) {
Copy link
Member

Choose a reason for hiding this comment

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

We do this in two places, actually; we should extract this to a method.

@jakebailey
Copy link
Member

my unsolicited patch

Details
diff --git a/internal/compiler/fileloader.go b/internal/compiler/fileloader.go
index fef6a118c6..04523fe78e 100644
--- a/internal/compiler/fileloader.go
+++ b/internal/compiler/fileloader.go
@@ -308,6 +308,15 @@ func (p *fileLoader) parseSourceFile(t *parseTask) *ast.SourceFile {
 	return sourceFile
 }
 
+func (p *fileLoader) isSupportedExtension(canonicalFileName string) bool {
+	for _, group := range p.supportedExtensionsWithJsonIfResolveJsonModule {
+		if tspath.FileExtensionIsOneOf(canonicalFileName, group) {
+			return true
+		}
+	}
+	return false
+}
+
 func (p *fileLoader) getSourceFileFromReference(
 	fileName string,
 	referenceText string,
@@ -319,21 +328,11 @@ func (p *fileLoader) getSourceFileFromReference(
 
 	if tspath.HasExtension(fileName) {
 		canonicalFileName := tspath.GetCanonicalFileName(fileName, p.opts.Host.FS().UseCaseSensitiveFileNames())
-		if !allowNonTsExtensions {
-			supported := false
-			for _, group := range p.supportedExtensionsWithJsonIfResolveJsonModule {
-				if tspath.FileExtensionIsOneOf(canonicalFileName, group) {
-					supported = true
-					break
-				}
-			}
-			if !supported {
-				if tspath.HasJSFileExtension(canonicalFileName) {
-					return "", &sourceFileFromReferenceDiagnostic{message: diagnostics.File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option, args: []any{diagnosticFileName}}
-				} else {
-					return "", &sourceFileFromReferenceDiagnostic{message: diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, args: []any{diagnosticFileName, "'" + strings.Join(core.Flatten(p.supportedExtensionsWithJsonIfResolveJsonModule), "', '") + "'"}}
-				}
+		if !allowNonTsExtensions && !p.isSupportedExtension(canonicalFileName) {
+			if tspath.HasJSFileExtension(canonicalFileName) {
+				return "", &sourceFileFromReferenceDiagnostic{message: diagnostics.File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option, args: []any{diagnosticFileName}}
 			}
+			return "", &sourceFileFromReferenceDiagnostic{message: diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, args: []any{diagnosticFileName, "'" + strings.Join(core.Flatten(p.supportedExtensions), "', '") + "'"}}
 		}
 
 		if !p.opts.Host.FS().FileExists(fileName) {
diff --git a/internal/compiler/filesparser.go b/internal/compiler/filesparser.go
index c4223c177a..b534faecfd 100644
--- a/internal/compiler/filesparser.go
+++ b/internal/compiler/filesparser.go
@@ -3,6 +3,7 @@ package compiler
 import (
 	"math"
 	"slices"
+	"strings"
 	"sync"
 
 	"github.com/microsoft/typescript-go/internal/ast"
@@ -69,14 +70,7 @@ func (t *parseTask) load(loader *fileLoader) {
 		allowNonTsExtensions := compilerOptions.AllowNonTsExtensions.IsTrue()
 		if !allowNonTsExtensions {
 			canonicalFileName := tspath.GetCanonicalFileName(t.normalizedFilePath, loader.opts.Host.FS().UseCaseSensitiveFileNames())
-			supported := false
-			for _, group := range loader.supportedExtensionsWithJsonIfResolveJsonModule {
-				if tspath.FileExtensionIsOneOf(canonicalFileName, group) {
-					supported = true
-					break
-				}
-			}
-			if !supported {
+			if !loader.isSupportedExtension(canonicalFileName) {
 				if tspath.HasJSFileExtension(canonicalFileName) {
 					t.processingDiagnostics = append(t.processingDiagnostics, &processingDiagnostic{
 						kind: processingDiagnosticKindExplainingFileInclude,
@@ -86,6 +80,15 @@ func (t *parseTask) load(loader *fileLoader) {
 							args:             []any{t.normalizedFilePath},
 						},
 					})
+				} else {
+					t.processingDiagnostics = append(t.processingDiagnostics, &processingDiagnostic{
+						kind: processingDiagnosticKindExplainingFileInclude,
+						data: &includeExplainingDiagnostic{
+							diagnosticReason: t.includeReason,
+							message:          diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1,
+							args:             []any{t.normalizedFilePath, "'" + strings.Join(core.Flatten(loader.supportedExtensions), "', '") + "'"},
+						},
+					})
 				}
 				return
 			}

@jakebailey jakebailey enabled auto-merge March 25, 2026 17:34
@jakebailey jakebailey added this pull request to the merge queue Mar 25, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Mar 25, 2026
@jakebailey jakebailey added this pull request to the merge queue Mar 25, 2026
Merged via the queue into microsoft:main with commit 7a2de6d Mar 25, 2026
21 checks passed
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.

Missing error when reference directive file path doesn't exist

3 participants