Skip to content

Commit 7bf9417

Browse files
Philipp Zinsdonaldpipowitch
Philipp Zins
authored andcommitted
improve error message TS2307
1 parent 0a97663 commit 7bf9417

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2211,7 +2211,7 @@ namespace ts {
22112211
}
22122212

22132213
function resolveExternalModuleName(location: Node, moduleReferenceExpression: Expression): Symbol | undefined {
2214-
return resolveExternalModuleNameWorker(location, moduleReferenceExpression, Diagnostics.Cannot_find_module_0);
2214+
return resolveExternalModuleNameWorker(location, moduleReferenceExpression, Diagnostics.Cannot_find_module_0_or_cannot_find_corresponding_type_declarations_for_this_module);
22152215
}
22162216

22172217
function resolveExternalModuleNameWorker(location: Node, moduleReferenceExpression: Expression, moduleNotFoundError: DiagnosticMessage | undefined, isForAugmentation = false): Symbol | undefined {

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@
10361036
"category": "Error",
10371037
"code": 2306
10381038
},
1039-
"Cannot find module '{0}'.": {
1039+
"Cannot find module '{0}' or cannot find corresponding type declarations for this module.": {
10401040
"category": "Error",
10411041
"code": 2307
10421042
},

src/testRunner/unittests/tscWatchMode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ namespace ts.tscWatch {
230230

231231
function getDiagnosticModuleNotFoundOfFile(program: Program, file: File, moduleName: string) {
232232
const quotedModuleName = `"${moduleName}"`;
233-
return getDiagnosticOfFileFromProgram(program, file.path, file.content.indexOf(quotedModuleName), quotedModuleName.length, Diagnostics.Cannot_find_module_0, moduleName);
233+
return getDiagnosticOfFileFromProgram(program, file.path, file.content.indexOf(quotedModuleName), quotedModuleName.length, Diagnostics.Cannot_find_module_0_or_cannot_find_corresponding_type_declarations_for_this_module, moduleName);
234234
}
235235

236236
describe("tsc-watch program updates", () => {

src/testRunner/unittests/tsserverProjectSystem.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4679,7 +4679,7 @@ namespace ts.projectSystem {
46794679
host.runQueuedTimeoutCallbacks();
46804680
diags = session.executeCommand(getErrRequest).response as server.protocol.Diagnostic[];
46814681
verifyDiagnostics(diags, [
4682-
{ diagnosticMessage: Diagnostics.Cannot_find_module_0, errorTextArguments: ["./moduleFile"] }
4682+
{ diagnosticMessage: Diagnostics.Cannot_find_module_0_or_cannot_find_corresponding_type_declarations_for_this_module, errorTextArguments: ["./moduleFile"] }
46834683
]);
46844684
assert.equal(diags.length, 1);
46854685

@@ -4730,7 +4730,7 @@ namespace ts.projectSystem {
47304730
host.runQueuedTimeoutCallbacks();
47314731
diags = session.executeCommand(getErrRequest).response as server.protocol.Diagnostic[];
47324732
verifyDiagnostics(diags, [
4733-
{ diagnosticMessage: Diagnostics.Cannot_find_module_0, errorTextArguments: ["./moduleFile"] }
4733+
{ diagnosticMessage: Diagnostics.Cannot_find_module_0_or_cannot_find_corresponding_type_declarations_for_this_module, errorTextArguments: ["./moduleFile"] }
47344734
]);
47354735

47364736
moduleFile.path = moduleFileOldPath;
@@ -4805,7 +4805,7 @@ namespace ts.projectSystem {
48054805
);
48064806
let diags = session.executeCommand(getErrRequest).response as server.protocol.Diagnostic[];
48074807
verifyDiagnostics(diags, [
4808-
{ diagnosticMessage: Diagnostics.Cannot_find_module_0, errorTextArguments: ["./moduleFile"] }
4808+
{ diagnosticMessage: Diagnostics.Cannot_find_module_0_or_cannot_find_corresponding_type_declarations_for_this_module, errorTextArguments: ["./moduleFile"] }
48094809
]);
48104810

48114811
host.reloadFS([file1, moduleFile]);
@@ -4862,7 +4862,7 @@ namespace ts.projectSystem {
48624862
checkErrorMessage(session, "semanticDiag", {
48634863
file: file1.path,
48644864
diagnostics: [
4865-
createDiagnostic({ line: 1, offset: startOffset }, { line: 1, offset: startOffset + '"pad"'.length }, Diagnostics.Cannot_find_module_0, ["pad"])
4865+
createDiagnostic({ line: 1, offset: startOffset }, { line: 1, offset: startOffset + '"pad"'.length }, Diagnostics.Cannot_find_module_0_or_cannot_find_corresponding_type_declarations_for_this_module, ["pad"])
48664866
],
48674867
});
48684868
session.clearMessages();
@@ -7039,7 +7039,7 @@ namespace ts.projectSystem {
70397039
let diags = project.getLanguageService().getSemanticDiagnostics(root.path);
70407040
assert.equal(diags.length, 1);
70417041
const diag = diags[0];
7042-
assert.equal(diag.code, Diagnostics.Cannot_find_module_0.code);
7042+
assert.equal(diag.code, Diagnostics.Cannot_find_module_0_or_cannot_find_corresponding_type_declarations_for_this_module.code);
70437043
assert.equal(flattenDiagnosticMessageText(diag.messageText, "\n"), "Cannot find module 'bar'.");
70447044
callsTrackingHost.verifyCalledOn(CalledMapsWithSingleArg.fileExists, imported.path);
70457045

0 commit comments

Comments
 (0)