typescript 5.2.0-dev.20230605 → 5.2.0-dev.20230607
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +72 -35
- package/lib/tsserver.js +679 -616
- package/lib/tsserverlibrary.js +678 -616
- package/lib/typescript.js +652 -608
- package/lib/typingsInstaller.js +27 -5
- package/package.json +2 -2
package/lib/tsserver.js
CHANGED
|
@@ -1285,6 +1285,7 @@ __export(server_exports, {
|
|
|
1285
1285
|
isDiagnosticWithLocation: () => isDiagnosticWithLocation,
|
|
1286
1286
|
isDiskPathRoot: () => isDiskPathRoot,
|
|
1287
1287
|
isDoStatement: () => isDoStatement,
|
|
1288
|
+
isDocumentRegistryEntry: () => isDocumentRegistryEntry,
|
|
1288
1289
|
isDotDotDotToken: () => isDotDotDotToken,
|
|
1289
1290
|
isDottedName: () => isDottedName,
|
|
1290
1291
|
isDynamicName: () => isDynamicName,
|
|
@@ -2304,7 +2305,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2304
2305
|
|
|
2305
2306
|
// src/compiler/corePublic.ts
|
|
2306
2307
|
var versionMajorMinor = "5.2";
|
|
2307
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2308
|
+
var version = `${versionMajorMinor}.0-dev.20230607`;
|
|
2308
2309
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2309
2310
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2310
2311
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -4005,10 +4006,10 @@ var Debug;
|
|
|
4005
4006
|
}
|
|
4006
4007
|
Debug2.log = log;
|
|
4007
4008
|
((_log) => {
|
|
4008
|
-
function
|
|
4009
|
+
function error2(s) {
|
|
4009
4010
|
logMessage(1 /* Error */, s);
|
|
4010
4011
|
}
|
|
4011
|
-
_log.error =
|
|
4012
|
+
_log.error = error2;
|
|
4012
4013
|
function warn(s) {
|
|
4013
4014
|
logMessage(2 /* Warning */, s);
|
|
4014
4015
|
}
|
|
@@ -4282,6 +4283,15 @@ Node ${formatSyntaxKind(node.kind)} was unexpected.`,
|
|
|
4282
4283
|
);
|
|
4283
4284
|
}
|
|
4284
4285
|
Debug2.formatSnippetKind = formatSnippetKind;
|
|
4286
|
+
function formatScriptKind(kind) {
|
|
4287
|
+
return formatEnum(
|
|
4288
|
+
kind,
|
|
4289
|
+
ScriptKind,
|
|
4290
|
+
/*isFlags*/
|
|
4291
|
+
false
|
|
4292
|
+
);
|
|
4293
|
+
}
|
|
4294
|
+
Debug2.formatScriptKind = formatScriptKind;
|
|
4285
4295
|
function formatNodeFlags(flags) {
|
|
4286
4296
|
return formatEnum(
|
|
4287
4297
|
flags,
|
|
@@ -6920,16 +6930,16 @@ var NewLineKind = /* @__PURE__ */ ((NewLineKind3) => {
|
|
|
6920
6930
|
NewLineKind3[NewLineKind3["LineFeed"] = 1] = "LineFeed";
|
|
6921
6931
|
return NewLineKind3;
|
|
6922
6932
|
})(NewLineKind || {});
|
|
6923
|
-
var ScriptKind = /* @__PURE__ */ ((
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
return
|
|
6933
|
+
var ScriptKind = /* @__PURE__ */ ((ScriptKind7) => {
|
|
6934
|
+
ScriptKind7[ScriptKind7["Unknown"] = 0] = "Unknown";
|
|
6935
|
+
ScriptKind7[ScriptKind7["JS"] = 1] = "JS";
|
|
6936
|
+
ScriptKind7[ScriptKind7["JSX"] = 2] = "JSX";
|
|
6937
|
+
ScriptKind7[ScriptKind7["TS"] = 3] = "TS";
|
|
6938
|
+
ScriptKind7[ScriptKind7["TSX"] = 4] = "TSX";
|
|
6939
|
+
ScriptKind7[ScriptKind7["External"] = 5] = "External";
|
|
6940
|
+
ScriptKind7[ScriptKind7["JSON"] = 6] = "JSON";
|
|
6941
|
+
ScriptKind7[ScriptKind7["Deferred"] = 7] = "Deferred";
|
|
6942
|
+
return ScriptKind7;
|
|
6933
6943
|
})(ScriptKind || {});
|
|
6934
6944
|
var ScriptTarget = /* @__PURE__ */ ((ScriptTarget11) => {
|
|
6935
6945
|
ScriptTarget11[ScriptTarget11["ES3"] = 0] = "ES3";
|
|
@@ -8459,8 +8469,8 @@ var sys = (() => {
|
|
|
8459
8469
|
try {
|
|
8460
8470
|
const modulePath = resolveJSModule(moduleName, baseDir, nodeSystem);
|
|
8461
8471
|
return { module: require(modulePath), modulePath, error: void 0 };
|
|
8462
|
-
} catch (
|
|
8463
|
-
return { module: void 0, modulePath: void 0, error };
|
|
8472
|
+
} catch (error2) {
|
|
8473
|
+
return { module: void 0, modulePath: void 0, error: error2 };
|
|
8464
8474
|
}
|
|
8465
8475
|
}
|
|
8466
8476
|
};
|
|
@@ -11216,6 +11226,7 @@ var Diagnostics = {
|
|
|
11216
11226
|
Use_import_type: diag(95180, 3 /* Message */, "Use_import_type_95180", "Use 'import type'"),
|
|
11217
11227
|
Use_type_0: diag(95181, 3 /* Message */, "Use_type_0_95181", "Use 'type {0}'"),
|
|
11218
11228
|
Fix_all_with_type_only_imports: diag(95182, 3 /* Message */, "Fix_all_with_type_only_imports_95182", "Fix all with type-only imports"),
|
|
11229
|
+
Cannot_move_statements_to_the_selected_file: diag(95183, 3 /* Message */, "Cannot_move_statements_to_the_selected_file_95183", "Cannot move statements to the selected file"),
|
|
11219
11230
|
No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, 1 /* Error */, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
|
|
11220
11231
|
Classes_may_not_have_a_field_named_constructor: diag(18006, 1 /* Error */, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
|
|
11221
11232
|
JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, 1 /* Error */, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
|
|
@@ -11691,9 +11702,9 @@ function isConflictMarkerTrivia(text, pos) {
|
|
|
11691
11702
|
}
|
|
11692
11703
|
return false;
|
|
11693
11704
|
}
|
|
11694
|
-
function scanConflictMarkerTrivia(text, pos,
|
|
11695
|
-
if (
|
|
11696
|
-
|
|
11705
|
+
function scanConflictMarkerTrivia(text, pos, error2) {
|
|
11706
|
+
if (error2) {
|
|
11707
|
+
error2(Diagnostics.Merge_conflict_marker_encountered, pos, mergeConflictMarkerLength);
|
|
11697
11708
|
}
|
|
11698
11709
|
const ch = text.charCodeAt(pos);
|
|
11699
11710
|
const len = text.length;
|
|
@@ -11990,7 +12001,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
11990
12001
|
});
|
|
11991
12002
|
}
|
|
11992
12003
|
return scanner2;
|
|
11993
|
-
function
|
|
12004
|
+
function error2(message, errPos = pos, length3, arg0) {
|
|
11994
12005
|
if (onError) {
|
|
11995
12006
|
const oldPos = pos;
|
|
11996
12007
|
pos = errPos;
|
|
@@ -12014,9 +12025,9 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12014
12025
|
} else {
|
|
12015
12026
|
tokenFlags |= 16384 /* ContainsInvalidSeparator */;
|
|
12016
12027
|
if (isPreviousTokenSeparator) {
|
|
12017
|
-
|
|
12028
|
+
error2(Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
|
|
12018
12029
|
} else {
|
|
12019
|
-
|
|
12030
|
+
error2(Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
|
|
12020
12031
|
}
|
|
12021
12032
|
}
|
|
12022
12033
|
pos++;
|
|
@@ -12033,7 +12044,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12033
12044
|
}
|
|
12034
12045
|
if (text.charCodeAt(pos - 1) === 95 /* _ */) {
|
|
12035
12046
|
tokenFlags |= 16384 /* ContainsInvalidSeparator */;
|
|
12036
|
-
|
|
12047
|
+
error2(Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
|
|
12037
12048
|
}
|
|
12038
12049
|
return result + text.substring(start3, pos);
|
|
12039
12050
|
}
|
|
@@ -12044,7 +12055,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12044
12055
|
pos++;
|
|
12045
12056
|
if (text.charCodeAt(pos) === 95 /* _ */) {
|
|
12046
12057
|
tokenFlags |= 512 /* ContainsSeparator */ | 16384 /* ContainsInvalidSeparator */;
|
|
12047
|
-
|
|
12058
|
+
error2(Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
|
|
12048
12059
|
pos--;
|
|
12049
12060
|
mainFragment = scanNumberFragment();
|
|
12050
12061
|
} else if (!scanDigits()) {
|
|
@@ -12059,7 +12070,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12059
12070
|
const literal = (withMinus ? "-" : "") + "0o" + (+tokenValue).toString(8);
|
|
12060
12071
|
if (withMinus)
|
|
12061
12072
|
start3--;
|
|
12062
|
-
|
|
12073
|
+
error2(Diagnostics.Octal_literals_are_not_allowed_Use_the_syntax_0, start3, pos - start3, literal);
|
|
12063
12074
|
return { type: 9 /* NumericLiteral */, value: tokenValue };
|
|
12064
12075
|
}
|
|
12065
12076
|
} else {
|
|
@@ -12080,7 +12091,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12080
12091
|
const preNumericPart = pos;
|
|
12081
12092
|
const finalFragment = scanNumberFragment();
|
|
12082
12093
|
if (!finalFragment) {
|
|
12083
|
-
|
|
12094
|
+
error2(Diagnostics.Digit_expected);
|
|
12084
12095
|
} else {
|
|
12085
12096
|
scientificFragment = text.substring(end2, preNumericPart) + finalFragment;
|
|
12086
12097
|
end2 = pos;
|
|
@@ -12099,7 +12110,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12099
12110
|
result = text.substring(start3, end2);
|
|
12100
12111
|
}
|
|
12101
12112
|
if (tokenFlags & 8192 /* ContainsLeadingZero */) {
|
|
12102
|
-
|
|
12113
|
+
error2(Diagnostics.Decimals_with_leading_zeros_are_not_allowed, start3, end2 - start3);
|
|
12103
12114
|
return { type: 9 /* NumericLiteral */, value: "" + +result };
|
|
12104
12115
|
}
|
|
12105
12116
|
if (decimalFragment !== void 0 || tokenFlags & 16 /* Scientific */) {
|
|
@@ -12124,12 +12135,12 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12124
12135
|
const { length: length3 } = scanIdentifierParts();
|
|
12125
12136
|
if (length3 === 1 && text[identifierStart] === "n") {
|
|
12126
12137
|
if (isScientific) {
|
|
12127
|
-
|
|
12138
|
+
error2(Diagnostics.A_bigint_literal_cannot_use_exponential_notation, numericStart, identifierStart - numericStart + 1);
|
|
12128
12139
|
} else {
|
|
12129
|
-
|
|
12140
|
+
error2(Diagnostics.A_bigint_literal_must_be_an_integer, numericStart, identifierStart - numericStart + 1);
|
|
12130
12141
|
}
|
|
12131
12142
|
} else {
|
|
12132
|
-
|
|
12143
|
+
error2(Diagnostics.An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal, identifierStart, length3);
|
|
12133
12144
|
pos = identifierStart;
|
|
12134
12145
|
}
|
|
12135
12146
|
}
|
|
@@ -12176,9 +12187,9 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12176
12187
|
allowSeparator = false;
|
|
12177
12188
|
isPreviousTokenSeparator = true;
|
|
12178
12189
|
} else if (isPreviousTokenSeparator) {
|
|
12179
|
-
|
|
12190
|
+
error2(Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
|
|
12180
12191
|
} else {
|
|
12181
|
-
|
|
12192
|
+
error2(Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
|
|
12182
12193
|
}
|
|
12183
12194
|
pos++;
|
|
12184
12195
|
continue;
|
|
@@ -12197,7 +12208,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12197
12208
|
valueChars = [];
|
|
12198
12209
|
}
|
|
12199
12210
|
if (text.charCodeAt(pos - 1) === 95 /* _ */) {
|
|
12200
|
-
|
|
12211
|
+
error2(Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
|
|
12201
12212
|
}
|
|
12202
12213
|
return String.fromCharCode(...valueChars);
|
|
12203
12214
|
}
|
|
@@ -12210,7 +12221,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12210
12221
|
if (pos >= end) {
|
|
12211
12222
|
result += text.substring(start3, pos);
|
|
12212
12223
|
tokenFlags |= 4 /* Unterminated */;
|
|
12213
|
-
|
|
12224
|
+
error2(Diagnostics.Unterminated_string_literal);
|
|
12214
12225
|
break;
|
|
12215
12226
|
}
|
|
12216
12227
|
const ch = text.charCodeAt(pos);
|
|
@@ -12231,7 +12242,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12231
12242
|
if (isLineBreak(ch) && !jsxAttributeString) {
|
|
12232
12243
|
result += text.substring(start3, pos);
|
|
12233
12244
|
tokenFlags |= 4 /* Unterminated */;
|
|
12234
|
-
|
|
12245
|
+
error2(Diagnostics.Unterminated_string_literal);
|
|
12235
12246
|
break;
|
|
12236
12247
|
}
|
|
12237
12248
|
pos++;
|
|
@@ -12248,7 +12259,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12248
12259
|
if (pos >= end) {
|
|
12249
12260
|
contents += text.substring(start3, pos);
|
|
12250
12261
|
tokenFlags |= 4 /* Unterminated */;
|
|
12251
|
-
|
|
12262
|
+
error2(Diagnostics.Unterminated_template_literal);
|
|
12252
12263
|
resultingToken = startedWithBacktick ? 15 /* NoSubstitutionTemplateLiteral */ : 18 /* TemplateTail */;
|
|
12253
12264
|
break;
|
|
12254
12265
|
}
|
|
@@ -12291,7 +12302,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12291
12302
|
const start3 = pos;
|
|
12292
12303
|
pos++;
|
|
12293
12304
|
if (pos >= end) {
|
|
12294
|
-
|
|
12305
|
+
error2(Diagnostics.Unexpected_end_of_text);
|
|
12295
12306
|
return "";
|
|
12296
12307
|
}
|
|
12297
12308
|
const ch = text.charCodeAt(pos);
|
|
@@ -12317,7 +12328,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12317
12328
|
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
12318
12329
|
if (shouldEmitInvalidEscapeError) {
|
|
12319
12330
|
const code = parseInt(text.substring(start3 + 1, pos), 8);
|
|
12320
|
-
|
|
12331
|
+
error2(Diagnostics.Octal_escape_sequences_are_not_allowed_Use_the_syntax_0, start3, pos - start3, "\\x" + padLeft(code.toString(16), 2, "0"));
|
|
12321
12332
|
return String.fromCharCode(code);
|
|
12322
12333
|
}
|
|
12323
12334
|
return text.substring(start3, pos);
|
|
@@ -12325,7 +12336,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12325
12336
|
case 57 /* _9 */:
|
|
12326
12337
|
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
12327
12338
|
if (shouldEmitInvalidEscapeError) {
|
|
12328
|
-
|
|
12339
|
+
error2(Diagnostics.Escape_sequence_0_is_not_allowed, start3, pos - start3, text.substring(start3, pos));
|
|
12329
12340
|
return String.fromCharCode(ch);
|
|
12330
12341
|
}
|
|
12331
12342
|
return text.substring(start3, pos);
|
|
@@ -12357,28 +12368,28 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12357
12368
|
if (escapedValue < 0) {
|
|
12358
12369
|
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
12359
12370
|
if (shouldEmitInvalidEscapeError) {
|
|
12360
|
-
|
|
12371
|
+
error2(Diagnostics.Hexadecimal_digit_expected);
|
|
12361
12372
|
}
|
|
12362
12373
|
return text.substring(start3, pos);
|
|
12363
12374
|
}
|
|
12364
12375
|
if (!isCodePoint(escapedValue)) {
|
|
12365
12376
|
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
12366
12377
|
if (shouldEmitInvalidEscapeError) {
|
|
12367
|
-
|
|
12378
|
+
error2(Diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive);
|
|
12368
12379
|
}
|
|
12369
12380
|
return text.substring(start3, pos);
|
|
12370
12381
|
}
|
|
12371
12382
|
if (pos >= end) {
|
|
12372
12383
|
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
12373
12384
|
if (shouldEmitInvalidEscapeError) {
|
|
12374
|
-
|
|
12385
|
+
error2(Diagnostics.Unexpected_end_of_text);
|
|
12375
12386
|
}
|
|
12376
12387
|
return text.substring(start3, pos);
|
|
12377
12388
|
}
|
|
12378
12389
|
if (text.charCodeAt(pos) !== 125 /* closeBrace */) {
|
|
12379
12390
|
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
12380
12391
|
if (shouldEmitInvalidEscapeError) {
|
|
12381
|
-
|
|
12392
|
+
error2(Diagnostics.Unterminated_Unicode_escape_sequence);
|
|
12382
12393
|
}
|
|
12383
12394
|
return text.substring(start3, pos);
|
|
12384
12395
|
}
|
|
@@ -12390,7 +12401,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12390
12401
|
if (!(pos < end && isHexDigit(text.charCodeAt(pos)))) {
|
|
12391
12402
|
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
12392
12403
|
if (shouldEmitInvalidEscapeError) {
|
|
12393
|
-
|
|
12404
|
+
error2(Diagnostics.Hexadecimal_digit_expected);
|
|
12394
12405
|
}
|
|
12395
12406
|
return text.substring(start3, pos);
|
|
12396
12407
|
}
|
|
@@ -12402,7 +12413,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12402
12413
|
if (!(pos < end && isHexDigit(text.charCodeAt(pos)))) {
|
|
12403
12414
|
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
12404
12415
|
if (shouldEmitInvalidEscapeError) {
|
|
12405
|
-
|
|
12416
|
+
error2(Diagnostics.Hexadecimal_digit_expected);
|
|
12406
12417
|
}
|
|
12407
12418
|
return text.substring(start3, pos);
|
|
12408
12419
|
}
|
|
@@ -12430,19 +12441,19 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12430
12441
|
const escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
|
|
12431
12442
|
let isInvalidExtendedEscape = false;
|
|
12432
12443
|
if (escapedValue < 0) {
|
|
12433
|
-
|
|
12444
|
+
error2(Diagnostics.Hexadecimal_digit_expected);
|
|
12434
12445
|
isInvalidExtendedEscape = true;
|
|
12435
12446
|
} else if (escapedValue > 1114111) {
|
|
12436
|
-
|
|
12447
|
+
error2(Diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive);
|
|
12437
12448
|
isInvalidExtendedEscape = true;
|
|
12438
12449
|
}
|
|
12439
12450
|
if (pos >= end) {
|
|
12440
|
-
|
|
12451
|
+
error2(Diagnostics.Unexpected_end_of_text);
|
|
12441
12452
|
isInvalidExtendedEscape = true;
|
|
12442
12453
|
} else if (text.charCodeAt(pos) === 125 /* closeBrace */) {
|
|
12443
12454
|
pos++;
|
|
12444
12455
|
} else {
|
|
12445
|
-
|
|
12456
|
+
error2(Diagnostics.Unterminated_Unicode_escape_sequence);
|
|
12446
12457
|
isInvalidExtendedEscape = true;
|
|
12447
12458
|
}
|
|
12448
12459
|
if (isInvalidExtendedEscape) {
|
|
@@ -12536,9 +12547,9 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12536
12547
|
separatorAllowed = false;
|
|
12537
12548
|
isPreviousTokenSeparator = true;
|
|
12538
12549
|
} else if (isPreviousTokenSeparator) {
|
|
12539
|
-
|
|
12550
|
+
error2(Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
|
|
12540
12551
|
} else {
|
|
12541
|
-
|
|
12552
|
+
error2(Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
|
|
12542
12553
|
}
|
|
12543
12554
|
pos++;
|
|
12544
12555
|
continue;
|
|
@@ -12552,7 +12563,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12552
12563
|
isPreviousTokenSeparator = false;
|
|
12553
12564
|
}
|
|
12554
12565
|
if (text.charCodeAt(pos - 1) === 95 /* _ */) {
|
|
12555
|
-
|
|
12566
|
+
error2(Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
|
|
12556
12567
|
}
|
|
12557
12568
|
return value;
|
|
12558
12569
|
}
|
|
@@ -12582,7 +12593,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12582
12593
|
const ch = codePointAt(text, pos);
|
|
12583
12594
|
if (pos === 0) {
|
|
12584
12595
|
if (ch === 65533 /* replacementCharacter */) {
|
|
12585
|
-
|
|
12596
|
+
error2(Diagnostics.File_appears_to_be_binary);
|
|
12586
12597
|
pos = end;
|
|
12587
12598
|
return token = 8 /* NonTextFileMarkerTrivia */;
|
|
12588
12599
|
}
|
|
@@ -12773,7 +12784,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12773
12784
|
}
|
|
12774
12785
|
commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(lastLineStart, pos), commentDirectiveRegExMultiLine, lastLineStart);
|
|
12775
12786
|
if (!commentClosed) {
|
|
12776
|
-
|
|
12787
|
+
error2(Diagnostics.Asterisk_Slash_expected);
|
|
12777
12788
|
}
|
|
12778
12789
|
if (skipTrivia2) {
|
|
12779
12790
|
continue;
|
|
@@ -12798,7 +12809,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12798
12809
|
true
|
|
12799
12810
|
);
|
|
12800
12811
|
if (!tokenValue) {
|
|
12801
|
-
|
|
12812
|
+
error2(Diagnostics.Hexadecimal_digit_expected);
|
|
12802
12813
|
tokenValue = "0";
|
|
12803
12814
|
}
|
|
12804
12815
|
tokenValue = "0x" + tokenValue;
|
|
@@ -12811,7 +12822,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12811
12822
|
2
|
|
12812
12823
|
);
|
|
12813
12824
|
if (!tokenValue) {
|
|
12814
|
-
|
|
12825
|
+
error2(Diagnostics.Binary_digit_expected);
|
|
12815
12826
|
tokenValue = "0";
|
|
12816
12827
|
}
|
|
12817
12828
|
tokenValue = "0b" + tokenValue;
|
|
@@ -12824,7 +12835,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12824
12835
|
8
|
|
12825
12836
|
);
|
|
12826
12837
|
if (!tokenValue) {
|
|
12827
|
-
|
|
12838
|
+
error2(Diagnostics.Octal_digit_expected);
|
|
12828
12839
|
tokenValue = "0";
|
|
12829
12840
|
}
|
|
12830
12841
|
tokenValue = "0o" + tokenValue;
|
|
@@ -12850,7 +12861,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12850
12861
|
return token = 27 /* SemicolonToken */;
|
|
12851
12862
|
case 60 /* lessThan */:
|
|
12852
12863
|
if (isConflictMarkerTrivia(text, pos)) {
|
|
12853
|
-
pos = scanConflictMarkerTrivia(text, pos,
|
|
12864
|
+
pos = scanConflictMarkerTrivia(text, pos, error2);
|
|
12854
12865
|
if (skipTrivia2) {
|
|
12855
12866
|
continue;
|
|
12856
12867
|
} else {
|
|
@@ -12873,7 +12884,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12873
12884
|
return token = 30 /* LessThanToken */;
|
|
12874
12885
|
case 61 /* equals */:
|
|
12875
12886
|
if (isConflictMarkerTrivia(text, pos)) {
|
|
12876
|
-
pos = scanConflictMarkerTrivia(text, pos,
|
|
12887
|
+
pos = scanConflictMarkerTrivia(text, pos, error2);
|
|
12877
12888
|
if (skipTrivia2) {
|
|
12878
12889
|
continue;
|
|
12879
12890
|
} else {
|
|
@@ -12893,7 +12904,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12893
12904
|
return token = 64 /* EqualsToken */;
|
|
12894
12905
|
case 62 /* greaterThan */:
|
|
12895
12906
|
if (isConflictMarkerTrivia(text, pos)) {
|
|
12896
|
-
pos = scanConflictMarkerTrivia(text, pos,
|
|
12907
|
+
pos = scanConflictMarkerTrivia(text, pos, error2);
|
|
12897
12908
|
if (skipTrivia2) {
|
|
12898
12909
|
continue;
|
|
12899
12910
|
} else {
|
|
@@ -12931,7 +12942,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12931
12942
|
return token = 19 /* OpenBraceToken */;
|
|
12932
12943
|
case 124 /* bar */:
|
|
12933
12944
|
if (isConflictMarkerTrivia(text, pos)) {
|
|
12934
|
-
pos = scanConflictMarkerTrivia(text, pos,
|
|
12945
|
+
pos = scanConflictMarkerTrivia(text, pos, error2);
|
|
12935
12946
|
if (skipTrivia2) {
|
|
12936
12947
|
continue;
|
|
12937
12948
|
} else {
|
|
@@ -12973,12 +12984,12 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
12973
12984
|
tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts();
|
|
12974
12985
|
return token = getIdentifierToken();
|
|
12975
12986
|
}
|
|
12976
|
-
|
|
12987
|
+
error2(Diagnostics.Invalid_character);
|
|
12977
12988
|
pos++;
|
|
12978
12989
|
return token = 0 /* Unknown */;
|
|
12979
12990
|
case 35 /* hash */:
|
|
12980
12991
|
if (pos !== 0 && text[pos + 1] === "!") {
|
|
12981
|
-
|
|
12992
|
+
error2(Diagnostics.can_only_be_used_at_the_start_of_a_file);
|
|
12982
12993
|
pos++;
|
|
12983
12994
|
return token = 0 /* Unknown */;
|
|
12984
12995
|
}
|
|
@@ -13006,7 +13017,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
13006
13017
|
scanIdentifier(charAfterHash, languageVersion);
|
|
13007
13018
|
} else {
|
|
13008
13019
|
tokenValue = "#";
|
|
13009
|
-
|
|
13020
|
+
error2(Diagnostics.Invalid_character, pos++, charSize(ch));
|
|
13010
13021
|
}
|
|
13011
13022
|
return token = 81 /* PrivateIdentifier */;
|
|
13012
13023
|
default:
|
|
@@ -13022,7 +13033,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
13022
13033
|
continue;
|
|
13023
13034
|
}
|
|
13024
13035
|
const size = charSize(ch);
|
|
13025
|
-
|
|
13036
|
+
error2(Diagnostics.Invalid_character, pos, size);
|
|
13026
13037
|
pos += size;
|
|
13027
13038
|
return token = 0 /* Unknown */;
|
|
13028
13039
|
}
|
|
@@ -13088,13 +13099,13 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
13088
13099
|
while (true) {
|
|
13089
13100
|
if (p >= end) {
|
|
13090
13101
|
tokenFlags |= 4 /* Unterminated */;
|
|
13091
|
-
|
|
13102
|
+
error2(Diagnostics.Unterminated_regular_expression_literal);
|
|
13092
13103
|
break;
|
|
13093
13104
|
}
|
|
13094
13105
|
const ch = text.charCodeAt(p);
|
|
13095
13106
|
if (isLineBreak(ch)) {
|
|
13096
13107
|
tokenFlags |= 4 /* Unterminated */;
|
|
13097
|
-
|
|
13108
|
+
error2(Diagnostics.Unterminated_regular_expression_literal);
|
|
13098
13109
|
break;
|
|
13099
13110
|
}
|
|
13100
13111
|
if (inEscape) {
|
|
@@ -13206,16 +13217,16 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
13206
13217
|
}
|
|
13207
13218
|
if (char === 60 /* lessThan */) {
|
|
13208
13219
|
if (isConflictMarkerTrivia(text, pos)) {
|
|
13209
|
-
pos = scanConflictMarkerTrivia(text, pos,
|
|
13220
|
+
pos = scanConflictMarkerTrivia(text, pos, error2);
|
|
13210
13221
|
return token = 7 /* ConflictMarkerTrivia */;
|
|
13211
13222
|
}
|
|
13212
13223
|
break;
|
|
13213
13224
|
}
|
|
13214
13225
|
if (char === 62 /* greaterThan */) {
|
|
13215
|
-
|
|
13226
|
+
error2(Diagnostics.Unexpected_token_Did_you_mean_or_gt, pos, 1);
|
|
13216
13227
|
}
|
|
13217
13228
|
if (char === 125 /* closeBrace */) {
|
|
13218
|
-
|
|
13229
|
+
error2(Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1);
|
|
13219
13230
|
}
|
|
13220
13231
|
if (isLineBreak(char) && firstNonWhitespace === 0) {
|
|
13221
13232
|
firstNonWhitespace = -1;
|
|
@@ -40112,8 +40123,8 @@ function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, exis
|
|
|
40112
40123
|
const fileName = configFileName || "tsconfig.json";
|
|
40113
40124
|
const diagnosticMessage = Diagnostics.The_files_list_in_config_file_0_is_empty;
|
|
40114
40125
|
const nodeValue = forEachTsConfigPropArray(sourceFile, "files", (property) => property.initializer);
|
|
40115
|
-
const
|
|
40116
|
-
errors.push(
|
|
40126
|
+
const error2 = createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, nodeValue, diagnosticMessage, fileName);
|
|
40127
|
+
errors.push(error2);
|
|
40117
40128
|
} else {
|
|
40118
40129
|
createCompilerDiagnosticOnlyIfJson(Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json");
|
|
40119
40130
|
}
|
|
@@ -40220,8 +40231,8 @@ function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, exis
|
|
|
40220
40231
|
}
|
|
40221
40232
|
}
|
|
40222
40233
|
}
|
|
40223
|
-
function isErrorNoInputFiles(
|
|
40224
|
-
return
|
|
40234
|
+
function isErrorNoInputFiles(error2) {
|
|
40235
|
+
return error2.code === Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2.code;
|
|
40225
40236
|
}
|
|
40226
40237
|
function getErrorForNoInputFiles({ includeSpecs, excludeSpecs }, configFileName) {
|
|
40227
40238
|
return createCompilerDiagnostic(
|
|
@@ -40242,7 +40253,7 @@ function updateErrorForNoInputFiles(fileNames, configFileName, configFileSpecs,
|
|
|
40242
40253
|
if (shouldReportNoInputFiles(fileNames, canJsonReportNoInutFiles)) {
|
|
40243
40254
|
configParseDiagnostics.push(getErrorForNoInputFiles(configFileSpecs, configFileName));
|
|
40244
40255
|
} else {
|
|
40245
|
-
filterMutate(configParseDiagnostics, (
|
|
40256
|
+
filterMutate(configParseDiagnostics, (error2) => !isErrorNoInputFiles(error2));
|
|
40246
40257
|
}
|
|
40247
40258
|
return existingErrors !== configParseDiagnostics.length;
|
|
40248
40259
|
}
|
|
@@ -41386,7 +41397,7 @@ function compilerOptionValueToString(value) {
|
|
|
41386
41397
|
return str + "}";
|
|
41387
41398
|
}
|
|
41388
41399
|
function getKeyForCompilerOptions(options, affectingOptionDeclarations) {
|
|
41389
|
-
return affectingOptionDeclarations.map((option) => compilerOptionValueToString(getCompilerOptionValue(options, option))).join("|") +
|
|
41400
|
+
return affectingOptionDeclarations.map((option) => compilerOptionValueToString(getCompilerOptionValue(options, option))).join("|") + `|${options.pathsBasePath}`;
|
|
41390
41401
|
}
|
|
41391
41402
|
function createCacheWithRedirects(ownOptions) {
|
|
41392
41403
|
const redirectsMap = /* @__PURE__ */ new Map();
|
|
@@ -47309,10 +47320,11 @@ var CheckMode = /* @__PURE__ */ ((CheckMode3) => {
|
|
|
47309
47320
|
CheckMode3[CheckMode3["Inferential"] = 2] = "Inferential";
|
|
47310
47321
|
CheckMode3[CheckMode3["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
47311
47322
|
CheckMode3[CheckMode3["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
47312
|
-
CheckMode3[CheckMode3["
|
|
47313
|
-
CheckMode3[CheckMode3["
|
|
47314
|
-
CheckMode3[CheckMode3["
|
|
47315
|
-
CheckMode3[CheckMode3["
|
|
47323
|
+
CheckMode3[CheckMode3["SkipAddingIntraExpressionSites"] = 16] = "SkipAddingIntraExpressionSites";
|
|
47324
|
+
CheckMode3[CheckMode3["IsForSignatureHelp"] = 32] = "IsForSignatureHelp";
|
|
47325
|
+
CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 64] = "IsForStringLiteralArgumentCompletions";
|
|
47326
|
+
CheckMode3[CheckMode3["RestBindingElement"] = 128] = "RestBindingElement";
|
|
47327
|
+
CheckMode3[CheckMode3["TypeOnly"] = 256] = "TypeOnly";
|
|
47316
47328
|
return CheckMode3;
|
|
47317
47329
|
})(CheckMode || {});
|
|
47318
47330
|
var SignatureCheckMode = /* @__PURE__ */ ((SignatureCheckMode3) => {
|
|
@@ -47592,9 +47604,9 @@ function createTypeChecker(host) {
|
|
|
47592
47604
|
candidatesOutArray,
|
|
47593
47605
|
/*argumentCount*/
|
|
47594
47606
|
void 0,
|
|
47595
|
-
|
|
47607
|
+
64 /* IsForStringLiteralArgumentCompletions */
|
|
47596
47608
|
)),
|
|
47597
|
-
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount,
|
|
47609
|
+
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 32 /* IsForSignatureHelp */)),
|
|
47598
47610
|
getExpandedParameters,
|
|
47599
47611
|
hasEffectiveRestParameter,
|
|
47600
47612
|
containsArgumentsReference,
|
|
@@ -48318,14 +48330,14 @@ function createTypeChecker(host) {
|
|
|
48318
48330
|
}
|
|
48319
48331
|
}
|
|
48320
48332
|
function errorSkippedOn(key, location, message, ...args) {
|
|
48321
|
-
const diagnostic =
|
|
48333
|
+
const diagnostic = error2(location, message, ...args);
|
|
48322
48334
|
diagnostic.skippedOn = key;
|
|
48323
48335
|
return diagnostic;
|
|
48324
48336
|
}
|
|
48325
48337
|
function createError(location, message, ...args) {
|
|
48326
48338
|
return location ? createDiagnosticForNode(location, message, ...args) : createCompilerDiagnostic(message, ...args);
|
|
48327
48339
|
}
|
|
48328
|
-
function
|
|
48340
|
+
function error2(location, message, ...args) {
|
|
48329
48341
|
const diagnostic = createError(location, message, ...args);
|
|
48330
48342
|
diagnostics.add(diagnostic);
|
|
48331
48343
|
return diagnostic;
|
|
@@ -48349,7 +48361,7 @@ function createTypeChecker(host) {
|
|
|
48349
48361
|
addErrorOrSuggestion(isError, "message" in message ? createDiagnosticForNode(location, message, ...args) : createDiagnosticForNodeFromMessageChain(getSourceFileOfNode(location), location, message));
|
|
48350
48362
|
}
|
|
48351
48363
|
function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, ...args) {
|
|
48352
|
-
const diagnostic =
|
|
48364
|
+
const diagnostic = error2(location, message, ...args);
|
|
48353
48365
|
if (maybeMissingAwait) {
|
|
48354
48366
|
const related = createDiagnosticForNode(location, Diagnostics.Did_you_forget_to_use_await);
|
|
48355
48367
|
addRelatedInfo(diagnostic, related);
|
|
@@ -48495,7 +48507,7 @@ function createTypeChecker(host) {
|
|
|
48495
48507
|
}
|
|
48496
48508
|
} else if (target.flags & 1024 /* NamespaceModule */) {
|
|
48497
48509
|
if (target !== globalThisSymbol) {
|
|
48498
|
-
|
|
48510
|
+
error2(
|
|
48499
48511
|
source.declarations && getNameOfDeclaration(source.declarations[0]),
|
|
48500
48512
|
Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity,
|
|
48501
48513
|
symbolToString(target)
|
|
@@ -48625,7 +48637,7 @@ function createTypeChecker(host) {
|
|
|
48625
48637
|
mergeSymbol(mainModule, moduleAugmentation.symbol);
|
|
48626
48638
|
}
|
|
48627
48639
|
} else {
|
|
48628
|
-
|
|
48640
|
+
error2(moduleName, Diagnostics.Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity, moduleName.text);
|
|
48629
48641
|
}
|
|
48630
48642
|
}
|
|
48631
48643
|
}
|
|
@@ -48952,7 +48964,7 @@ function createTypeChecker(host) {
|
|
|
48952
48964
|
case 265 /* EnumDeclaration */:
|
|
48953
48965
|
if (result = lookup(((_c = getSymbolOfDeclaration(location)) == null ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* EnumMember */)) {
|
|
48954
48966
|
if (nameNotFoundMessage && getIsolatedModules(compilerOptions) && !(location.flags & 16777216 /* Ambient */) && getSourceFileOfNode(location) !== getSourceFileOfNode(result.valueDeclaration)) {
|
|
48955
|
-
|
|
48967
|
+
error2(
|
|
48956
48968
|
errorLocation,
|
|
48957
48969
|
Diagnostics.Cannot_access_0_from_another_file_without_qualification_when_1_is_enabled_Use_2_instead,
|
|
48958
48970
|
unescapeLeadingUnderscores(name),
|
|
@@ -48984,7 +48996,7 @@ function createTypeChecker(host) {
|
|
|
48984
48996
|
}
|
|
48985
48997
|
if (lastLocation && isStatic(lastLocation)) {
|
|
48986
48998
|
if (nameNotFoundMessage) {
|
|
48987
|
-
|
|
48999
|
+
error2(errorLocation, Diagnostics.Static_members_cannot_reference_class_type_parameters);
|
|
48988
49000
|
}
|
|
48989
49001
|
return void 0;
|
|
48990
49002
|
}
|
|
@@ -49003,7 +49015,7 @@ function createTypeChecker(host) {
|
|
|
49003
49015
|
const container = location.parent.parent;
|
|
49004
49016
|
if (isClassLike(container) && (result = lookup(getSymbolOfDeclaration(container).members, name, meaning & 788968 /* Type */))) {
|
|
49005
49017
|
if (nameNotFoundMessage) {
|
|
49006
|
-
|
|
49018
|
+
error2(errorLocation, Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters);
|
|
49007
49019
|
}
|
|
49008
49020
|
return void 0;
|
|
49009
49021
|
}
|
|
@@ -49014,7 +49026,7 @@ function createTypeChecker(host) {
|
|
|
49014
49026
|
if (isClassLike(grandparent) || grandparent.kind === 263 /* InterfaceDeclaration */) {
|
|
49015
49027
|
if (result = lookup(getSymbolOfDeclaration(grandparent).members, name, meaning & 788968 /* Type */)) {
|
|
49016
49028
|
if (nameNotFoundMessage) {
|
|
49017
|
-
|
|
49029
|
+
error2(errorLocation, Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type);
|
|
49018
49030
|
}
|
|
49019
49031
|
return void 0;
|
|
49020
49032
|
}
|
|
@@ -49125,7 +49137,7 @@ function createTypeChecker(host) {
|
|
|
49125
49137
|
}
|
|
49126
49138
|
function checkAndReportErrorForInvalidInitializer() {
|
|
49127
49139
|
if (propertyWithInvalidInitializer && !(useDefineForClassFields && getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */)) {
|
|
49128
|
-
|
|
49140
|
+
error2(
|
|
49129
49141
|
errorLocation,
|
|
49130
49142
|
errorLocation && propertyWithInvalidInitializer.type && textRangeContainsPositionInclusive(propertyWithInvalidInitializer.type, errorLocation.pos) ? Diagnostics.Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor : Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor,
|
|
49131
49143
|
declarationNameToString(propertyWithInvalidInitializer.name),
|
|
@@ -49145,7 +49157,7 @@ function createTypeChecker(host) {
|
|
|
49145
49157
|
if (nameArg) {
|
|
49146
49158
|
suggestedLib = getSuggestedLibForNonExistentName(nameArg);
|
|
49147
49159
|
if (suggestedLib) {
|
|
49148
|
-
|
|
49160
|
+
error2(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), suggestedLib);
|
|
49149
49161
|
}
|
|
49150
49162
|
}
|
|
49151
49163
|
if (!suggestedLib && getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
|
|
@@ -49174,7 +49186,7 @@ function createTypeChecker(host) {
|
|
|
49174
49186
|
}
|
|
49175
49187
|
}
|
|
49176
49188
|
if (!suggestion && !suggestedLib && nameArg) {
|
|
49177
|
-
|
|
49189
|
+
error2(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
|
|
49178
49190
|
}
|
|
49179
49191
|
suggestionCount++;
|
|
49180
49192
|
}
|
|
@@ -49202,9 +49214,9 @@ function createTypeChecker(host) {
|
|
|
49202
49214
|
const candidate = getMergedSymbol(getLateBoundSymbol(result));
|
|
49203
49215
|
const root = getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName);
|
|
49204
49216
|
if (candidate === getSymbolOfDeclaration(associatedDeclarationForContainingInitializerOrBindingName)) {
|
|
49205
|
-
|
|
49217
|
+
error2(errorLocation, Diagnostics.Parameter_0_cannot_reference_itself, declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name));
|
|
49206
49218
|
} else if (candidate.valueDeclaration && candidate.valueDeclaration.pos > associatedDeclarationForContainingInitializerOrBindingName.pos && root.parent.locals && lookup(root.parent.locals, candidate.escapedName, meaning) === candidate) {
|
|
49207
|
-
|
|
49219
|
+
error2(errorLocation, Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), declarationNameToString(errorLocation));
|
|
49208
49220
|
}
|
|
49209
49221
|
}
|
|
49210
49222
|
if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */ && !(result.flags & 111551 /* Value */) && !isValidTypeOnlyAliasUseSite(errorLocation)) {
|
|
@@ -49213,7 +49225,7 @@ function createTypeChecker(host) {
|
|
|
49213
49225
|
const message = typeOnlyDeclaration.kind === 280 /* ExportSpecifier */ || typeOnlyDeclaration.kind === 277 /* ExportDeclaration */ || typeOnlyDeclaration.kind === 279 /* NamespaceExport */ ? Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type : Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
|
|
49214
49226
|
const unescapedName = unescapeLeadingUnderscores(name);
|
|
49215
49227
|
addTypeOnlyDeclarationRelatedInfo(
|
|
49216
|
-
|
|
49228
|
+
error2(errorLocation, message, unescapedName),
|
|
49217
49229
|
typeOnlyDeclaration,
|
|
49218
49230
|
unescapedName
|
|
49219
49231
|
);
|
|
@@ -49296,13 +49308,13 @@ function createTypeChecker(host) {
|
|
|
49296
49308
|
}
|
|
49297
49309
|
const constructorType = getTypeOfSymbol(classSymbol);
|
|
49298
49310
|
if (getPropertyOfType(constructorType, name)) {
|
|
49299
|
-
|
|
49311
|
+
error2(errorLocation, Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0, diagnosticName(nameArg), symbolToString(classSymbol));
|
|
49300
49312
|
return true;
|
|
49301
49313
|
}
|
|
49302
49314
|
if (location === container && !isStatic(location)) {
|
|
49303
49315
|
const instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType;
|
|
49304
49316
|
if (getPropertyOfType(instanceType, name)) {
|
|
49305
|
-
|
|
49317
|
+
error2(errorLocation, Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, diagnosticName(nameArg));
|
|
49306
49318
|
return true;
|
|
49307
49319
|
}
|
|
49308
49320
|
}
|
|
@@ -49319,7 +49331,7 @@ function createTypeChecker(host) {
|
|
|
49319
49331
|
/*ignoreErrors*/
|
|
49320
49332
|
true
|
|
49321
49333
|
)) {
|
|
49322
|
-
|
|
49334
|
+
error2(errorLocation, Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, getTextOfNode(expression));
|
|
49323
49335
|
return true;
|
|
49324
49336
|
}
|
|
49325
49337
|
return false;
|
|
@@ -49358,7 +49370,7 @@ function createTypeChecker(host) {
|
|
|
49358
49370
|
const propName = parent2.right.escapedText;
|
|
49359
49371
|
const propType = getPropertyOfType(getDeclaredTypeOfSymbol(symbol), propName);
|
|
49360
49372
|
if (propType) {
|
|
49361
|
-
|
|
49373
|
+
error2(
|
|
49362
49374
|
parent2,
|
|
49363
49375
|
Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1,
|
|
49364
49376
|
unescapeLeadingUnderscores(name),
|
|
@@ -49367,7 +49379,7 @@ function createTypeChecker(host) {
|
|
|
49367
49379
|
return true;
|
|
49368
49380
|
}
|
|
49369
49381
|
}
|
|
49370
|
-
|
|
49382
|
+
error2(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here, unescapeLeadingUnderscores(name));
|
|
49371
49383
|
return true;
|
|
49372
49384
|
}
|
|
49373
49385
|
}
|
|
@@ -49387,7 +49399,7 @@ function createTypeChecker(host) {
|
|
|
49387
49399
|
false
|
|
49388
49400
|
));
|
|
49389
49401
|
if (symbol && !(symbol.flags & 1920 /* Namespace */)) {
|
|
49390
|
-
|
|
49402
|
+
error2(errorLocation, Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, unescapeLeadingUnderscores(name));
|
|
49391
49403
|
return true;
|
|
49392
49404
|
}
|
|
49393
49405
|
}
|
|
@@ -49398,7 +49410,7 @@ function createTypeChecker(host) {
|
|
|
49398
49410
|
}
|
|
49399
49411
|
function checkAndReportErrorForExportingPrimitiveType(errorLocation, name) {
|
|
49400
49412
|
if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 280 /* ExportSpecifier */) {
|
|
49401
|
-
|
|
49413
|
+
error2(errorLocation, Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name);
|
|
49402
49414
|
return true;
|
|
49403
49415
|
}
|
|
49404
49416
|
return false;
|
|
@@ -49407,9 +49419,9 @@ function createTypeChecker(host) {
|
|
|
49407
49419
|
if (meaning & 111551 /* Value */) {
|
|
49408
49420
|
if (isPrimitiveTypeName(name)) {
|
|
49409
49421
|
if (isExtendedByInterface(errorLocation)) {
|
|
49410
|
-
|
|
49422
|
+
error2(errorLocation, Diagnostics.An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes, unescapeLeadingUnderscores(name));
|
|
49411
49423
|
} else {
|
|
49412
|
-
|
|
49424
|
+
error2(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, unescapeLeadingUnderscores(name));
|
|
49413
49425
|
}
|
|
49414
49426
|
return true;
|
|
49415
49427
|
}
|
|
@@ -49428,11 +49440,11 @@ function createTypeChecker(host) {
|
|
|
49428
49440
|
if (symbol && allFlags !== void 0 && !(allFlags & 111551 /* Value */)) {
|
|
49429
49441
|
const rawName = unescapeLeadingUnderscores(name);
|
|
49430
49442
|
if (isES2015OrLaterConstructorName(name)) {
|
|
49431
|
-
|
|
49443
|
+
error2(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later, rawName);
|
|
49432
49444
|
} else if (maybeMappedType(errorLocation, symbol)) {
|
|
49433
|
-
|
|
49445
|
+
error2(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Did_you_mean_to_use_1_in_0, rawName, rawName === "K" ? "P" : "K");
|
|
49434
49446
|
} else {
|
|
49435
|
-
|
|
49447
|
+
error2(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, rawName);
|
|
49436
49448
|
}
|
|
49437
49449
|
return true;
|
|
49438
49450
|
}
|
|
@@ -49488,7 +49500,7 @@ function createTypeChecker(host) {
|
|
|
49488
49500
|
false
|
|
49489
49501
|
));
|
|
49490
49502
|
if (symbol) {
|
|
49491
|
-
|
|
49503
|
+
error2(
|
|
49492
49504
|
errorLocation,
|
|
49493
49505
|
Diagnostics.Cannot_use_namespace_0_as_a_value,
|
|
49494
49506
|
unescapeLeadingUnderscores(name)
|
|
@@ -49508,7 +49520,7 @@ function createTypeChecker(host) {
|
|
|
49508
49520
|
false
|
|
49509
49521
|
));
|
|
49510
49522
|
if (symbol) {
|
|
49511
|
-
|
|
49523
|
+
error2(errorLocation, Diagnostics.Cannot_use_namespace_0_as_a_type, unescapeLeadingUnderscores(name));
|
|
49512
49524
|
return true;
|
|
49513
49525
|
}
|
|
49514
49526
|
}
|
|
@@ -49529,11 +49541,11 @@ function createTypeChecker(host) {
|
|
|
49529
49541
|
let diagnosticMessage;
|
|
49530
49542
|
const declarationName = declarationNameToString(getNameOfDeclaration(declaration));
|
|
49531
49543
|
if (result.flags & 2 /* BlockScopedVariable */) {
|
|
49532
|
-
diagnosticMessage =
|
|
49544
|
+
diagnosticMessage = error2(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName);
|
|
49533
49545
|
} else if (result.flags & 32 /* Class */) {
|
|
49534
|
-
diagnosticMessage =
|
|
49546
|
+
diagnosticMessage = error2(errorLocation, Diagnostics.Class_0_used_before_its_declaration, declarationName);
|
|
49535
49547
|
} else if (result.flags & 256 /* RegularEnum */) {
|
|
49536
|
-
diagnosticMessage =
|
|
49548
|
+
diagnosticMessage = error2(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationName);
|
|
49537
49549
|
}
|
|
49538
49550
|
if (diagnosticMessage) {
|
|
49539
49551
|
addRelatedInfo(
|
|
@@ -49608,7 +49620,7 @@ function createTypeChecker(host) {
|
|
|
49608
49620
|
const message = isExport ? Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type : Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type;
|
|
49609
49621
|
const relatedMessage = isExport ? Diagnostics._0_was_exported_here : Diagnostics._0_was_imported_here;
|
|
49610
49622
|
const name = typeOnlyDeclaration.kind === 277 /* ExportDeclaration */ ? "*" : unescapeLeadingUnderscores(typeOnlyDeclaration.name.escapedText);
|
|
49611
|
-
addRelatedInfo(
|
|
49623
|
+
addRelatedInfo(error2(node.moduleReference, message), createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, name));
|
|
49612
49624
|
}
|
|
49613
49625
|
}
|
|
49614
49626
|
function resolveExportByName(moduleSymbol, name, sourceNode, dontResolveAlias) {
|
|
@@ -49713,7 +49725,7 @@ function createTypeChecker(host) {
|
|
|
49713
49725
|
const compilerOptionName = moduleKind >= 5 /* ES2015 */ ? "allowSyntheticDefaultImports" : "esModuleInterop";
|
|
49714
49726
|
const exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */);
|
|
49715
49727
|
const exportAssignment = exportEqualsSymbol.valueDeclaration;
|
|
49716
|
-
const err =
|
|
49728
|
+
const err = error2(node.name, Diagnostics.Module_0_can_only_be_default_imported_using_the_1_flag, symbolToString(moduleSymbol), compilerOptionName);
|
|
49717
49729
|
if (exportAssignment) {
|
|
49718
49730
|
addRelatedInfo(err, createDiagnosticForNode(
|
|
49719
49731
|
exportAssignment,
|
|
@@ -49766,14 +49778,14 @@ function createTypeChecker(host) {
|
|
|
49766
49778
|
function reportNonDefaultExport(moduleSymbol, node) {
|
|
49767
49779
|
var _a, _b, _c;
|
|
49768
49780
|
if ((_a = moduleSymbol.exports) == null ? void 0 : _a.has(node.symbol.escapedName)) {
|
|
49769
|
-
|
|
49781
|
+
error2(
|
|
49770
49782
|
node.name,
|
|
49771
49783
|
Diagnostics.Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead,
|
|
49772
49784
|
symbolToString(moduleSymbol),
|
|
49773
49785
|
symbolToString(node.symbol)
|
|
49774
49786
|
);
|
|
49775
49787
|
} else {
|
|
49776
|
-
const diagnostic =
|
|
49788
|
+
const diagnostic = error2(node.name, Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol));
|
|
49777
49789
|
const exportStar = (_b = moduleSymbol.exports) == null ? void 0 : _b.get("__export" /* ExportStar */);
|
|
49778
49790
|
if (exportStar) {
|
|
49779
49791
|
const defaultExport = (_c = exportStar.declarations) == null ? void 0 : _c.find((decl) => {
|
|
@@ -49924,7 +49936,7 @@ function createTypeChecker(host) {
|
|
|
49924
49936
|
const suggestion = getSuggestedSymbolForNonexistentModule(name, targetSymbol);
|
|
49925
49937
|
if (suggestion !== void 0) {
|
|
49926
49938
|
const suggestionName = symbolToString(suggestion);
|
|
49927
|
-
const diagnostic =
|
|
49939
|
+
const diagnostic = error2(name, Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2, moduleName, declarationName, suggestionName);
|
|
49928
49940
|
if (suggestion.valueDeclaration) {
|
|
49929
49941
|
addRelatedInfo(
|
|
49930
49942
|
diagnostic,
|
|
@@ -49933,7 +49945,7 @@ function createTypeChecker(host) {
|
|
|
49933
49945
|
}
|
|
49934
49946
|
} else {
|
|
49935
49947
|
if ((_a = moduleSymbol.exports) == null ? void 0 : _a.has("default" /* Default */)) {
|
|
49936
|
-
|
|
49948
|
+
error2(
|
|
49937
49949
|
name,
|
|
49938
49950
|
Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead,
|
|
49939
49951
|
moduleName,
|
|
@@ -49951,10 +49963,10 @@ function createTypeChecker(host) {
|
|
|
49951
49963
|
if (localSymbol) {
|
|
49952
49964
|
const exportedEqualsSymbol = exports == null ? void 0 : exports.get("export=" /* ExportEquals */);
|
|
49953
49965
|
if (exportedEqualsSymbol) {
|
|
49954
|
-
getSymbolIfSameReference(exportedEqualsSymbol, localSymbol) ? reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) :
|
|
49966
|
+
getSymbolIfSameReference(exportedEqualsSymbol, localSymbol) ? reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) : error2(name, Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName);
|
|
49955
49967
|
} else {
|
|
49956
49968
|
const exportedSymbol = exports ? find(symbolsToArray(exports), (symbol) => !!getSymbolIfSameReference(symbol, localSymbol)) : void 0;
|
|
49957
|
-
const diagnostic = exportedSymbol ?
|
|
49969
|
+
const diagnostic = exportedSymbol ? error2(name, Diagnostics.Module_0_declares_1_locally_but_it_is_exported_as_2, moduleName, declarationName, symbolToString(exportedSymbol)) : error2(name, Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported, moduleName, declarationName);
|
|
49958
49970
|
if (localSymbol.declarations) {
|
|
49959
49971
|
addRelatedInfo(
|
|
49960
49972
|
diagnostic,
|
|
@@ -49963,20 +49975,20 @@ function createTypeChecker(host) {
|
|
|
49963
49975
|
}
|
|
49964
49976
|
}
|
|
49965
49977
|
} else {
|
|
49966
|
-
|
|
49978
|
+
error2(name, Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName);
|
|
49967
49979
|
}
|
|
49968
49980
|
}
|
|
49969
49981
|
function reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) {
|
|
49970
49982
|
if (moduleKind >= 5 /* ES2015 */) {
|
|
49971
49983
|
const message = getESModuleInterop(compilerOptions) ? Diagnostics._0_can_only_be_imported_by_using_a_default_import : Diagnostics._0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
|
|
49972
|
-
|
|
49984
|
+
error2(name, message, declarationName);
|
|
49973
49985
|
} else {
|
|
49974
49986
|
if (isInJSFile(node)) {
|
|
49975
49987
|
const message = getESModuleInterop(compilerOptions) ? Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import : Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
|
|
49976
|
-
|
|
49988
|
+
error2(name, message, declarationName);
|
|
49977
49989
|
} else {
|
|
49978
49990
|
const message = getESModuleInterop(compilerOptions) ? Diagnostics._0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import : Diagnostics._0_can_only_be_imported_by_using_import_1_require_2_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
|
|
49979
|
-
|
|
49991
|
+
error2(name, message, declarationName, declarationName, moduleName);
|
|
49980
49992
|
}
|
|
49981
49993
|
}
|
|
49982
49994
|
}
|
|
@@ -50146,7 +50158,7 @@ function createTypeChecker(host) {
|
|
|
50146
50158
|
if (links.aliasTarget === resolvingSymbol) {
|
|
50147
50159
|
links.aliasTarget = target || unknownSymbol;
|
|
50148
50160
|
} else {
|
|
50149
|
-
|
|
50161
|
+
error2(node, Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol));
|
|
50150
50162
|
}
|
|
50151
50163
|
} else if (links.aliasTarget === resolvingSymbol) {
|
|
50152
50164
|
links.aliasTarget = unknownSymbol;
|
|
@@ -50382,13 +50394,13 @@ function createTypeChecker(host) {
|
|
|
50382
50394
|
const declarationName = declarationNameToString(right);
|
|
50383
50395
|
const suggestionForNonexistentModule = getSuggestedSymbolForNonexistentModule(right, namespace);
|
|
50384
50396
|
if (suggestionForNonexistentModule) {
|
|
50385
|
-
|
|
50397
|
+
error2(right, Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2, namespaceName, declarationName, symbolToString(suggestionForNonexistentModule));
|
|
50386
50398
|
return void 0;
|
|
50387
50399
|
}
|
|
50388
50400
|
const containingQualifiedName = isQualifiedName(name) && getContainingQualifiedNameNode(name);
|
|
50389
50401
|
const canSuggestTypeof = globalObjectType && meaning & 788968 /* Type */ && containingQualifiedName && !isTypeOfExpression(containingQualifiedName.parent) && tryGetQualifiedNameAsValue(containingQualifiedName);
|
|
50390
50402
|
if (canSuggestTypeof) {
|
|
50391
|
-
|
|
50403
|
+
error2(
|
|
50392
50404
|
containingQualifiedName,
|
|
50393
50405
|
Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0,
|
|
50394
50406
|
entityNameToString(containingQualifiedName)
|
|
@@ -50398,7 +50410,7 @@ function createTypeChecker(host) {
|
|
|
50398
50410
|
if (meaning & 1920 /* Namespace */ && isQualifiedName(name.parent)) {
|
|
50399
50411
|
const exportedTypeSymbol = getMergedSymbol(getSymbol2(getExportsOfSymbol(namespace), right.escapedText, 788968 /* Type */));
|
|
50400
50412
|
if (exportedTypeSymbol) {
|
|
50401
|
-
|
|
50413
|
+
error2(
|
|
50402
50414
|
name.parent.right,
|
|
50403
50415
|
Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1,
|
|
50404
50416
|
symbolToString(exportedTypeSymbol),
|
|
@@ -50407,7 +50419,7 @@ function createTypeChecker(host) {
|
|
|
50407
50419
|
return void 0;
|
|
50408
50420
|
}
|
|
50409
50421
|
}
|
|
50410
|
-
|
|
50422
|
+
error2(right, Diagnostics.Namespace_0_has_no_exported_member_1, namespaceName, declarationName);
|
|
50411
50423
|
}
|
|
50412
50424
|
return void 0;
|
|
50413
50425
|
}
|
|
@@ -50512,7 +50524,7 @@ function createTypeChecker(host) {
|
|
|
50512
50524
|
if (startsWith(moduleReference, "@types/")) {
|
|
50513
50525
|
const diag2 = Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
|
|
50514
50526
|
const withoutAtTypePrefix = removePrefix(moduleReference, "@types/");
|
|
50515
|
-
|
|
50527
|
+
error2(errorNode, diag2, withoutAtTypePrefix, moduleReference);
|
|
50516
50528
|
}
|
|
50517
50529
|
const ambientModule = tryFindAmbientModule(
|
|
50518
50530
|
moduleReference,
|
|
@@ -50531,12 +50543,12 @@ function createTypeChecker(host) {
|
|
|
50531
50543
|
const sourceFile = resolvedModule && (!resolutionDiagnostic || resolutionDiagnostic === Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set) && host.getSourceFile(resolvedModule.resolvedFileName);
|
|
50532
50544
|
if (sourceFile) {
|
|
50533
50545
|
if (resolutionDiagnostic) {
|
|
50534
|
-
|
|
50546
|
+
error2(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName);
|
|
50535
50547
|
}
|
|
50536
50548
|
if (resolvedModule.resolvedUsingTsExtension && isDeclarationFileName(moduleReference)) {
|
|
50537
50549
|
const importOrExport = ((_g = findAncestor(location, isImportDeclaration)) == null ? void 0 : _g.importClause) || findAncestor(location, or(isImportEqualsDeclaration, isExportDeclaration));
|
|
50538
50550
|
if (importOrExport && !importOrExport.isTypeOnly || findAncestor(location, isImportCall)) {
|
|
50539
|
-
|
|
50551
|
+
error2(
|
|
50540
50552
|
errorNode,
|
|
50541
50553
|
Diagnostics.A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_file_0_instead,
|
|
50542
50554
|
getSuggestedImportSource(Debug.checkDefined(tryExtractTSExtension(moduleReference)))
|
|
@@ -50544,7 +50556,7 @@ function createTypeChecker(host) {
|
|
|
50544
50556
|
}
|
|
50545
50557
|
} else if (resolvedModule.resolvedUsingTsExtension && !shouldAllowImportingTsExtension(compilerOptions, currentSourceFile.fileName)) {
|
|
50546
50558
|
const tsExtension = Debug.checkDefined(tryExtractTSExtension(moduleReference));
|
|
50547
|
-
|
|
50559
|
+
error2(errorNode, Diagnostics.An_import_path_can_only_end_with_a_0_extension_when_allowImportingTsExtensions_is_enabled, tsExtension);
|
|
50548
50560
|
}
|
|
50549
50561
|
if (sourceFile.symbol) {
|
|
50550
50562
|
if (resolvedModule.isExternalLibraryImport && !resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
|
|
@@ -50564,7 +50576,7 @@ function createTypeChecker(host) {
|
|
|
50564
50576
|
const overrideClause = overrideClauseHost && isImportTypeNode(overrideClauseHost) ? (_h = overrideClauseHost.assertions) == null ? void 0 : _h.assertClause : overrideClauseHost == null ? void 0 : overrideClauseHost.assertClause;
|
|
50565
50577
|
if (isSyncImport && sourceFile.impliedNodeFormat === 99 /* ESNext */ && !getResolutionModeOverrideForClause(overrideClause)) {
|
|
50566
50578
|
if (findAncestor(location, isImportEqualsDeclaration)) {
|
|
50567
|
-
|
|
50579
|
+
error2(errorNode, Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead, moduleReference);
|
|
50568
50580
|
} else {
|
|
50569
50581
|
let diagnosticDetails;
|
|
50570
50582
|
const ext = tryGetExtensionFromPath2(currentSourceFile.fileName);
|
|
@@ -50616,7 +50628,7 @@ function createTypeChecker(host) {
|
|
|
50616
50628
|
return getMergedSymbol(sourceFile.symbol);
|
|
50617
50629
|
}
|
|
50618
50630
|
if (moduleNotFoundError) {
|
|
50619
|
-
|
|
50631
|
+
error2(errorNode, Diagnostics.File_0_is_not_a_module, sourceFile.fileName);
|
|
50620
50632
|
}
|
|
50621
50633
|
return void 0;
|
|
50622
50634
|
}
|
|
@@ -50633,7 +50645,7 @@ function createTypeChecker(host) {
|
|
|
50633
50645
|
if (resolvedModule && !resolutionExtensionIsTSOrJson(resolvedModule.extension) && resolutionDiagnostic === void 0 || resolutionDiagnostic === Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type) {
|
|
50634
50646
|
if (isForAugmentation) {
|
|
50635
50647
|
const diag2 = Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented;
|
|
50636
|
-
|
|
50648
|
+
error2(errorNode, diag2, moduleReference, resolvedModule.resolvedFileName);
|
|
50637
50649
|
} else {
|
|
50638
50650
|
errorOnImplicitAnyModule(
|
|
50639
50651
|
/*isError*/
|
|
@@ -50651,31 +50663,31 @@ function createTypeChecker(host) {
|
|
|
50651
50663
|
if (resolvedModule) {
|
|
50652
50664
|
const redirect = host.getProjectReferenceRedirect(resolvedModule.resolvedFileName);
|
|
50653
50665
|
if (redirect) {
|
|
50654
|
-
|
|
50666
|
+
error2(errorNode, Diagnostics.Output_file_0_has_not_been_built_from_source_file_1, redirect, resolvedModule.resolvedFileName);
|
|
50655
50667
|
return void 0;
|
|
50656
50668
|
}
|
|
50657
50669
|
}
|
|
50658
50670
|
if (resolutionDiagnostic) {
|
|
50659
|
-
|
|
50671
|
+
error2(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName);
|
|
50660
50672
|
} else {
|
|
50661
50673
|
const isExtensionlessRelativePathImport = pathIsRelative(moduleReference) && !hasExtension(moduleReference);
|
|
50662
50674
|
const resolutionIsNode16OrNext = moduleResolutionKind === 3 /* Node16 */ || moduleResolutionKind === 99 /* NodeNext */;
|
|
50663
50675
|
if (!getResolveJsonModule(compilerOptions) && fileExtensionIs(moduleReference, ".json" /* Json */) && moduleResolutionKind !== 1 /* Classic */ && hasJsonModuleEmitEnabled(compilerOptions)) {
|
|
50664
|
-
|
|
50676
|
+
error2(errorNode, Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
|
|
50665
50677
|
} else if (mode === 99 /* ESNext */ && resolutionIsNode16OrNext && isExtensionlessRelativePathImport) {
|
|
50666
50678
|
const absoluteRef = getNormalizedAbsolutePath(moduleReference, getDirectoryPath(currentSourceFile.path));
|
|
50667
50679
|
const suggestedExt = (_i = suggestedExtensions.find(([actualExt, _importExt]) => host.fileExists(absoluteRef + actualExt))) == null ? void 0 : _i[1];
|
|
50668
50680
|
if (suggestedExt) {
|
|
50669
|
-
|
|
50681
|
+
error2(
|
|
50670
50682
|
errorNode,
|
|
50671
50683
|
Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0,
|
|
50672
50684
|
moduleReference + suggestedExt
|
|
50673
50685
|
);
|
|
50674
50686
|
} else {
|
|
50675
|
-
|
|
50687
|
+
error2(errorNode, Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path);
|
|
50676
50688
|
}
|
|
50677
50689
|
} else {
|
|
50678
|
-
|
|
50690
|
+
error2(errorNode, moduleNotFoundError, moduleReference);
|
|
50679
50691
|
}
|
|
50680
50692
|
}
|
|
50681
50693
|
}
|
|
@@ -50741,7 +50753,7 @@ function createTypeChecker(host) {
|
|
|
50741
50753
|
if (!dontResolveAlias && symbol) {
|
|
50742
50754
|
if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !getDeclarationOfKind(symbol, 311 /* SourceFile */)) {
|
|
50743
50755
|
const compilerOptionName = moduleKind >= 5 /* ES2015 */ ? "allowSyntheticDefaultImports" : "esModuleInterop";
|
|
50744
|
-
|
|
50756
|
+
error2(referencingLocation, Diagnostics.This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_referencing_its_default_export, compilerOptionName);
|
|
50745
50757
|
return symbol;
|
|
50746
50758
|
}
|
|
50747
50759
|
const referenceParent = referencingLocation.parent;
|
|
@@ -51125,7 +51137,7 @@ function createTypeChecker(host) {
|
|
|
51125
51137
|
function createIntrinsicType(kind, intrinsicName, objectFlags = 0 /* None */) {
|
|
51126
51138
|
const type = createType(kind);
|
|
51127
51139
|
type.intrinsicName = intrinsicName;
|
|
51128
|
-
type.objectFlags = objectFlags
|
|
51140
|
+
type.objectFlags = objectFlags | 524288 /* CouldContainTypeVariablesComputed */ | 2097152 /* IsGenericTypeComputed */ | 33554432 /* IsUnknownLikeUnionComputed */ | 16777216 /* IsNeverIntersectionComputed */;
|
|
51129
51141
|
return type;
|
|
51130
51142
|
}
|
|
51131
51143
|
function createObjectType(objectFlags, symbol) {
|
|
@@ -55549,7 +55561,7 @@ function createTypeChecker(host) {
|
|
|
55549
55561
|
return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : void 0;
|
|
55550
55562
|
}
|
|
55551
55563
|
function getTypeForBindingElement(declaration) {
|
|
55552
|
-
const checkMode = declaration.dotDotDotToken ?
|
|
55564
|
+
const checkMode = declaration.dotDotDotToken ? 128 /* RestBindingElement */ : 0 /* Normal */;
|
|
55553
55565
|
const parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
|
55554
55566
|
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
55555
55567
|
}
|
|
@@ -55568,7 +55580,7 @@ function createTypeChecker(host) {
|
|
|
55568
55580
|
if (declaration.dotDotDotToken) {
|
|
55569
55581
|
parentType = getReducedType(parentType);
|
|
55570
55582
|
if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) {
|
|
55571
|
-
|
|
55583
|
+
error2(declaration, Diagnostics.Rest_types_may_only_be_created_from_object_types);
|
|
55572
55584
|
return errorType;
|
|
55573
55585
|
}
|
|
55574
55586
|
const literalMembers = [];
|
|
@@ -55801,7 +55813,7 @@ function createTypeChecker(host) {
|
|
|
55801
55813
|
reference.flowNode = staticBlock.returnFlowNode;
|
|
55802
55814
|
const flowType = getFlowTypeOfProperty(reference, symbol);
|
|
55803
55815
|
if (noImplicitAny && (flowType === autoType || flowType === autoArrayType)) {
|
|
55804
|
-
|
|
55816
|
+
error2(symbol.valueDeclaration, Diagnostics.Member_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType));
|
|
55805
55817
|
}
|
|
55806
55818
|
if (everyType(flowType, isNullableType)) {
|
|
55807
55819
|
continue;
|
|
@@ -55817,7 +55829,7 @@ function createTypeChecker(host) {
|
|
|
55817
55829
|
reference.flowNode = constructor.returnFlowNode;
|
|
55818
55830
|
const flowType = getFlowTypeOfProperty(reference, symbol);
|
|
55819
55831
|
if (noImplicitAny && (flowType === autoType || flowType === autoArrayType)) {
|
|
55820
|
-
|
|
55832
|
+
error2(symbol.valueDeclaration, Diagnostics.Member_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType));
|
|
55821
55833
|
}
|
|
55822
55834
|
return everyType(flowType, isNullableType) ? void 0 : convertAutoToAny(flowType);
|
|
55823
55835
|
}
|
|
@@ -55992,11 +56004,11 @@ function createTypeChecker(host) {
|
|
|
55992
56004
|
const unescapedName = unescapeLeadingUnderscores(s.escapedName);
|
|
55993
56005
|
const exportedMemberName = ((_a = tryCast(exportedMember.valueDeclaration, isNamedDeclaration)) == null ? void 0 : _a.name) || exportedMember.valueDeclaration;
|
|
55994
56006
|
addRelatedInfo(
|
|
55995
|
-
|
|
56007
|
+
error2(s.valueDeclaration, Diagnostics.Duplicate_identifier_0, unescapedName),
|
|
55996
56008
|
createDiagnosticForNode(exportedMemberName, Diagnostics._0_was_also_declared_here, unescapedName)
|
|
55997
56009
|
);
|
|
55998
56010
|
addRelatedInfo(
|
|
55999
|
-
|
|
56011
|
+
error2(exportedMemberName, Diagnostics.Duplicate_identifier_0, unescapedName),
|
|
56000
56012
|
createDiagnosticForNode(s.valueDeclaration, Diagnostics._0_was_also_declared_here, unescapedName)
|
|
56001
56013
|
);
|
|
56002
56014
|
}
|
|
@@ -56351,13 +56363,13 @@ function createTypeChecker(host) {
|
|
|
56351
56363
|
}
|
|
56352
56364
|
if (!popTypeResolution()) {
|
|
56353
56365
|
if (getAnnotatedAccessorTypeNode(getter)) {
|
|
56354
|
-
|
|
56366
|
+
error2(getter, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
56355
56367
|
} else if (getAnnotatedAccessorTypeNode(setter)) {
|
|
56356
|
-
|
|
56368
|
+
error2(setter, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
56357
56369
|
} else if (getAnnotatedAccessorTypeNode(accessor)) {
|
|
56358
|
-
|
|
56370
|
+
error2(setter, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
56359
56371
|
} else if (getter && noImplicitAny) {
|
|
56360
|
-
|
|
56372
|
+
error2(getter, Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol));
|
|
56361
56373
|
}
|
|
56362
56374
|
type = anyType;
|
|
56363
56375
|
}
|
|
@@ -56375,7 +56387,7 @@ function createTypeChecker(host) {
|
|
|
56375
56387
|
let writeType = getAnnotatedAccessorType(setter);
|
|
56376
56388
|
if (!popTypeResolution()) {
|
|
56377
56389
|
if (getAnnotatedAccessorTypeNode(setter)) {
|
|
56378
|
-
|
|
56390
|
+
error2(setter, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
56379
56391
|
}
|
|
56380
56392
|
writeType = anyType;
|
|
56381
56393
|
}
|
|
@@ -56468,7 +56480,7 @@ function createTypeChecker(host) {
|
|
|
56468
56480
|
function reportCircularityError(symbol) {
|
|
56469
56481
|
const declaration = symbol.valueDeclaration;
|
|
56470
56482
|
if (getEffectiveTypeAnnotationNode(declaration)) {
|
|
56471
|
-
|
|
56483
|
+
error2(
|
|
56472
56484
|
symbol.valueDeclaration,
|
|
56473
56485
|
Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation,
|
|
56474
56486
|
symbolToString(symbol)
|
|
@@ -56476,7 +56488,7 @@ function createTypeChecker(host) {
|
|
|
56476
56488
|
return errorType;
|
|
56477
56489
|
}
|
|
56478
56490
|
if (noImplicitAny && (declaration.kind !== 168 /* Parameter */ || declaration.initializer)) {
|
|
56479
|
-
|
|
56491
|
+
error2(
|
|
56480
56492
|
symbol.valueDeclaration,
|
|
56481
56493
|
Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer,
|
|
56482
56494
|
symbolToString(symbol)
|
|
@@ -56721,11 +56733,11 @@ function createTypeChecker(host) {
|
|
|
56721
56733
|
resolveStructuredTypeMembers(baseConstructorType);
|
|
56722
56734
|
}
|
|
56723
56735
|
if (!popTypeResolution()) {
|
|
56724
|
-
|
|
56736
|
+
error2(type.symbol.valueDeclaration, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol));
|
|
56725
56737
|
return type.resolvedBaseConstructorType = errorType;
|
|
56726
56738
|
}
|
|
56727
56739
|
if (!(baseConstructorType.flags & 1 /* Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) {
|
|
56728
|
-
const err =
|
|
56740
|
+
const err = error2(baseTypeNode.expression, Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType));
|
|
56729
56741
|
if (baseConstructorType.flags & 262144 /* TypeParameter */) {
|
|
56730
56742
|
const constraint = getConstraintFromTypeParameter(baseConstructorType);
|
|
56731
56743
|
let ctorReturn = unknownType;
|
|
@@ -56767,7 +56779,7 @@ function createTypeChecker(host) {
|
|
|
56767
56779
|
return resolvedImplementsTypes;
|
|
56768
56780
|
}
|
|
56769
56781
|
function reportCircularBaseType(node, type) {
|
|
56770
|
-
|
|
56782
|
+
error2(node, Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(
|
|
56771
56783
|
type,
|
|
56772
56784
|
/*enclosingDeclaration*/
|
|
56773
56785
|
void 0,
|
|
@@ -56821,7 +56833,7 @@ function createTypeChecker(host) {
|
|
|
56821
56833
|
} else {
|
|
56822
56834
|
const constructors = getInstantiatedConstructorsForTypeArguments(baseConstructorType, baseTypeNode.typeArguments, baseTypeNode);
|
|
56823
56835
|
if (!constructors.length) {
|
|
56824
|
-
|
|
56836
|
+
error2(baseTypeNode.expression, Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments);
|
|
56825
56837
|
return type.resolvedBaseTypes = emptyArray;
|
|
56826
56838
|
}
|
|
56827
56839
|
baseType = getReturnTypeOfSignature(constructors[0]);
|
|
@@ -56841,7 +56853,7 @@ function createTypeChecker(host) {
|
|
|
56841
56853
|
return type.resolvedBaseTypes = emptyArray;
|
|
56842
56854
|
}
|
|
56843
56855
|
if (type === reducedBaseType || hasBaseType(reducedBaseType, type)) {
|
|
56844
|
-
|
|
56856
|
+
error2(
|
|
56845
56857
|
type.symbol.valueDeclaration,
|
|
56846
56858
|
Diagnostics.Type_0_recursively_references_itself_as_a_base_type,
|
|
56847
56859
|
typeToString(
|
|
@@ -56895,7 +56907,7 @@ function createTypeChecker(host) {
|
|
|
56895
56907
|
reportCircularBaseType(declaration, type);
|
|
56896
56908
|
}
|
|
56897
56909
|
} else {
|
|
56898
|
-
|
|
56910
|
+
error2(node, Diagnostics.An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members);
|
|
56899
56911
|
}
|
|
56900
56912
|
}
|
|
56901
56913
|
}
|
|
@@ -56981,9 +56993,9 @@ function createTypeChecker(host) {
|
|
|
56981
56993
|
} else {
|
|
56982
56994
|
type = errorType;
|
|
56983
56995
|
if (declaration.kind === 346 /* JSDocEnumTag */) {
|
|
56984
|
-
|
|
56996
|
+
error2(declaration.typeExpression.type, Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
|
|
56985
56997
|
} else {
|
|
56986
|
-
|
|
56998
|
+
error2(isNamedDeclaration(declaration) ? declaration.name || declaration : declaration, Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
|
|
56987
56999
|
}
|
|
56988
57000
|
}
|
|
56989
57001
|
links.declaredType = type;
|
|
@@ -57232,8 +57244,8 @@ function createTypeChecker(host) {
|
|
|
57232
57244
|
if (lateSymbol.flags & getExcludedSymbolFlags(symbolFlags) || earlySymbol) {
|
|
57233
57245
|
const declarations = earlySymbol ? concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
|
|
57234
57246
|
const name = !(type.flags & 8192 /* UniqueESSymbol */) && unescapeLeadingUnderscores(memberName) || declarationNameToString(declName);
|
|
57235
|
-
forEach(declarations, (declaration) =>
|
|
57236
|
-
|
|
57247
|
+
forEach(declarations, (declaration) => error2(getNameOfDeclaration(declaration) || declaration, Diagnostics.Property_0_was_also_declared_here, name));
|
|
57248
|
+
error2(declName || decl, Diagnostics.Duplicate_property_0, name);
|
|
57237
57249
|
lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */);
|
|
57238
57250
|
}
|
|
57239
57251
|
lateSymbol.links.nameType = type;
|
|
@@ -58079,7 +58091,7 @@ function createTypeChecker(host) {
|
|
|
58079
58091
|
true
|
|
58080
58092
|
) : symbol.links.checkFlags & 524288 /* StripOptional */ ? removeMissingOrUndefinedType(propType) : propType;
|
|
58081
58093
|
if (!popTypeResolution()) {
|
|
58082
|
-
|
|
58094
|
+
error2(currentNode, Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(mappedType));
|
|
58083
58095
|
type = errorType;
|
|
58084
58096
|
}
|
|
58085
58097
|
symbol.links.type = type;
|
|
@@ -58405,7 +58417,7 @@ function createTypeChecker(host) {
|
|
|
58405
58417
|
if (t.flags & 262144 /* TypeParameter */) {
|
|
58406
58418
|
const errorNode = getConstraintDeclaration(t);
|
|
58407
58419
|
if (errorNode) {
|
|
58408
|
-
const diagnostic =
|
|
58420
|
+
const diagnostic = error2(errorNode, Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(t));
|
|
58409
58421
|
if (currentNode && !isNodeDescendantOf(errorNode, currentNode) && !isNodeDescendantOf(currentNode, errorNode)) {
|
|
58410
58422
|
addRelatedInfo(diagnostic, createDiagnosticForNode(currentNode, Diagnostics.Circularity_originates_in_type_at_this_location));
|
|
58411
58423
|
}
|
|
@@ -59255,14 +59267,14 @@ function createTypeChecker(host) {
|
|
|
59255
59267
|
if (signature.declaration) {
|
|
59256
59268
|
const typeNode = getEffectiveReturnTypeNode(signature.declaration);
|
|
59257
59269
|
if (typeNode) {
|
|
59258
|
-
|
|
59270
|
+
error2(typeNode, Diagnostics.Return_type_annotation_circularly_references_itself);
|
|
59259
59271
|
} else if (noImplicitAny) {
|
|
59260
59272
|
const declaration = signature.declaration;
|
|
59261
59273
|
const name = getNameOfDeclaration(declaration);
|
|
59262
59274
|
if (name) {
|
|
59263
|
-
|
|
59275
|
+
error2(name, Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, declarationNameToString(name));
|
|
59264
59276
|
} else {
|
|
59265
|
-
|
|
59277
|
+
error2(declaration, Diagnostics.Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions);
|
|
59266
59278
|
}
|
|
59267
59279
|
}
|
|
59268
59280
|
}
|
|
@@ -59606,7 +59618,7 @@ function createTypeChecker(host) {
|
|
|
59606
59618
|
type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments;
|
|
59607
59619
|
} else {
|
|
59608
59620
|
type.resolvedTypeArguments = ((_b = type.target.localTypeParameters) == null ? void 0 : _b.map(() => errorType)) || emptyArray;
|
|
59609
|
-
|
|
59621
|
+
error2(
|
|
59610
59622
|
type.node || currentNode,
|
|
59611
59623
|
type.target.symbol ? Diagnostics.Type_arguments_for_0_circularly_reference_themselves : Diagnostics.Tuple_type_arguments_circularly_reference_themselves,
|
|
59612
59624
|
type.target.symbol && symbolToString(type.target.symbol)
|
|
@@ -59635,7 +59647,7 @@ function createTypeChecker(host) {
|
|
|
59635
59647
|
void 0,
|
|
59636
59648
|
2 /* WriteArrayAsGenericType */
|
|
59637
59649
|
);
|
|
59638
|
-
|
|
59650
|
+
error2(node, diag2, typeStr, minTypeArgumentCount, typeParameters.length);
|
|
59639
59651
|
if (!isJs) {
|
|
59640
59652
|
return errorType;
|
|
59641
59653
|
}
|
|
@@ -59691,7 +59703,7 @@ function createTypeChecker(host) {
|
|
|
59691
59703
|
const numTypeArguments = length(node.typeArguments);
|
|
59692
59704
|
const minTypeArgumentCount = getMinTypeArgumentCount(typeParameters);
|
|
59693
59705
|
if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) {
|
|
59694
|
-
|
|
59706
|
+
error2(
|
|
59695
59707
|
node,
|
|
59696
59708
|
minTypeArgumentCount === typeParameters.length ? Diagnostics.Generic_type_0_requires_1_type_argument_s : Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments,
|
|
59697
59709
|
symbolToString(symbol),
|
|
@@ -59867,7 +59879,7 @@ function createTypeChecker(host) {
|
|
|
59867
59879
|
}
|
|
59868
59880
|
function checkNoTypeArguments(node, symbol) {
|
|
59869
59881
|
if (node.typeArguments) {
|
|
59870
|
-
|
|
59882
|
+
error2(node, Diagnostics.Type_0_is_not_generic, symbol ? symbolToString(symbol) : node.typeName ? declarationNameToString(node.typeName) : anon);
|
|
59871
59883
|
return false;
|
|
59872
59884
|
}
|
|
59873
59885
|
return true;
|
|
@@ -59999,11 +60011,11 @@ function createTypeChecker(host) {
|
|
|
59999
60011
|
}
|
|
60000
60012
|
const type = getDeclaredTypeOfSymbol(symbol);
|
|
60001
60013
|
if (!(type.flags & 524288 /* Object */)) {
|
|
60002
|
-
|
|
60014
|
+
error2(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbolName(symbol));
|
|
60003
60015
|
return arity ? emptyGenericType : emptyObjectType;
|
|
60004
60016
|
}
|
|
60005
60017
|
if (length(type.typeParameters) !== arity) {
|
|
60006
|
-
|
|
60018
|
+
error2(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbolName(symbol), arity);
|
|
60007
60019
|
return arity ? emptyGenericType : emptyObjectType;
|
|
60008
60020
|
}
|
|
60009
60021
|
return type;
|
|
@@ -60020,7 +60032,7 @@ function createTypeChecker(host) {
|
|
|
60020
60032
|
getDeclaredTypeOfSymbol(symbol);
|
|
60021
60033
|
if (length(getSymbolLinks(symbol).typeParameters) !== arity) {
|
|
60022
60034
|
const decl = symbol.declarations && find(symbol.declarations, isTypeAliasDeclaration);
|
|
60023
|
-
|
|
60035
|
+
error2(decl, Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbolName(symbol), arity);
|
|
60024
60036
|
return void 0;
|
|
60025
60037
|
}
|
|
60026
60038
|
}
|
|
@@ -60565,7 +60577,7 @@ function createTypeChecker(host) {
|
|
|
60565
60577
|
} else if (isTupleType(type)) {
|
|
60566
60578
|
const elements = getElementTypes(type);
|
|
60567
60579
|
if (elements.length + expandedTypes.length >= 1e4) {
|
|
60568
|
-
|
|
60580
|
+
error2(currentNode, isPartOfTypeNode(currentNode) ? Diagnostics.Type_produces_a_tuple_type_that_is_too_large_to_represent : Diagnostics.Expression_produces_a_tuple_type_that_is_too_large_to_represent);
|
|
60569
60581
|
return errorType;
|
|
60570
60582
|
}
|
|
60571
60583
|
forEach(elements, (t, n) => {
|
|
@@ -60730,7 +60742,7 @@ function createTypeChecker(host) {
|
|
|
60730
60742
|
const estimatedCount = count / (len - i) * len;
|
|
60731
60743
|
if (estimatedCount > 1e6) {
|
|
60732
60744
|
(_a = tracing) == null ? void 0 : _a.instant(tracing.Phase.CheckTypes, "removeSubtypes_DepthLimit", { typeIds: types.map((t) => t.id) });
|
|
60733
|
-
|
|
60745
|
+
error2(currentNode, Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
|
|
60734
60746
|
return void 0;
|
|
60735
60747
|
}
|
|
60736
60748
|
}
|
|
@@ -61139,7 +61151,7 @@ function createTypeChecker(host) {
|
|
|
61139
61151
|
const size = getCrossProductUnionSize(types);
|
|
61140
61152
|
if (size >= 1e5) {
|
|
61141
61153
|
(_a = tracing) == null ? void 0 : _a.instant(tracing.Phase.CheckTypes, "checkCrossProductUnion_DepthLimit", { typeIds: types.map((t) => t.id), size });
|
|
61142
|
-
|
|
61154
|
+
error2(currentNode, Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
|
|
61143
61155
|
return false;
|
|
61144
61156
|
}
|
|
61145
61157
|
return true;
|
|
@@ -61511,7 +61523,7 @@ function createTypeChecker(host) {
|
|
|
61511
61523
|
if (accessExpression) {
|
|
61512
61524
|
markPropertyAsReferenced(prop, accessExpression, isSelfTypeAccess(accessExpression.expression, objectType.symbol));
|
|
61513
61525
|
if (isAssignmentToReadonlyEntity(accessExpression, prop, getAssignmentTargetKind(accessExpression))) {
|
|
61514
|
-
|
|
61526
|
+
error2(accessExpression.argumentExpression, Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop));
|
|
61515
61527
|
return void 0;
|
|
61516
61528
|
}
|
|
61517
61529
|
if (accessFlags & 8 /* CacheSymbol */) {
|
|
@@ -61530,10 +61542,10 @@ function createTypeChecker(host) {
|
|
|
61530
61542
|
const indexNode = getIndexNodeForAccessExpression(accessNode);
|
|
61531
61543
|
if (isTupleType(objectType)) {
|
|
61532
61544
|
if (index < 0) {
|
|
61533
|
-
|
|
61545
|
+
error2(indexNode, Diagnostics.A_tuple_type_cannot_be_indexed_with_a_negative_value);
|
|
61534
61546
|
return undefinedType;
|
|
61535
61547
|
}
|
|
61536
|
-
|
|
61548
|
+
error2(
|
|
61537
61549
|
indexNode,
|
|
61538
61550
|
Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2,
|
|
61539
61551
|
typeToString(objectType),
|
|
@@ -61541,7 +61553,7 @@ function createTypeChecker(host) {
|
|
|
61541
61553
|
unescapeLeadingUnderscores(propName)
|
|
61542
61554
|
);
|
|
61543
61555
|
} else {
|
|
61544
|
-
|
|
61556
|
+
error2(indexNode, Diagnostics.Property_0_does_not_exist_on_type_1, unescapeLeadingUnderscores(propName), typeToString(objectType));
|
|
61545
61557
|
}
|
|
61546
61558
|
}
|
|
61547
61559
|
if (index >= 0) {
|
|
@@ -61561,13 +61573,13 @@ function createTypeChecker(host) {
|
|
|
61561
61573
|
if (indexInfo) {
|
|
61562
61574
|
if (accessFlags & 2 /* NoIndexSignatures */ && indexInfo.keyType !== numberType) {
|
|
61563
61575
|
if (accessExpression) {
|
|
61564
|
-
|
|
61576
|
+
error2(accessExpression, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType));
|
|
61565
61577
|
}
|
|
61566
61578
|
return void 0;
|
|
61567
61579
|
}
|
|
61568
61580
|
if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) {
|
|
61569
61581
|
const indexNode = getIndexNodeForAccessExpression(accessNode);
|
|
61570
|
-
|
|
61582
|
+
error2(indexNode, Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
|
|
61571
61583
|
return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, missingType]) : indexInfo.type;
|
|
61572
61584
|
}
|
|
61573
61585
|
errorIfWritingToReadonlyIndex(indexInfo);
|
|
@@ -61595,23 +61607,23 @@ function createTypeChecker(host) {
|
|
|
61595
61607
|
}
|
|
61596
61608
|
}
|
|
61597
61609
|
if (objectType.symbol === globalThisSymbol && propName !== void 0 && globalThisSymbol.exports.has(propName) && globalThisSymbol.exports.get(propName).flags & 418 /* BlockScoped */) {
|
|
61598
|
-
|
|
61610
|
+
error2(accessExpression, Diagnostics.Property_0_does_not_exist_on_type_1, unescapeLeadingUnderscores(propName), typeToString(objectType));
|
|
61599
61611
|
} else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* SuppressNoImplicitAnyError */)) {
|
|
61600
61612
|
if (propName !== void 0 && typeHasStaticProperty(propName, objectType)) {
|
|
61601
61613
|
const typeName = typeToString(objectType);
|
|
61602
|
-
|
|
61614
|
+
error2(accessExpression, Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead, propName, typeName, typeName + "[" + getTextOfNode(accessExpression.argumentExpression) + "]");
|
|
61603
61615
|
} else if (getIndexTypeOfType(objectType, numberType)) {
|
|
61604
|
-
|
|
61616
|
+
error2(accessExpression.argumentExpression, Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number);
|
|
61605
61617
|
} else {
|
|
61606
61618
|
let suggestion;
|
|
61607
61619
|
if (propName !== void 0 && (suggestion = getSuggestionForNonexistentProperty(propName, objectType))) {
|
|
61608
61620
|
if (suggestion !== void 0) {
|
|
61609
|
-
|
|
61621
|
+
error2(accessExpression.argumentExpression, Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, propName, typeToString(objectType), suggestion);
|
|
61610
61622
|
}
|
|
61611
61623
|
} else {
|
|
61612
61624
|
const suggestion2 = getSuggestionForNonexistentIndexSignature(objectType, accessExpression, indexType);
|
|
61613
61625
|
if (suggestion2 !== void 0) {
|
|
61614
|
-
|
|
61626
|
+
error2(accessExpression, Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1, typeToString(objectType), suggestion2);
|
|
61615
61627
|
} else {
|
|
61616
61628
|
let errorInfo;
|
|
61617
61629
|
if (indexType.flags & 1024 /* EnumLiteral */) {
|
|
@@ -61676,11 +61688,11 @@ function createTypeChecker(host) {
|
|
|
61676
61688
|
if (accessNode) {
|
|
61677
61689
|
const indexNode = getIndexNodeForAccessExpression(accessNode);
|
|
61678
61690
|
if (indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
|
|
61679
|
-
|
|
61691
|
+
error2(indexNode, Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType));
|
|
61680
61692
|
} else if (indexType.flags & (4 /* String */ | 8 /* Number */)) {
|
|
61681
|
-
|
|
61693
|
+
error2(indexNode, Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType));
|
|
61682
61694
|
} else {
|
|
61683
|
-
|
|
61695
|
+
error2(indexNode, Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
|
|
61684
61696
|
}
|
|
61685
61697
|
}
|
|
61686
61698
|
if (isTypeAny(indexType)) {
|
|
@@ -61689,7 +61701,7 @@ function createTypeChecker(host) {
|
|
|
61689
61701
|
return void 0;
|
|
61690
61702
|
function errorIfWritingToReadonlyIndex(indexInfo) {
|
|
61691
61703
|
if (indexInfo && indexInfo.isReadonly && accessExpression && (isAssignmentTarget(accessExpression) || isDeleteTarget(accessExpression))) {
|
|
61692
|
-
|
|
61704
|
+
error2(accessExpression, Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
|
|
61693
61705
|
}
|
|
61694
61706
|
}
|
|
61695
61707
|
}
|
|
@@ -61914,7 +61926,7 @@ function createTypeChecker(host) {
|
|
|
61914
61926
|
let tailCount = 0;
|
|
61915
61927
|
while (true) {
|
|
61916
61928
|
if (tailCount === 1e3) {
|
|
61917
|
-
|
|
61929
|
+
error2(currentNode, Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
|
|
61918
61930
|
return errorType;
|
|
61919
61931
|
}
|
|
61920
61932
|
const checkType = instantiateType(getActualTypeVariable(root.checkType), mapper);
|
|
@@ -62092,7 +62104,7 @@ function createTypeChecker(host) {
|
|
|
62092
62104
|
const links = getNodeLinks(node);
|
|
62093
62105
|
if (!links.resolvedType) {
|
|
62094
62106
|
if (!isLiteralImportTypeNode(node)) {
|
|
62095
|
-
|
|
62107
|
+
error2(node.argument, Diagnostics.String_literal_expected);
|
|
62096
62108
|
links.resolvedSymbol = unknownSymbol;
|
|
62097
62109
|
return links.resolvedType = errorType;
|
|
62098
62110
|
}
|
|
@@ -62126,7 +62138,7 @@ function createTypeChecker(host) {
|
|
|
62126
62138
|
const symbolFromModule = node.isTypeOf ? void 0 : getSymbol2(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning);
|
|
62127
62139
|
const next = symbolFromModule ?? symbolFromVariable;
|
|
62128
62140
|
if (!next) {
|
|
62129
|
-
|
|
62141
|
+
error2(current, Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), declarationNameToString(current));
|
|
62130
62142
|
return links.resolvedType = errorType;
|
|
62131
62143
|
}
|
|
62132
62144
|
getNodeLinks(current).resolvedSymbol = next;
|
|
@@ -62139,7 +62151,7 @@ function createTypeChecker(host) {
|
|
|
62139
62151
|
links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning);
|
|
62140
62152
|
} else {
|
|
62141
62153
|
const errorMessage = targetMeaning === 111551 /* Value */ ? Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0;
|
|
62142
|
-
|
|
62154
|
+
error2(node, errorMessage, node.argument.literal.text);
|
|
62143
62155
|
links.resolvedSymbol = unknownSymbol;
|
|
62144
62156
|
links.resolvedType = errorType;
|
|
62145
62157
|
}
|
|
@@ -62417,7 +62429,7 @@ function createTypeChecker(host) {
|
|
|
62417
62429
|
if (isJSConstructor(container) && isNodeDescendantOf(node, container.body)) {
|
|
62418
62430
|
return getDeclaredTypeOfClassOrInterface(getSymbolOfDeclaration(container)).thisType;
|
|
62419
62431
|
}
|
|
62420
|
-
|
|
62432
|
+
error2(node, Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface);
|
|
62421
62433
|
return errorType;
|
|
62422
62434
|
}
|
|
62423
62435
|
function getTypeFromThisTypeNode(node) {
|
|
@@ -62746,10 +62758,18 @@ function createTypeChecker(host) {
|
|
|
62746
62758
|
if (!result) {
|
|
62747
62759
|
const newMapper = createTypeMapper(typeParameters, typeArguments);
|
|
62748
62760
|
result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
|
|
62749
|
-
if (result.flags & 138117121 /* ObjectFlagsType */ && !(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
62750
|
-
result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (some(typeArguments, couldContainTypeVariables) ? 1048576 /* CouldContainTypeVariables */ : 0);
|
|
62751
|
-
}
|
|
62752
62761
|
target.instantiations.set(id, result);
|
|
62762
|
+
const resultObjectFlags = getObjectFlags(result);
|
|
62763
|
+
if (result.flags & 138117121 /* ObjectFlagsType */ && !(resultObjectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
62764
|
+
const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables);
|
|
62765
|
+
if (!(getObjectFlags(result) & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
62766
|
+
if (resultObjectFlags & (32 /* Mapped */ | 16 /* Anonymous */ | 4 /* Reference */)) {
|
|
62767
|
+
result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (resultCouldContainTypeVariables ? 1048576 /* CouldContainTypeVariables */ : 0);
|
|
62768
|
+
} else {
|
|
62769
|
+
result.objectFlags |= !resultCouldContainTypeVariables ? 524288 /* CouldContainTypeVariablesComputed */ : 0;
|
|
62770
|
+
}
|
|
62771
|
+
}
|
|
62772
|
+
}
|
|
62753
62773
|
}
|
|
62754
62774
|
return result;
|
|
62755
62775
|
}
|
|
@@ -62934,7 +62954,7 @@ function createTypeChecker(host) {
|
|
|
62934
62954
|
}
|
|
62935
62955
|
if (instantiationDepth === 100 || instantiationCount >= 5e6) {
|
|
62936
62956
|
(_a = tracing) == null ? void 0 : _a.instant(tracing.Phase.CheckTypes, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth, instantiationCount });
|
|
62937
|
-
|
|
62957
|
+
error2(currentNode, Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
|
|
62938
62958
|
return errorType;
|
|
62939
62959
|
}
|
|
62940
62960
|
totalInstantiationCount++;
|
|
@@ -63554,7 +63574,7 @@ function createTypeChecker(host) {
|
|
|
63554
63574
|
result = elaborateIterableOrArrayLikeTargetElementwise(children, realSource, arrayLikeTargetParts, relation, containingMessageChain, errorOutputContainer) || result;
|
|
63555
63575
|
} else if (!isTypeRelatedTo(getIndexedAccessType(source, childrenNameType), childrenTargetType, relation)) {
|
|
63556
63576
|
result = true;
|
|
63557
|
-
const diag2 =
|
|
63577
|
+
const diag2 = error2(
|
|
63558
63578
|
containingElement.openingElement.tagName,
|
|
63559
63579
|
Diagnostics.This_JSX_tag_s_0_prop_expects_a_single_child_of_type_1_but_multiple_children_were_provided,
|
|
63560
63580
|
childrenPropName,
|
|
@@ -63582,7 +63602,7 @@ function createTypeChecker(host) {
|
|
|
63582
63602
|
}
|
|
63583
63603
|
} else if (!isTypeRelatedTo(getIndexedAccessType(source, childrenNameType), childrenTargetType, relation)) {
|
|
63584
63604
|
result = true;
|
|
63585
|
-
const diag2 =
|
|
63605
|
+
const diag2 = error2(
|
|
63586
63606
|
containingElement.openingElement.tagName,
|
|
63587
63607
|
Diagnostics.This_JSX_tag_s_0_prop_expects_type_1_which_requires_multiple_children_but_only_a_single_child_was_provided,
|
|
63588
63608
|
childrenPropName,
|
|
@@ -64087,7 +64107,7 @@ function createTypeChecker(host) {
|
|
|
64087
64107
|
}
|
|
64088
64108
|
if (overflow) {
|
|
64089
64109
|
(_a = tracing) == null ? void 0 : _a.instant(tracing.Phase.CheckTypes, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth });
|
|
64090
|
-
const diag2 =
|
|
64110
|
+
const diag2 = error2(errorNode || currentNode, Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target));
|
|
64091
64111
|
if (errorOutputContainer) {
|
|
64092
64112
|
(errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag2);
|
|
64093
64113
|
}
|
|
@@ -67203,7 +67223,7 @@ function createTypeChecker(host) {
|
|
|
67203
67223
|
const t = getTypeOfSymbol(p);
|
|
67204
67224
|
if (getObjectFlags(t) & 65536 /* ContainsWideningType */) {
|
|
67205
67225
|
if (!reportWideningErrorsInType(t)) {
|
|
67206
|
-
|
|
67226
|
+
error2(p.valueDeclaration, Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t)));
|
|
67207
67227
|
}
|
|
67208
67228
|
errorReported = true;
|
|
67209
67229
|
}
|
|
@@ -67253,11 +67273,11 @@ function createTypeChecker(host) {
|
|
|
67253
67273
|
}
|
|
67254
67274
|
break;
|
|
67255
67275
|
case 323 /* JSDocFunctionType */:
|
|
67256
|
-
|
|
67276
|
+
error2(declaration, Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString);
|
|
67257
67277
|
return;
|
|
67258
67278
|
case 329 /* JSDocSignature */:
|
|
67259
67279
|
if (noImplicitAny && isJSDocOverloadTag(declaration.parent)) {
|
|
67260
|
-
|
|
67280
|
+
error2(declaration.parent.tagName, Diagnostics.This_overload_implicitly_returns_the_type_0_because_it_lacks_a_return_type_annotation, typeAsString);
|
|
67261
67281
|
}
|
|
67262
67282
|
return;
|
|
67263
67283
|
case 261 /* FunctionDeclaration */:
|
|
@@ -67269,9 +67289,9 @@ function createTypeChecker(host) {
|
|
|
67269
67289
|
case 218 /* ArrowFunction */:
|
|
67270
67290
|
if (noImplicitAny && !declaration.name) {
|
|
67271
67291
|
if (wideningKind === 3 /* GeneratorYield */) {
|
|
67272
|
-
|
|
67292
|
+
error2(declaration, Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString);
|
|
67273
67293
|
} else {
|
|
67274
|
-
|
|
67294
|
+
error2(declaration, Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString);
|
|
67275
67295
|
}
|
|
67276
67296
|
return;
|
|
67277
67297
|
}
|
|
@@ -67279,7 +67299,7 @@ function createTypeChecker(host) {
|
|
|
67279
67299
|
break;
|
|
67280
67300
|
case 199 /* MappedType */:
|
|
67281
67301
|
if (noImplicitAny) {
|
|
67282
|
-
|
|
67302
|
+
error2(declaration, Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type);
|
|
67283
67303
|
}
|
|
67284
67304
|
return;
|
|
67285
67305
|
default:
|
|
@@ -70446,7 +70466,7 @@ function createTypeChecker(host) {
|
|
|
70446
70466
|
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
|
|
70447
70467
|
}
|
|
70448
70468
|
function hasContextualTypeWithNoGenericTypes(node, checkMode) {
|
|
70449
|
-
const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode &
|
|
70469
|
+
const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode & 128 /* RestBindingElement */ ? getContextualType2(node, 8 /* SkipBindingPatterns */) : getContextualType2(
|
|
70450
70470
|
node,
|
|
70451
70471
|
/*contextFlags*/
|
|
70452
70472
|
void 0
|
|
@@ -70557,15 +70577,15 @@ function createTypeChecker(host) {
|
|
|
70557
70577
|
}
|
|
70558
70578
|
if (symbol === argumentsSymbol) {
|
|
70559
70579
|
if (isInPropertyInitializerOrClassStaticBlock(node)) {
|
|
70560
|
-
|
|
70580
|
+
error2(node, Diagnostics.arguments_cannot_be_referenced_in_property_initializers);
|
|
70561
70581
|
return errorType;
|
|
70562
70582
|
}
|
|
70563
70583
|
const container = getContainingFunction(node);
|
|
70564
70584
|
if (languageVersion < 2 /* ES2015 */) {
|
|
70565
70585
|
if (container.kind === 218 /* ArrowFunction */) {
|
|
70566
|
-
|
|
70586
|
+
error2(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression);
|
|
70567
70587
|
} else if (hasSyntacticModifier(container, 512 /* Async */)) {
|
|
70568
|
-
|
|
70588
|
+
error2(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method);
|
|
70569
70589
|
}
|
|
70570
70590
|
}
|
|
70571
70591
|
getNodeLinks(container).flags |= 512 /* CaptureArguments */;
|
|
@@ -70623,14 +70643,14 @@ function createTypeChecker(host) {
|
|
|
70623
70643
|
if (assignmentKind) {
|
|
70624
70644
|
if (!(localOrExportSymbol.flags & 3 /* Variable */) && !(isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) {
|
|
70625
70645
|
const assignmentError = localOrExportSymbol.flags & 384 /* Enum */ ? Diagnostics.Cannot_assign_to_0_because_it_is_an_enum : localOrExportSymbol.flags & 32 /* Class */ ? Diagnostics.Cannot_assign_to_0_because_it_is_a_class : localOrExportSymbol.flags & 1536 /* Module */ ? Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace : localOrExportSymbol.flags & 16 /* Function */ ? Diagnostics.Cannot_assign_to_0_because_it_is_a_function : localOrExportSymbol.flags & 2097152 /* Alias */ ? Diagnostics.Cannot_assign_to_0_because_it_is_an_import : Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable;
|
|
70626
|
-
|
|
70646
|
+
error2(node, assignmentError, symbolToString(symbol));
|
|
70627
70647
|
return errorType;
|
|
70628
70648
|
}
|
|
70629
70649
|
if (isReadonlySymbol(localOrExportSymbol)) {
|
|
70630
70650
|
if (localOrExportSymbol.flags & 3 /* Variable */) {
|
|
70631
|
-
|
|
70651
|
+
error2(node, Diagnostics.Cannot_assign_to_0_because_it_is_a_constant, symbolToString(symbol));
|
|
70632
70652
|
} else {
|
|
70633
|
-
|
|
70653
|
+
error2(node, Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(symbol));
|
|
70634
70654
|
}
|
|
70635
70655
|
return errorType;
|
|
70636
70656
|
}
|
|
@@ -70666,13 +70686,13 @@ function createTypeChecker(host) {
|
|
|
70666
70686
|
if (!isEvolvingArrayOperationTarget(node) && (type === autoType || type === autoArrayType)) {
|
|
70667
70687
|
if (flowType === autoType || flowType === autoArrayType) {
|
|
70668
70688
|
if (noImplicitAny) {
|
|
70669
|
-
|
|
70670
|
-
|
|
70689
|
+
error2(getNameOfDeclaration(declaration), Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType));
|
|
70690
|
+
error2(node, Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType));
|
|
70671
70691
|
}
|
|
70672
70692
|
return convertAutoToAny(flowType);
|
|
70673
70693
|
}
|
|
70674
70694
|
} else if (!assumeInitialized && !containsUndefinedType(type) && containsUndefinedType(flowType)) {
|
|
70675
|
-
|
|
70695
|
+
error2(node, Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol));
|
|
70676
70696
|
return type;
|
|
70677
70697
|
}
|
|
70678
70698
|
return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
|
|
@@ -70802,13 +70822,13 @@ function createTypeChecker(host) {
|
|
|
70802
70822
|
/*noCacheCheck*/
|
|
70803
70823
|
false
|
|
70804
70824
|
)) {
|
|
70805
|
-
|
|
70825
|
+
error2(node, diagnosticMessage);
|
|
70806
70826
|
}
|
|
70807
70827
|
}
|
|
70808
70828
|
}
|
|
70809
70829
|
function checkThisInStaticClassFieldInitializerInDecoratedClass(thisExpression, container) {
|
|
70810
70830
|
if (isPropertyDeclaration(container) && hasStaticModifier(container) && legacyDecorators && container.initializer && textRangeContainsPositionInclusive(container.initializer, thisExpression.pos) && hasDecorators(container.parent)) {
|
|
70811
|
-
|
|
70831
|
+
error2(thisExpression, Diagnostics.Cannot_use_this_in_a_static_property_initializer_of_a_decorated_class);
|
|
70812
70832
|
}
|
|
70813
70833
|
}
|
|
70814
70834
|
function checkThisExpression(node) {
|
|
@@ -70849,18 +70869,18 @@ function createTypeChecker(host) {
|
|
|
70849
70869
|
}
|
|
70850
70870
|
checkThisInStaticClassFieldInitializerInDecoratedClass(node, container);
|
|
70851
70871
|
if (thisInComputedPropertyName) {
|
|
70852
|
-
|
|
70872
|
+
error2(node, Diagnostics.this_cannot_be_referenced_in_a_computed_property_name);
|
|
70853
70873
|
} else {
|
|
70854
70874
|
switch (container.kind) {
|
|
70855
70875
|
case 266 /* ModuleDeclaration */:
|
|
70856
|
-
|
|
70876
|
+
error2(node, Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body);
|
|
70857
70877
|
break;
|
|
70858
70878
|
case 265 /* EnumDeclaration */:
|
|
70859
|
-
|
|
70879
|
+
error2(node, Diagnostics.this_cannot_be_referenced_in_current_location);
|
|
70860
70880
|
break;
|
|
70861
70881
|
case 175 /* Constructor */:
|
|
70862
70882
|
if (isInConstructorArgumentInitializer(node, container)) {
|
|
70863
|
-
|
|
70883
|
+
error2(node, Diagnostics.this_cannot_be_referenced_in_constructor_arguments);
|
|
70864
70884
|
}
|
|
70865
70885
|
break;
|
|
70866
70886
|
}
|
|
@@ -70877,9 +70897,9 @@ function createTypeChecker(host) {
|
|
|
70877
70897
|
if (noImplicitThis) {
|
|
70878
70898
|
const globalThisType2 = getTypeOfSymbol(globalThisSymbol);
|
|
70879
70899
|
if (type === globalThisType2 && capturedByArrowFunction) {
|
|
70880
|
-
|
|
70900
|
+
error2(node, Diagnostics.The_containing_arrow_function_captures_the_global_value_of_this);
|
|
70881
70901
|
} else if (!type) {
|
|
70882
|
-
const diag2 =
|
|
70902
|
+
const diag2 = error2(node, Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation);
|
|
70883
70903
|
if (!isSourceFile(container)) {
|
|
70884
70904
|
const outsideThis = tryGetThisTypeAt(container);
|
|
70885
70905
|
if (outsideThis && outsideThis !== globalThisType2) {
|
|
@@ -71008,13 +71028,13 @@ function createTypeChecker(host) {
|
|
|
71008
71028
|
if (!container || !isLegalUsageOfSuperExpression(container)) {
|
|
71009
71029
|
const current = findAncestor(node, (n) => n === container ? "quit" : n.kind === 166 /* ComputedPropertyName */);
|
|
71010
71030
|
if (current && current.kind === 166 /* ComputedPropertyName */) {
|
|
71011
|
-
|
|
71031
|
+
error2(node, Diagnostics.super_cannot_be_referenced_in_a_computed_property_name);
|
|
71012
71032
|
} else if (isCallExpression2) {
|
|
71013
|
-
|
|
71033
|
+
error2(node, Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors);
|
|
71014
71034
|
} else if (!container || !container.parent || !(isClassLike(container.parent) || container.parent.kind === 209 /* ObjectLiteralExpression */)) {
|
|
71015
|
-
|
|
71035
|
+
error2(node, Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions);
|
|
71016
71036
|
} else {
|
|
71017
|
-
|
|
71037
|
+
error2(node, Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class);
|
|
71018
71038
|
}
|
|
71019
71039
|
return errorType;
|
|
71020
71040
|
}
|
|
@@ -71046,7 +71066,7 @@ function createTypeChecker(host) {
|
|
|
71046
71066
|
}
|
|
71047
71067
|
if (container.parent.kind === 209 /* ObjectLiteralExpression */) {
|
|
71048
71068
|
if (languageVersion < 2 /* ES2015 */) {
|
|
71049
|
-
|
|
71069
|
+
error2(node, Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher);
|
|
71050
71070
|
return errorType;
|
|
71051
71071
|
} else {
|
|
71052
71072
|
return anyType;
|
|
@@ -71054,7 +71074,7 @@ function createTypeChecker(host) {
|
|
|
71054
71074
|
}
|
|
71055
71075
|
const classLikeDeclaration = container.parent;
|
|
71056
71076
|
if (!getClassExtendsHeritageElement(classLikeDeclaration)) {
|
|
71057
|
-
|
|
71077
|
+
error2(node, Diagnostics.super_can_only_be_referenced_in_a_derived_class);
|
|
71058
71078
|
return errorType;
|
|
71059
71079
|
}
|
|
71060
71080
|
const classType = getDeclaredTypeOfSymbol(getSymbolOfDeclaration(classLikeDeclaration));
|
|
@@ -71063,7 +71083,7 @@ function createTypeChecker(host) {
|
|
|
71063
71083
|
return errorType;
|
|
71064
71084
|
}
|
|
71065
71085
|
if (container.kind === 175 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) {
|
|
71066
|
-
|
|
71086
|
+
error2(node, Diagnostics.super_cannot_be_referenced_in_constructor_arguments);
|
|
71067
71087
|
return errorType;
|
|
71068
71088
|
}
|
|
71069
71089
|
return nodeCheckFlag === 32 /* SuperStatic */ ? getBaseConstructorTypeOfClass(classType) : getTypeWithThisArgument(baseClassType, classType.thisType);
|
|
@@ -71203,7 +71223,7 @@ function createTypeChecker(host) {
|
|
|
71203
71223
|
function getContextualTypeForBindingElement(declaration, contextFlags) {
|
|
71204
71224
|
const parent2 = declaration.parent.parent;
|
|
71205
71225
|
const name = declaration.propertyName || declaration.name;
|
|
71206
|
-
const parentType = getContextualTypeForVariableLikeDeclaration(parent2, contextFlags) || parent2.kind !== 207 /* BindingElement */ && parent2.initializer && checkDeclarationInitializer(parent2, declaration.dotDotDotToken ?
|
|
71226
|
+
const parentType = getContextualTypeForVariableLikeDeclaration(parent2, contextFlags) || parent2.kind !== 207 /* BindingElement */ && parent2.initializer && checkDeclarationInitializer(parent2, declaration.dotDotDotToken ? 128 /* RestBindingElement */ : 0 /* Normal */);
|
|
71207
71227
|
if (!parentType || isBindingPattern(name) || isComputedNonLiteralName(name))
|
|
71208
71228
|
return void 0;
|
|
71209
71229
|
if (parent2.name.kind === 206 /* ArrayBindingPattern */) {
|
|
@@ -72019,7 +72039,7 @@ function createTypeChecker(host) {
|
|
|
72019
72039
|
let attributesType = forcedLookupLocation === void 0 ? getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType) : forcedLookupLocation === "" ? getReturnTypeOfSignature(sig) : getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation);
|
|
72020
72040
|
if (!attributesType) {
|
|
72021
72041
|
if (!!forcedLookupLocation && !!length(context.attributes.properties)) {
|
|
72022
|
-
|
|
72042
|
+
error2(context, Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, unescapeLeadingUnderscores(forcedLookupLocation));
|
|
72023
72043
|
}
|
|
72024
72044
|
return unknownType;
|
|
72025
72045
|
}
|
|
@@ -72252,7 +72272,9 @@ function createTypeChecker(host) {
|
|
|
72252
72272
|
elementTypes.push(undefinedOrMissingType);
|
|
72253
72273
|
elementFlags.push(2 /* Optional */);
|
|
72254
72274
|
} else {
|
|
72255
|
-
const
|
|
72275
|
+
const shouldAddAsIntraExpressionInferenceSite = inTupleContext && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & (4 /* SkipContextSensitive */ | 16 /* SkipAddingIntraExpressionSites */)) && isContextSensitive(e);
|
|
72276
|
+
const elementCheckMode = (checkMode || 0 /* Normal */) | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
72277
|
+
const type = checkExpressionForMutableLocation(e, elementCheckMode, forceTuple);
|
|
72256
72278
|
elementTypes.push(addOptionality(
|
|
72257
72279
|
type,
|
|
72258
72280
|
/*isProperty*/
|
|
@@ -72260,7 +72282,7 @@ function createTypeChecker(host) {
|
|
|
72260
72282
|
hasOmittedExpression
|
|
72261
72283
|
));
|
|
72262
72284
|
elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */);
|
|
72263
|
-
if (
|
|
72285
|
+
if (shouldAddAsIntraExpressionInferenceSite) {
|
|
72264
72286
|
const inferenceContext = getInferenceContext(node);
|
|
72265
72287
|
Debug.assert(inferenceContext);
|
|
72266
72288
|
addIntraExpressionInferenceSite(inferenceContext, e, type);
|
|
@@ -72325,7 +72347,7 @@ function createTypeChecker(host) {
|
|
|
72325
72347
|
}
|
|
72326
72348
|
}
|
|
72327
72349
|
if (links.resolvedType.flags & 98304 /* Nullable */ || !isTypeAssignableToKind(links.resolvedType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) {
|
|
72328
|
-
|
|
72350
|
+
error2(node, Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any);
|
|
72329
72351
|
}
|
|
72330
72352
|
}
|
|
72331
72353
|
return links.resolvedType;
|
|
@@ -72401,11 +72423,13 @@ function createTypeChecker(host) {
|
|
|
72401
72423
|
let member = getSymbolOfDeclaration(memberDecl);
|
|
72402
72424
|
const computedNameType = memberDecl.name && memberDecl.name.kind === 166 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : void 0;
|
|
72403
72425
|
if (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 303 /* ShorthandPropertyAssignment */ || isObjectLiteralMethod(memberDecl)) {
|
|
72404
|
-
|
|
72426
|
+
const shouldAddAsIntraExpressionInferenceSite = contextualType && checkMode & 2 /* Inferential */ && !(checkMode & (4 /* SkipContextSensitive */ | 16 /* SkipAddingIntraExpressionSites */)) && (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 173 /* MethodDeclaration */) && isContextSensitive(memberDecl);
|
|
72427
|
+
const propCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
72428
|
+
let type = memberDecl.kind === 302 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, propCheckMode) : (
|
|
72405
72429
|
// avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring
|
|
72406
72430
|
// for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`.
|
|
72407
72431
|
// we don't want to say "could not find 'a'".
|
|
72408
|
-
memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name,
|
|
72432
|
+
memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, propCheckMode) : checkObjectLiteralMethod(memberDecl, propCheckMode)
|
|
72409
72433
|
);
|
|
72410
72434
|
if (isInJavascript) {
|
|
72411
72435
|
const jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
|
|
@@ -72432,7 +72456,7 @@ function createTypeChecker(host) {
|
|
|
72432
72456
|
if (impliedProp) {
|
|
72433
72457
|
prop.flags |= impliedProp.flags & 16777216 /* Optional */;
|
|
72434
72458
|
} else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, stringType)) {
|
|
72435
|
-
|
|
72459
|
+
error2(
|
|
72436
72460
|
memberDecl.name,
|
|
72437
72461
|
Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1,
|
|
72438
72462
|
symbolToString(member),
|
|
@@ -72449,7 +72473,7 @@ function createTypeChecker(host) {
|
|
|
72449
72473
|
prop.links.target = member;
|
|
72450
72474
|
member = prop;
|
|
72451
72475
|
allPropertiesTable == null ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
|
|
72452
|
-
if (
|
|
72476
|
+
if (shouldAddAsIntraExpressionInferenceSite) {
|
|
72453
72477
|
const inferenceContext = getInferenceContext(node);
|
|
72454
72478
|
Debug.assert(inferenceContext);
|
|
72455
72479
|
const inferenceNode = memberDecl.kind === 302 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
|
|
@@ -72479,7 +72503,7 @@ function createTypeChecker(host) {
|
|
|
72479
72503
|
}
|
|
72480
72504
|
spread = getSpreadType(spread, mergedType, node.symbol, objectFlags, inConstContext);
|
|
72481
72505
|
} else {
|
|
72482
|
-
|
|
72506
|
+
error2(memberDecl, Diagnostics.Spread_types_may_only_be_created_from_object_types);
|
|
72483
72507
|
spread = errorType;
|
|
72484
72508
|
}
|
|
72485
72509
|
continue;
|
|
@@ -72519,7 +72543,7 @@ function createTypeChecker(host) {
|
|
|
72519
72543
|
for (const prop of getPropertiesOfType(contextualType)) {
|
|
72520
72544
|
if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) {
|
|
72521
72545
|
if (!(prop.flags & 16777216 /* Optional */)) {
|
|
72522
|
-
|
|
72546
|
+
error2(
|
|
72523
72547
|
prop.valueDeclaration || ((_a = tryCast(prop, isTransientSymbol)) == null ? void 0 : _a.links.bindingElement),
|
|
72524
72548
|
Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value
|
|
72525
72549
|
);
|
|
@@ -72594,7 +72618,7 @@ function createTypeChecker(host) {
|
|
|
72594
72618
|
checkJsxOpeningLikeElementOrOpeningFragment(node.openingFragment);
|
|
72595
72619
|
const nodeSourceFile = getSourceFileOfNode(node);
|
|
72596
72620
|
if (getJSXTransformEnabled(compilerOptions) && (compilerOptions.jsxFactory || nodeSourceFile.pragmas.has("jsx")) && !compilerOptions.jsxFragmentFactory && !nodeSourceFile.pragmas.has("jsxfrag")) {
|
|
72597
|
-
|
|
72621
|
+
error2(node, compilerOptions.jsxFactory ? Diagnostics.The_jsxFragmentFactory_compiler_option_must_be_provided_to_use_JSX_fragments_with_the_jsxFactory_compiler_option : Diagnostics.An_jsxFrag_pragma_is_required_when_using_an_jsx_pragma_with_JSX_fragments);
|
|
72598
72622
|
}
|
|
72599
72623
|
checkJsxChildren(node);
|
|
72600
72624
|
return getJsxElementTypeAt(node) || anyType;
|
|
@@ -72622,7 +72646,9 @@ function createTypeChecker(host) {
|
|
|
72622
72646
|
for (const attributeDecl of attributes.properties) {
|
|
72623
72647
|
const member = attributeDecl.symbol;
|
|
72624
72648
|
if (isJsxAttribute(attributeDecl)) {
|
|
72625
|
-
const
|
|
72649
|
+
const shouldAddAsIntraExpressionInferenceSite = contextualType && checkMode & 2 /* Inferential */ && !(checkMode & (4 /* SkipContextSensitive */ | 16 /* SkipAddingIntraExpressionSites */)) && isContextSensitive(attributeDecl);
|
|
72650
|
+
const attributeCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
72651
|
+
const exprType = checkJsxAttribute(attributeDecl, attributeCheckMode);
|
|
72626
72652
|
objectFlags |= getObjectFlags(exprType) & 458752 /* PropagatingFlags */;
|
|
72627
72653
|
const attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName);
|
|
72628
72654
|
attributeSymbol.declarations = member.declarations;
|
|
@@ -72643,7 +72669,7 @@ function createTypeChecker(host) {
|
|
|
72643
72669
|
addDeprecatedSuggestion(attributeDecl.name, prop.declarations, attributeDecl.name.escapedText);
|
|
72644
72670
|
}
|
|
72645
72671
|
}
|
|
72646
|
-
if (
|
|
72672
|
+
if (shouldAddAsIntraExpressionInferenceSite) {
|
|
72647
72673
|
const inferenceContext = getInferenceContext(attributes);
|
|
72648
72674
|
Debug.assert(inferenceContext);
|
|
72649
72675
|
const inferenceNode = attributeDecl.initializer.expression;
|
|
@@ -72679,7 +72705,7 @@ function createTypeChecker(host) {
|
|
|
72679
72705
|
checkSpreadPropOverrides(exprType, allAttributesTable, attributeDecl);
|
|
72680
72706
|
}
|
|
72681
72707
|
} else {
|
|
72682
|
-
|
|
72708
|
+
error2(attributeDecl.expression, Diagnostics.Spread_types_may_only_be_created_from_object_types);
|
|
72683
72709
|
typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType;
|
|
72684
72710
|
}
|
|
72685
72711
|
}
|
|
@@ -72701,7 +72727,7 @@ function createTypeChecker(host) {
|
|
|
72701
72727
|
const childrenTypes = checkJsxChildren(parent2, checkMode);
|
|
72702
72728
|
if (!hasSpreadAnyType && jsxChildrenPropertyName && jsxChildrenPropertyName !== "") {
|
|
72703
72729
|
if (explicitlySpecifyChildrenAttribute) {
|
|
72704
|
-
|
|
72730
|
+
error2(attributes, Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, unescapeLeadingUnderscores(jsxChildrenPropertyName));
|
|
72705
72731
|
}
|
|
72706
72732
|
const contextualType2 = getApparentTypeOfContextualType(
|
|
72707
72733
|
openingLikeElement.attributes,
|
|
@@ -72768,7 +72794,7 @@ function createTypeChecker(host) {
|
|
|
72768
72794
|
if (!(right.flags & 16777216 /* Optional */)) {
|
|
72769
72795
|
const left = props.get(right.escapedName);
|
|
72770
72796
|
if (left) {
|
|
72771
|
-
const diagnostic =
|
|
72797
|
+
const diagnostic = error2(left.valueDeclaration, Diagnostics._0_is_specified_more_than_once_so_this_usage_will_be_overwritten, unescapeLeadingUnderscores(left.escapedName));
|
|
72772
72798
|
addRelatedInfo(diagnostic, createDiagnosticForNode(spread, Diagnostics.This_spread_always_overwrites_this_property));
|
|
72773
72799
|
}
|
|
72774
72800
|
}
|
|
@@ -72800,11 +72826,11 @@ function createTypeChecker(host) {
|
|
|
72800
72826
|
links.jsxFlags |= 2 /* IntrinsicIndexedElement */;
|
|
72801
72827
|
return links.resolvedSymbol = intrinsicElementsType.symbol;
|
|
72802
72828
|
}
|
|
72803
|
-
|
|
72829
|
+
error2(node, Diagnostics.Property_0_does_not_exist_on_type_1, intrinsicTagNameToString(node.tagName), "JSX." + JsxNames.IntrinsicElements);
|
|
72804
72830
|
return links.resolvedSymbol = unknownSymbol;
|
|
72805
72831
|
} else {
|
|
72806
72832
|
if (noImplicitAny) {
|
|
72807
|
-
|
|
72833
|
+
error2(node, Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, unescapeLeadingUnderscores(JsxNames.IntrinsicElements));
|
|
72808
72834
|
}
|
|
72809
72835
|
return links.resolvedSymbol = unknownSymbol;
|
|
72810
72836
|
}
|
|
@@ -72887,7 +72913,7 @@ function createTypeChecker(host) {
|
|
|
72887
72913
|
} else if (propertiesOfJsxElementAttribPropInterface.length === 1) {
|
|
72888
72914
|
return propertiesOfJsxElementAttribPropInterface[0].escapedName;
|
|
72889
72915
|
} else if (propertiesOfJsxElementAttribPropInterface.length > 1 && jsxElementAttribPropInterfaceSym.declarations) {
|
|
72890
|
-
|
|
72916
|
+
error2(jsxElementAttribPropInterfaceSym.declarations[0], Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, unescapeLeadingUnderscores(nameOfAttribPropContainer));
|
|
72891
72917
|
}
|
|
72892
72918
|
}
|
|
72893
72919
|
return void 0;
|
|
@@ -72910,7 +72936,7 @@ function createTypeChecker(host) {
|
|
|
72910
72936
|
} else if (elementType.flags & 128 /* StringLiteral */) {
|
|
72911
72937
|
const intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(elementType, caller);
|
|
72912
72938
|
if (!intrinsicType) {
|
|
72913
|
-
|
|
72939
|
+
error2(caller, Diagnostics.Property_0_does_not_exist_on_type_1, elementType.value, "JSX." + JsxNames.IntrinsicElements);
|
|
72914
72940
|
return emptyArray;
|
|
72915
72941
|
} else {
|
|
72916
72942
|
const fakeSignature = createSignatureForJSXIntrinsic(caller, intrinsicType);
|
|
@@ -73036,11 +73062,11 @@ function createTypeChecker(host) {
|
|
|
73036
73062
|
}
|
|
73037
73063
|
function checkJsxPreconditions(errorNode) {
|
|
73038
73064
|
if ((compilerOptions.jsx || 0 /* None */) === 0 /* None */) {
|
|
73039
|
-
|
|
73065
|
+
error2(errorNode, Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided);
|
|
73040
73066
|
}
|
|
73041
73067
|
if (getJsxElementTypeAt(errorNode) === void 0) {
|
|
73042
73068
|
if (noImplicitAny) {
|
|
73043
|
-
|
|
73069
|
+
error2(errorNode, Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist);
|
|
73044
73070
|
}
|
|
73045
73071
|
}
|
|
73046
73072
|
}
|
|
@@ -73132,7 +73158,7 @@ function createTypeChecker(host) {
|
|
|
73132
73158
|
if (node.expression) {
|
|
73133
73159
|
const type = checkExpression(node.expression, checkMode);
|
|
73134
73160
|
if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) {
|
|
73135
|
-
|
|
73161
|
+
error2(node, Diagnostics.JSX_spread_child_must_be_an_array_type);
|
|
73136
73162
|
}
|
|
73137
73163
|
return type;
|
|
73138
73164
|
} else {
|
|
@@ -73161,14 +73187,14 @@ function createTypeChecker(host) {
|
|
|
73161
73187
|
if (languageVersion < 2 /* ES2015 */) {
|
|
73162
73188
|
if (symbolHasNonMethodDeclaration(prop)) {
|
|
73163
73189
|
if (errorNode) {
|
|
73164
|
-
|
|
73190
|
+
error2(errorNode, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword);
|
|
73165
73191
|
}
|
|
73166
73192
|
return false;
|
|
73167
73193
|
}
|
|
73168
73194
|
}
|
|
73169
73195
|
if (flags & 256 /* Abstract */) {
|
|
73170
73196
|
if (errorNode) {
|
|
73171
|
-
|
|
73197
|
+
error2(
|
|
73172
73198
|
errorNode,
|
|
73173
73199
|
Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression,
|
|
73174
73200
|
symbolToString(prop),
|
|
@@ -73182,7 +73208,7 @@ function createTypeChecker(host) {
|
|
|
73182
73208
|
const declaringClassDeclaration = getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop));
|
|
73183
73209
|
if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(location)) {
|
|
73184
73210
|
if (errorNode) {
|
|
73185
|
-
|
|
73211
|
+
error2(
|
|
73186
73212
|
errorNode,
|
|
73187
73213
|
Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor,
|
|
73188
73214
|
symbolToString(prop),
|
|
@@ -73199,7 +73225,7 @@ function createTypeChecker(host) {
|
|
|
73199
73225
|
const declaringClassDeclaration = getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop));
|
|
73200
73226
|
if (!isNodeWithinClass(location, declaringClassDeclaration)) {
|
|
73201
73227
|
if (errorNode) {
|
|
73202
|
-
|
|
73228
|
+
error2(
|
|
73203
73229
|
errorNode,
|
|
73204
73230
|
Diagnostics.Property_0_is_private_and_only_accessible_within_class_1,
|
|
73205
73231
|
symbolToString(prop),
|
|
@@ -73222,7 +73248,7 @@ function createTypeChecker(host) {
|
|
|
73222
73248
|
enclosingClass = enclosingClass && isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing);
|
|
73223
73249
|
if (flags & 32 /* Static */ || !enclosingClass) {
|
|
73224
73250
|
if (errorNode) {
|
|
73225
|
-
|
|
73251
|
+
error2(
|
|
73226
73252
|
errorNode,
|
|
73227
73253
|
Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses,
|
|
73228
73254
|
symbolToString(prop),
|
|
@@ -73240,7 +73266,7 @@ function createTypeChecker(host) {
|
|
|
73240
73266
|
}
|
|
73241
73267
|
if (!containingType || !hasBaseType(containingType, enclosingClass)) {
|
|
73242
73268
|
if (errorNode) {
|
|
73243
|
-
|
|
73269
|
+
error2(
|
|
73244
73270
|
errorNode,
|
|
73245
73271
|
Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_class_2,
|
|
73246
73272
|
symbolToString(prop),
|
|
@@ -73288,28 +73314,28 @@ function createTypeChecker(host) {
|
|
|
73288
73314
|
function reportObjectPossiblyNullOrUndefinedError(node, facts) {
|
|
73289
73315
|
const nodeText2 = isEntityNameExpression(node) ? entityNameToString(node) : void 0;
|
|
73290
73316
|
if (node.kind === 106 /* NullKeyword */) {
|
|
73291
|
-
|
|
73317
|
+
error2(node, Diagnostics.The_value_0_cannot_be_used_here, "null");
|
|
73292
73318
|
return;
|
|
73293
73319
|
}
|
|
73294
73320
|
if (nodeText2 !== void 0 && nodeText2.length < 100) {
|
|
73295
73321
|
if (isIdentifier(node) && nodeText2 === "undefined") {
|
|
73296
|
-
|
|
73322
|
+
error2(node, Diagnostics.The_value_0_cannot_be_used_here, "undefined");
|
|
73297
73323
|
return;
|
|
73298
73324
|
}
|
|
73299
|
-
|
|
73325
|
+
error2(
|
|
73300
73326
|
node,
|
|
73301
73327
|
facts & 16777216 /* IsUndefined */ ? facts & 33554432 /* IsNull */ ? Diagnostics._0_is_possibly_null_or_undefined : Diagnostics._0_is_possibly_undefined : Diagnostics._0_is_possibly_null,
|
|
73302
73328
|
nodeText2
|
|
73303
73329
|
);
|
|
73304
73330
|
} else {
|
|
73305
|
-
|
|
73331
|
+
error2(
|
|
73306
73332
|
node,
|
|
73307
73333
|
facts & 16777216 /* IsUndefined */ ? facts & 33554432 /* IsNull */ ? Diagnostics.Object_is_possibly_null_or_undefined : Diagnostics.Object_is_possibly_undefined : Diagnostics.Object_is_possibly_null
|
|
73308
73334
|
);
|
|
73309
73335
|
}
|
|
73310
73336
|
}
|
|
73311
73337
|
function reportCannotInvokePossiblyNullOrUndefinedError(node, facts) {
|
|
73312
|
-
|
|
73338
|
+
error2(
|
|
73313
73339
|
node,
|
|
73314
73340
|
facts & 16777216 /* IsUndefined */ ? facts & 33554432 /* IsNull */ ? Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined : Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined : Diagnostics.Cannot_invoke_an_object_which_is_possibly_null
|
|
73315
73341
|
);
|
|
@@ -73319,11 +73345,11 @@ function createTypeChecker(host) {
|
|
|
73319
73345
|
if (isEntityNameExpression(node)) {
|
|
73320
73346
|
const nodeText2 = entityNameToString(node);
|
|
73321
73347
|
if (nodeText2.length < 100) {
|
|
73322
|
-
|
|
73348
|
+
error2(node, Diagnostics._0_is_of_type_unknown, nodeText2);
|
|
73323
73349
|
return errorType;
|
|
73324
73350
|
}
|
|
73325
73351
|
}
|
|
73326
|
-
|
|
73352
|
+
error2(node, Diagnostics.Object_is_of_type_unknown);
|
|
73327
73353
|
return errorType;
|
|
73328
73354
|
}
|
|
73329
73355
|
const facts = getTypeFacts(type);
|
|
@@ -73343,15 +73369,15 @@ function createTypeChecker(host) {
|
|
|
73343
73369
|
if (isEntityNameExpression(node)) {
|
|
73344
73370
|
const nodeText2 = entityNameToString(node);
|
|
73345
73371
|
if (isIdentifier(node) && nodeText2 === "undefined") {
|
|
73346
|
-
|
|
73372
|
+
error2(node, Diagnostics.The_value_0_cannot_be_used_here, nodeText2);
|
|
73347
73373
|
return nonNullType;
|
|
73348
73374
|
}
|
|
73349
73375
|
if (nodeText2.length < 100) {
|
|
73350
|
-
|
|
73376
|
+
error2(node, Diagnostics._0_is_possibly_undefined, nodeText2);
|
|
73351
73377
|
return nonNullType;
|
|
73352
73378
|
}
|
|
73353
73379
|
}
|
|
73354
|
-
|
|
73380
|
+
error2(node, Diagnostics.Object_is_possibly_undefined);
|
|
73355
73381
|
}
|
|
73356
73382
|
return nonNullType;
|
|
73357
73383
|
}
|
|
@@ -73446,7 +73472,7 @@ function createTypeChecker(host) {
|
|
|
73446
73472
|
const lexicalClass = getContainingClass(lexicalValueDecl);
|
|
73447
73473
|
Debug.assert(!!lexicalClass);
|
|
73448
73474
|
if (findAncestor(lexicalClass, (n) => typeClass === n)) {
|
|
73449
|
-
const diagnostic =
|
|
73475
|
+
const diagnostic = error2(
|
|
73450
73476
|
right,
|
|
73451
73477
|
Diagnostics.The_property_0_cannot_be_accessed_on_type_1_within_this_class_because_it_is_shadowed_by_another_private_identifier_with_the_same_spelling,
|
|
73452
73478
|
diagName,
|
|
@@ -73468,7 +73494,7 @@ function createTypeChecker(host) {
|
|
|
73468
73494
|
return true;
|
|
73469
73495
|
}
|
|
73470
73496
|
}
|
|
73471
|
-
|
|
73497
|
+
error2(
|
|
73472
73498
|
right,
|
|
73473
73499
|
Diagnostics.Property_0_is_not_accessible_outside_class_1_because_it_has_a_private_identifier,
|
|
73474
73500
|
diagName,
|
|
@@ -73521,7 +73547,7 @@ function createTypeChecker(host) {
|
|
|
73521
73547
|
} else {
|
|
73522
73548
|
const isSetonlyAccessor = prop && prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */);
|
|
73523
73549
|
if (isSetonlyAccessor && assignmentKind !== 1 /* Definite */) {
|
|
73524
|
-
|
|
73550
|
+
error2(node, Diagnostics.Private_accessor_was_defined_without_a_getter);
|
|
73525
73551
|
}
|
|
73526
73552
|
}
|
|
73527
73553
|
} else {
|
|
@@ -73558,9 +73584,9 @@ function createTypeChecker(host) {
|
|
|
73558
73584
|
}
|
|
73559
73585
|
if (leftType.symbol === globalThisSymbol) {
|
|
73560
73586
|
if (globalThisSymbol.exports.has(right.escapedText) && globalThisSymbol.exports.get(right.escapedText).flags & 418 /* BlockScoped */) {
|
|
73561
|
-
|
|
73587
|
+
error2(right, Diagnostics.Property_0_does_not_exist_on_type_1, unescapeLeadingUnderscores(right.escapedText), typeToString(leftType));
|
|
73562
73588
|
} else if (noImplicitAny) {
|
|
73563
|
-
|
|
73589
|
+
error2(right, Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(leftType));
|
|
73564
73590
|
}
|
|
73565
73591
|
return anyType;
|
|
73566
73592
|
}
|
|
@@ -73570,11 +73596,11 @@ function createTypeChecker(host) {
|
|
|
73570
73596
|
return errorType;
|
|
73571
73597
|
}
|
|
73572
73598
|
if (indexInfo.isReadonly && (isAssignmentTarget(node) || isDeleteTarget(node))) {
|
|
73573
|
-
|
|
73599
|
+
error2(node, Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(apparentType));
|
|
73574
73600
|
}
|
|
73575
73601
|
propType = compilerOptions.noUncheckedIndexedAccess && !isAssignmentTarget(node) ? getUnionType([indexInfo.type, missingType]) : indexInfo.type;
|
|
73576
73602
|
if (compilerOptions.noPropertyAccessFromIndexSignature && isPropertyAccessExpression(node)) {
|
|
73577
|
-
|
|
73603
|
+
error2(right, Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, unescapeLeadingUnderscores(right.escapedText));
|
|
73578
73604
|
}
|
|
73579
73605
|
if (indexInfo.declaration && getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* Deprecated */) {
|
|
73580
73606
|
addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText);
|
|
@@ -73589,7 +73615,7 @@ function createTypeChecker(host) {
|
|
|
73589
73615
|
getNodeLinks(node).resolvedSymbol = prop;
|
|
73590
73616
|
checkPropertyAccessibility(node, left.kind === 108 /* SuperKeyword */, isWriteAccess(node), apparentType, prop);
|
|
73591
73617
|
if (isAssignmentToReadonlyEntity(node, prop, assignmentKind)) {
|
|
73592
|
-
|
|
73618
|
+
error2(right, Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, idText(right));
|
|
73593
73619
|
return errorType;
|
|
73594
73620
|
}
|
|
73595
73621
|
propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : writeOnly || isWriteOnlyAccess(node) ? getWriteTypeOfSymbol(prop) : getTypeOfSymbol(prop);
|
|
@@ -73634,7 +73660,7 @@ function createTypeChecker(host) {
|
|
|
73634
73660
|
}
|
|
73635
73661
|
const flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType);
|
|
73636
73662
|
if (assumeUninitialized && !containsUndefinedType(propType) && containsUndefinedType(flowType)) {
|
|
73637
|
-
|
|
73663
|
+
error2(errorNode, Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop));
|
|
73638
73664
|
return propType;
|
|
73639
73665
|
}
|
|
73640
73666
|
return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
|
|
@@ -73647,9 +73673,9 @@ function createTypeChecker(host) {
|
|
|
73647
73673
|
let diagnosticMessage;
|
|
73648
73674
|
const declarationName = idText(right);
|
|
73649
73675
|
if (isInPropertyInitializerOrClassStaticBlock(node) && !isOptionalPropertyDeclaration(valueDeclaration) && !(isAccessExpression(node) && isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && !(isMethodDeclaration(valueDeclaration) && getCombinedModifierFlags(valueDeclaration) & 32 /* Static */) && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) {
|
|
73650
|
-
diagnosticMessage =
|
|
73676
|
+
diagnosticMessage = error2(right, Diagnostics.Property_0_is_used_before_its_initialization, declarationName);
|
|
73651
73677
|
} else if (valueDeclaration.kind === 262 /* ClassDeclaration */ && node.parent.kind !== 182 /* TypeReference */ && !(valueDeclaration.flags & 16777216 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) {
|
|
73652
|
-
diagnosticMessage =
|
|
73678
|
+
diagnosticMessage = error2(right, Diagnostics.Class_0_used_before_its_declaration, declarationName);
|
|
73653
73679
|
}
|
|
73654
73680
|
if (diagnosticMessage) {
|
|
73655
73681
|
addRelatedInfo(
|
|
@@ -74027,7 +74053,7 @@ function createTypeChecker(host) {
|
|
|
74027
74053
|
return objectType;
|
|
74028
74054
|
}
|
|
74029
74055
|
if (isConstEnumObjectType(objectType) && !isStringLiteralLike(indexExpression)) {
|
|
74030
|
-
|
|
74056
|
+
error2(indexExpression, Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal);
|
|
74031
74057
|
return errorType;
|
|
74032
74058
|
}
|
|
74033
74059
|
const effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType;
|
|
@@ -74261,7 +74287,7 @@ function createTypeChecker(host) {
|
|
|
74261
74287
|
}
|
|
74262
74288
|
for (let i = 0; i < argCount; i++) {
|
|
74263
74289
|
const arg = args[i];
|
|
74264
|
-
if (arg.kind !== 231 /* OmittedExpression */ && !(checkMode &
|
|
74290
|
+
if (arg.kind !== 231 /* OmittedExpression */ && !(checkMode & 64 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
|
|
74265
74291
|
const paramType = getTypeAtPosition(signature, i);
|
|
74266
74292
|
if (couldContainTypeVariables(paramType)) {
|
|
74267
74293
|
const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
|
|
@@ -74734,7 +74760,7 @@ function createTypeChecker(host) {
|
|
|
74734
74760
|
if (isVoidPromiseError && isInJSFile(node)) {
|
|
74735
74761
|
return getDiagnosticForCallNode(node, Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments);
|
|
74736
74762
|
}
|
|
74737
|
-
const
|
|
74763
|
+
const error3 = isDecorator(node) ? hasRestParameter2 ? Diagnostics.The_runtime_will_invoke_the_decorator_with_1_arguments_but_the_decorator_expects_at_least_0 : Diagnostics.The_runtime_will_invoke_the_decorator_with_1_arguments_but_the_decorator_expects_0 : hasRestParameter2 ? Diagnostics.Expected_at_least_0_arguments_but_got_1 : isVoidPromiseError ? Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise : Diagnostics.Expected_0_arguments_but_got_1;
|
|
74738
74764
|
if (min2 < args.length && args.length < max) {
|
|
74739
74765
|
if (headMessage) {
|
|
74740
74766
|
let chain = chainDiagnosticMessages(
|
|
@@ -74755,14 +74781,14 @@ function createTypeChecker(host) {
|
|
|
74755
74781
|
let chain = chainDiagnosticMessages(
|
|
74756
74782
|
/*details*/
|
|
74757
74783
|
void 0,
|
|
74758
|
-
|
|
74784
|
+
error3,
|
|
74759
74785
|
parameterRange,
|
|
74760
74786
|
args.length
|
|
74761
74787
|
);
|
|
74762
74788
|
chain = chainDiagnosticMessages(chain, headMessage);
|
|
74763
74789
|
diagnostic = getDiagnosticForCallNode(node, chain);
|
|
74764
74790
|
} else {
|
|
74765
|
-
diagnostic = getDiagnosticForCallNode(node,
|
|
74791
|
+
diagnostic = getDiagnosticForCallNode(node, error3, parameterRange, args.length);
|
|
74766
74792
|
}
|
|
74767
74793
|
const parameter = (_a = closestSignature == null ? void 0 : closestSignature.declaration) == null ? void 0 : _a.parameters[closestSignature.thisParameter ? args.length + 1 : args.length];
|
|
74768
74794
|
if (parameter) {
|
|
@@ -74783,14 +74809,14 @@ function createTypeChecker(host) {
|
|
|
74783
74809
|
let chain = chainDiagnosticMessages(
|
|
74784
74810
|
/*details*/
|
|
74785
74811
|
void 0,
|
|
74786
|
-
|
|
74812
|
+
error3,
|
|
74787
74813
|
parameterRange,
|
|
74788
74814
|
args.length
|
|
74789
74815
|
);
|
|
74790
74816
|
chain = chainDiagnosticMessages(chain, headMessage);
|
|
74791
74817
|
return createDiagnosticForNodeArrayFromMessageChain(getSourceFileOfNode(node), errorSpan, chain);
|
|
74792
74818
|
}
|
|
74793
|
-
return createDiagnosticForNodeArray(getSourceFileOfNode(node), errorSpan,
|
|
74819
|
+
return createDiagnosticForNodeArray(getSourceFileOfNode(node), errorSpan, error3, parameterRange, args.length);
|
|
74794
74820
|
}
|
|
74795
74821
|
}
|
|
74796
74822
|
function getTypeArgumentArityError(node, signatures, typeArguments, headMessage) {
|
|
@@ -74874,12 +74900,12 @@ function createTypeChecker(host) {
|
|
|
74874
74900
|
const args = getEffectiveCallArguments(node);
|
|
74875
74901
|
const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
|
|
74876
74902
|
let argCheckMode = !isDecorator2 && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
|
|
74877
|
-
argCheckMode |= checkMode &
|
|
74903
|
+
argCheckMode |= checkMode & 64 /* IsForStringLiteralArgumentCompletions */;
|
|
74878
74904
|
let candidatesForArgumentError;
|
|
74879
74905
|
let candidateForArgumentArityError;
|
|
74880
74906
|
let candidateForTypeArgumentError;
|
|
74881
74907
|
let result;
|
|
74882
|
-
const signatureHelpTrailingComma = !!(checkMode &
|
|
74908
|
+
const signatureHelpTrailingComma = !!(checkMode & 32 /* IsForSignatureHelp */) && node.kind === 212 /* CallExpression */ && node.arguments.hasTrailingComma;
|
|
74883
74909
|
if (candidates.length > 1) {
|
|
74884
74910
|
result = chooseOverload(candidates, subtypeRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
|
|
74885
74911
|
}
|
|
@@ -75098,7 +75124,7 @@ function createTypeChecker(host) {
|
|
|
75098
75124
|
continue;
|
|
75099
75125
|
}
|
|
75100
75126
|
if (argCheckMode) {
|
|
75101
|
-
argCheckMode = checkMode &
|
|
75127
|
+
argCheckMode = checkMode & 64 /* IsForStringLiteralArgumentCompletions */;
|
|
75102
75128
|
if (inferenceContext) {
|
|
75103
75129
|
const typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
|
|
75104
75130
|
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
|
|
@@ -75272,13 +75298,13 @@ function createTypeChecker(host) {
|
|
|
75272
75298
|
const numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length;
|
|
75273
75299
|
if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) {
|
|
75274
75300
|
if (!isErrorType(funcType) && node.typeArguments) {
|
|
75275
|
-
|
|
75301
|
+
error2(node, Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
|
|
75276
75302
|
}
|
|
75277
75303
|
return resolveUntypedCall(node);
|
|
75278
75304
|
}
|
|
75279
75305
|
if (!callSignatures.length) {
|
|
75280
75306
|
if (numConstructSignatures) {
|
|
75281
|
-
|
|
75307
|
+
error2(node, Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
|
|
75282
75308
|
} else {
|
|
75283
75309
|
let relatedInformation;
|
|
75284
75310
|
if (node.arguments.length === 1) {
|
|
@@ -75301,7 +75327,7 @@ function createTypeChecker(host) {
|
|
|
75301
75327
|
return resolvingSignature;
|
|
75302
75328
|
}
|
|
75303
75329
|
if (callSignatures.some((sig) => isInJSFile(sig.declaration) && !!getJSDocClassTag(sig.declaration))) {
|
|
75304
|
-
|
|
75330
|
+
error2(node, Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
|
|
75305
75331
|
return resolveErrorCall(node);
|
|
75306
75332
|
}
|
|
75307
75333
|
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
|
|
@@ -75316,7 +75342,7 @@ function createTypeChecker(host) {
|
|
|
75316
75342
|
if (node.arguments && languageVersion < 1 /* ES5 */) {
|
|
75317
75343
|
const spreadIndex = getSpreadArgumentIndex(node.arguments);
|
|
75318
75344
|
if (spreadIndex >= 0) {
|
|
75319
|
-
|
|
75345
|
+
error2(node.arguments[spreadIndex], Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher);
|
|
75320
75346
|
}
|
|
75321
75347
|
}
|
|
75322
75348
|
let expressionType = checkNonNullExpression(node.expression);
|
|
@@ -75329,7 +75355,7 @@ function createTypeChecker(host) {
|
|
|
75329
75355
|
}
|
|
75330
75356
|
if (isTypeAny(expressionType)) {
|
|
75331
75357
|
if (node.typeArguments) {
|
|
75332
|
-
|
|
75358
|
+
error2(node, Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
|
|
75333
75359
|
}
|
|
75334
75360
|
return resolveUntypedCall(node);
|
|
75335
75361
|
}
|
|
@@ -75339,12 +75365,12 @@ function createTypeChecker(host) {
|
|
|
75339
75365
|
return resolveErrorCall(node);
|
|
75340
75366
|
}
|
|
75341
75367
|
if (someSignature(constructSignatures, (signature) => !!(signature.flags & 4 /* Abstract */))) {
|
|
75342
|
-
|
|
75368
|
+
error2(node, Diagnostics.Cannot_create_an_instance_of_an_abstract_class);
|
|
75343
75369
|
return resolveErrorCall(node);
|
|
75344
75370
|
}
|
|
75345
75371
|
const valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol);
|
|
75346
75372
|
if (valueDecl && hasSyntacticModifier(valueDecl, 256 /* Abstract */)) {
|
|
75347
|
-
|
|
75373
|
+
error2(node, Diagnostics.Cannot_create_an_instance_of_an_abstract_class);
|
|
75348
75374
|
return resolveErrorCall(node);
|
|
75349
75375
|
}
|
|
75350
75376
|
return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* None */);
|
|
@@ -75354,10 +75380,10 @@ function createTypeChecker(host) {
|
|
|
75354
75380
|
const signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */);
|
|
75355
75381
|
if (!noImplicitAny) {
|
|
75356
75382
|
if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) {
|
|
75357
|
-
|
|
75383
|
+
error2(node, Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword);
|
|
75358
75384
|
}
|
|
75359
75385
|
if (getThisTypeOfSignature(signature) === voidType) {
|
|
75360
|
-
|
|
75386
|
+
error2(node, Diagnostics.A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void);
|
|
75361
75387
|
}
|
|
75362
75388
|
}
|
|
75363
75389
|
return signature;
|
|
@@ -75421,10 +75447,10 @@ function createTypeChecker(host) {
|
|
|
75421
75447
|
}
|
|
75422
75448
|
}
|
|
75423
75449
|
if (modifiers & 8 /* Private */) {
|
|
75424
|
-
|
|
75450
|
+
error2(node, Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass));
|
|
75425
75451
|
}
|
|
75426
75452
|
if (modifiers & 16 /* Protected */) {
|
|
75427
|
-
|
|
75453
|
+
error2(node, Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass));
|
|
75428
75454
|
}
|
|
75429
75455
|
return false;
|
|
75430
75456
|
}
|
|
@@ -75586,7 +75612,7 @@ function createTypeChecker(host) {
|
|
|
75586
75612
|
/*includeTrivia*/
|
|
75587
75613
|
false
|
|
75588
75614
|
);
|
|
75589
|
-
|
|
75615
|
+
error2(node, Diagnostics._0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0, nodeStr);
|
|
75590
75616
|
return resolveErrorCall(node);
|
|
75591
75617
|
}
|
|
75592
75618
|
const headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
|
|
@@ -75676,7 +75702,7 @@ function createTypeChecker(host) {
|
|
|
75676
75702
|
return resolveUntypedCall(node);
|
|
75677
75703
|
}
|
|
75678
75704
|
if (signatures.length === 0) {
|
|
75679
|
-
|
|
75705
|
+
error2(node.tagName, Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, getTextOfNode(node.tagName));
|
|
75680
75706
|
return resolveErrorCall(node);
|
|
75681
75707
|
}
|
|
75682
75708
|
return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* None */);
|
|
@@ -75836,7 +75862,7 @@ function createTypeChecker(host) {
|
|
|
75836
75862
|
const declaration = signature.declaration;
|
|
75837
75863
|
if (declaration && declaration.kind !== 175 /* Constructor */ && declaration.kind !== 179 /* ConstructSignature */ && declaration.kind !== 184 /* ConstructorType */ && !(isJSDocSignature(declaration) && ((_b = (_a = getJSDocRoot(declaration)) == null ? void 0 : _a.parent) == null ? void 0 : _b.kind) === 175 /* Constructor */) && !isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) {
|
|
75838
75864
|
if (noImplicitAny) {
|
|
75839
|
-
|
|
75865
|
+
error2(node, Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type);
|
|
75840
75866
|
}
|
|
75841
75867
|
return anyType;
|
|
75842
75868
|
}
|
|
@@ -75850,9 +75876,9 @@ function createTypeChecker(host) {
|
|
|
75850
75876
|
}
|
|
75851
75877
|
if (node.kind === 212 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 243 /* ExpressionStatement */ && returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) {
|
|
75852
75878
|
if (!isDottedName(node.expression)) {
|
|
75853
|
-
|
|
75879
|
+
error2(node.expression, Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name);
|
|
75854
75880
|
} else if (!getEffectsSignature(node)) {
|
|
75855
|
-
const diagnostic =
|
|
75881
|
+
const diagnostic = error2(node.expression, Diagnostics.Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation);
|
|
75856
75882
|
getTypeOfDottedName(node.expression, diagnostic);
|
|
75857
75883
|
}
|
|
75858
75884
|
}
|
|
@@ -75941,7 +75967,7 @@ function createTypeChecker(host) {
|
|
|
75941
75967
|
checkExpressionCached(node.arguments[i]);
|
|
75942
75968
|
}
|
|
75943
75969
|
if (specifierType.flags & 32768 /* Undefined */ || specifierType.flags & 65536 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) {
|
|
75944
|
-
|
|
75970
|
+
error2(specifier, Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType));
|
|
75945
75971
|
}
|
|
75946
75972
|
if (optionsType) {
|
|
75947
75973
|
const importCallOptionsType = getGlobalImportCallOptionsType(
|
|
@@ -76115,7 +76141,7 @@ function createTypeChecker(host) {
|
|
|
76115
76141
|
const exprType = checkExpression(expression, checkMode);
|
|
76116
76142
|
if (isConstTypeReference(type)) {
|
|
76117
76143
|
if (!isValidConstAssertionArgument(expression)) {
|
|
76118
|
-
|
|
76144
|
+
error2(expression, Diagnostics.A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals);
|
|
76119
76145
|
}
|
|
76120
76146
|
return getRegularTypeOfLiteralType(exprType);
|
|
76121
76147
|
}
|
|
@@ -76176,7 +76202,7 @@ function createTypeChecker(host) {
|
|
|
76176
76202
|
if (node.kind === 232 /* ExpressionWithTypeArguments */) {
|
|
76177
76203
|
const parent2 = walkUpParenthesizedExpressions(node.parent);
|
|
76178
76204
|
if (parent2.kind === 225 /* BinaryExpression */ && parent2.operatorToken.kind === 104 /* InstanceOfKeyword */ && isNodeDescendantOf(node, parent2.right)) {
|
|
76179
|
-
|
|
76205
|
+
error2(node, Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression);
|
|
76180
76206
|
}
|
|
76181
76207
|
}
|
|
76182
76208
|
const exprType = node.kind === 232 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) : isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName);
|
|
@@ -76291,7 +76317,7 @@ function createTypeChecker(host) {
|
|
|
76291
76317
|
function checkNewTargetMetaProperty(node) {
|
|
76292
76318
|
const container = getNewTargetContainer(node);
|
|
76293
76319
|
if (!container) {
|
|
76294
|
-
|
|
76320
|
+
error2(node, Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target");
|
|
76295
76321
|
return errorType;
|
|
76296
76322
|
} else if (container.kind === 175 /* Constructor */) {
|
|
76297
76323
|
const symbol = getSymbolOfDeclaration(container.parent);
|
|
@@ -76304,10 +76330,10 @@ function createTypeChecker(host) {
|
|
|
76304
76330
|
function checkImportMetaProperty(node) {
|
|
76305
76331
|
if (moduleKind === 100 /* Node16 */ || moduleKind === 199 /* NodeNext */) {
|
|
76306
76332
|
if (getSourceFileOfNode(node).impliedNodeFormat !== 99 /* ESNext */) {
|
|
76307
|
-
|
|
76333
|
+
error2(node, Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output);
|
|
76308
76334
|
}
|
|
76309
76335
|
} else if (moduleKind < 6 /* ES2020 */ && moduleKind !== 4 /* System */) {
|
|
76310
|
-
|
|
76336
|
+
error2(node, Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext);
|
|
76311
76337
|
}
|
|
76312
76338
|
const file = getSourceFileOfNode(node);
|
|
76313
76339
|
Debug.assert(!!(file.flags & 4194304 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag.");
|
|
@@ -76864,13 +76890,13 @@ function createTypeChecker(host) {
|
|
|
76864
76890
|
function createPromiseReturnType(func, promisedType) {
|
|
76865
76891
|
const promiseType = createPromiseType(promisedType);
|
|
76866
76892
|
if (promiseType === unknownType) {
|
|
76867
|
-
|
|
76893
|
+
error2(func, isImportCall(func) ? Diagnostics.A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option : Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option);
|
|
76868
76894
|
return errorType;
|
|
76869
76895
|
} else if (!getGlobalPromiseConstructorSymbol(
|
|
76870
76896
|
/*reportErrors*/
|
|
76871
76897
|
true
|
|
76872
76898
|
)) {
|
|
76873
|
-
|
|
76899
|
+
error2(func, isImportCall(func) ? Diagnostics.A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option : Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option);
|
|
76874
76900
|
}
|
|
76875
76901
|
return promiseType;
|
|
76876
76902
|
}
|
|
@@ -77166,11 +77192,11 @@ function createTypeChecker(host) {
|
|
|
77166
77192
|
const hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */;
|
|
77167
77193
|
const errorNode = getEffectiveReturnTypeNode(func) || func;
|
|
77168
77194
|
if (type && type.flags & 131072 /* Never */) {
|
|
77169
|
-
|
|
77195
|
+
error2(errorNode, Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
|
|
77170
77196
|
} else if (type && !hasExplicitReturn) {
|
|
77171
|
-
|
|
77197
|
+
error2(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value);
|
|
77172
77198
|
} else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
|
|
77173
|
-
|
|
77199
|
+
error2(errorNode, Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
|
|
77174
77200
|
} else if (compilerOptions.noImplicitReturns) {
|
|
77175
77201
|
if (!type) {
|
|
77176
77202
|
if (!hasExplicitReturn) {
|
|
@@ -77181,7 +77207,7 @@ function createTypeChecker(host) {
|
|
|
77181
77207
|
return;
|
|
77182
77208
|
}
|
|
77183
77209
|
}
|
|
77184
|
-
|
|
77210
|
+
error2(errorNode, Diagnostics.Not_all_code_paths_return_a_value);
|
|
77185
77211
|
}
|
|
77186
77212
|
}
|
|
77187
77213
|
}
|
|
@@ -77381,11 +77407,11 @@ function createTypeChecker(host) {
|
|
|
77381
77407
|
function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) {
|
|
77382
77408
|
const node = skipOuterExpressions(expr, 6 /* Assertions */ | 1 /* Parentheses */);
|
|
77383
77409
|
if (node.kind !== 80 /* Identifier */ && !isAccessExpression(node)) {
|
|
77384
|
-
|
|
77410
|
+
error2(expr, invalidReferenceMessage);
|
|
77385
77411
|
return false;
|
|
77386
77412
|
}
|
|
77387
77413
|
if (node.flags & 32 /* OptionalChain */) {
|
|
77388
|
-
|
|
77414
|
+
error2(expr, invalidOptionalChainMessage);
|
|
77389
77415
|
return false;
|
|
77390
77416
|
}
|
|
77391
77417
|
return true;
|
|
@@ -77394,17 +77420,17 @@ function createTypeChecker(host) {
|
|
|
77394
77420
|
checkExpression(node.expression);
|
|
77395
77421
|
const expr = skipParentheses(node.expression);
|
|
77396
77422
|
if (!isAccessExpression(expr)) {
|
|
77397
|
-
|
|
77423
|
+
error2(expr, Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference);
|
|
77398
77424
|
return booleanType;
|
|
77399
77425
|
}
|
|
77400
77426
|
if (isPropertyAccessExpression(expr) && isPrivateIdentifier(expr.name)) {
|
|
77401
|
-
|
|
77427
|
+
error2(expr, Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_private_identifier);
|
|
77402
77428
|
}
|
|
77403
77429
|
const links = getNodeLinks(expr);
|
|
77404
77430
|
const symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol);
|
|
77405
77431
|
if (symbol) {
|
|
77406
77432
|
if (isReadonlySymbol(symbol)) {
|
|
77407
|
-
|
|
77433
|
+
error2(expr, Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property);
|
|
77408
77434
|
}
|
|
77409
77435
|
checkDeleteExpressionMustBeOptional(expr, symbol);
|
|
77410
77436
|
}
|
|
@@ -77413,7 +77439,7 @@ function createTypeChecker(host) {
|
|
|
77413
77439
|
function checkDeleteExpressionMustBeOptional(expr, symbol) {
|
|
77414
77440
|
const type = getTypeOfSymbol(symbol);
|
|
77415
77441
|
if (strictNullChecks && !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : getTypeFacts(type) & 16777216 /* IsUndefined */)) {
|
|
77416
|
-
|
|
77442
|
+
error2(expr, Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
|
|
77417
77443
|
}
|
|
77418
77444
|
}
|
|
77419
77445
|
function checkTypeOfExpression(node) {
|
|
@@ -77427,7 +77453,7 @@ function createTypeChecker(host) {
|
|
|
77427
77453
|
function checkAwaitExpressionGrammar(node) {
|
|
77428
77454
|
const container = getContainingFunctionOrClassStaticBlock(node);
|
|
77429
77455
|
if (container && isClassStaticBlockDeclaration(container)) {
|
|
77430
|
-
|
|
77456
|
+
error2(node, Diagnostics.Await_expression_cannot_be_used_inside_a_class_static_block);
|
|
77431
77457
|
} else if (!(node.flags & 32768 /* AwaitContext */)) {
|
|
77432
77458
|
if (isInTopLevelContext(node)) {
|
|
77433
77459
|
const sourceFile = getSourceFileOfNode(node);
|
|
@@ -77486,7 +77512,7 @@ function createTypeChecker(host) {
|
|
|
77486
77512
|
}
|
|
77487
77513
|
}
|
|
77488
77514
|
if (isInParameterInitializerBeforeContainingFunction(node)) {
|
|
77489
|
-
|
|
77515
|
+
error2(node, Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer);
|
|
77490
77516
|
}
|
|
77491
77517
|
}
|
|
77492
77518
|
function checkAwaitExpression(node) {
|
|
@@ -77536,11 +77562,11 @@ function createTypeChecker(host) {
|
|
|
77536
77562
|
case 55 /* TildeToken */:
|
|
77537
77563
|
checkNonNullType(operandType, node.operand);
|
|
77538
77564
|
if (maybeTypeOfKindConsideringBaseConstraint(operandType, 12288 /* ESSymbolLike */)) {
|
|
77539
|
-
|
|
77565
|
+
error2(node.operand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(node.operator));
|
|
77540
77566
|
}
|
|
77541
77567
|
if (node.operator === 40 /* PlusToken */) {
|
|
77542
77568
|
if (maybeTypeOfKindConsideringBaseConstraint(operandType, 2112 /* BigIntLike */)) {
|
|
77543
|
-
|
|
77569
|
+
error2(node.operand, Diagnostics.Operator_0_cannot_be_applied_to_type_1, tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType)));
|
|
77544
77570
|
}
|
|
77545
77571
|
return numberType;
|
|
77546
77572
|
}
|
|
@@ -77636,10 +77662,10 @@ function createTypeChecker(host) {
|
|
|
77636
77662
|
return silentNeverType;
|
|
77637
77663
|
}
|
|
77638
77664
|
if (!isTypeAny(leftType) && allTypesAssignableToKind(leftType, 402784252 /* Primitive */)) {
|
|
77639
|
-
|
|
77665
|
+
error2(left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
|
|
77640
77666
|
}
|
|
77641
77667
|
if (!(isTypeAny(rightType) || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
|
|
77642
|
-
|
|
77668
|
+
error2(right, Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type);
|
|
77643
77669
|
}
|
|
77644
77670
|
return booleanType;
|
|
77645
77671
|
}
|
|
@@ -77668,7 +77694,7 @@ function createTypeChecker(host) {
|
|
|
77668
77694
|
}
|
|
77669
77695
|
if (checkTypeAssignableTo(checkNonNullType(rightType, right), nonPrimitiveType, right)) {
|
|
77670
77696
|
if (hasEmptyObjectIntersection(rightType)) {
|
|
77671
|
-
|
|
77697
|
+
error2(right, Diagnostics.Type_0_may_represent_a_primitive_value_which_is_not_permitted_as_the_right_operand_of_the_in_operator, typeToString(rightType));
|
|
77672
77698
|
}
|
|
77673
77699
|
}
|
|
77674
77700
|
return booleanType;
|
|
@@ -77710,7 +77736,7 @@ function createTypeChecker(host) {
|
|
|
77710
77736
|
return checkDestructuringAssignment(property.kind === 303 /* ShorthandPropertyAssignment */ ? property : property.initializer, type);
|
|
77711
77737
|
} else if (property.kind === 304 /* SpreadAssignment */) {
|
|
77712
77738
|
if (propertyIndex < properties.length - 1) {
|
|
77713
|
-
|
|
77739
|
+
error2(property, Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
|
|
77714
77740
|
} else {
|
|
77715
77741
|
if (languageVersion < 99 /* ESNext */) {
|
|
77716
77742
|
checkExternalEmitHelpers(property, 4 /* Rest */);
|
|
@@ -77728,7 +77754,7 @@ function createTypeChecker(host) {
|
|
|
77728
77754
|
return checkDestructuringAssignment(property.expression, type);
|
|
77729
77755
|
}
|
|
77730
77756
|
} else {
|
|
77731
|
-
|
|
77757
|
+
error2(property, Diagnostics.Property_assignment_expected);
|
|
77732
77758
|
}
|
|
77733
77759
|
}
|
|
77734
77760
|
function checkArrayLiteralAssignment(node, sourceType, checkMode) {
|
|
@@ -77763,11 +77789,11 @@ function createTypeChecker(host) {
|
|
|
77763
77789
|
return checkDestructuringAssignment(element, elementType, checkMode);
|
|
77764
77790
|
}
|
|
77765
77791
|
if (elementIndex < elements.length - 1) {
|
|
77766
|
-
|
|
77792
|
+
error2(element, Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
|
|
77767
77793
|
} else {
|
|
77768
77794
|
const restExpression = element.expression;
|
|
77769
77795
|
if (restExpression.kind === 225 /* BinaryExpression */ && restExpression.operatorToken.kind === 64 /* EqualsToken */) {
|
|
77770
|
-
|
|
77796
|
+
error2(restExpression.operatorToken, Diagnostics.A_rest_element_cannot_have_an_initializer);
|
|
77771
77797
|
} else {
|
|
77772
77798
|
checkGrammarForDisallowedTrailingComma(node.elements, Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
|
|
77773
77799
|
const type = everyType(sourceType, isTupleType) ? mapType(sourceType, (t) => sliceTupleType(t, elementIndex)) : createArrayType(elementType);
|
|
@@ -77808,9 +77834,9 @@ function createTypeChecker(host) {
|
|
|
77808
77834
|
}
|
|
77809
77835
|
function checkReferenceAssignment(target, sourceType, checkMode) {
|
|
77810
77836
|
const targetType = checkExpression(target, checkMode);
|
|
77811
|
-
const
|
|
77837
|
+
const error3 = target.parent.kind === 304 /* SpreadAssignment */ ? Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access;
|
|
77812
77838
|
const optionalError = target.parent.kind === 304 /* SpreadAssignment */ ? Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access : Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access;
|
|
77813
|
-
if (checkReferenceExpression(target,
|
|
77839
|
+
if (checkReferenceExpression(target, error3, optionalError)) {
|
|
77814
77840
|
checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target);
|
|
77815
77841
|
}
|
|
77816
77842
|
if (isPrivateIdentifierPropertyAccessExpression(target)) {
|
|
@@ -78051,7 +78077,7 @@ function createTypeChecker(host) {
|
|
|
78051
78077
|
rightType = checkNonNullType(rightType, right);
|
|
78052
78078
|
let suggestedOperator;
|
|
78053
78079
|
if (leftType.flags & 528 /* BooleanLike */ && rightType.flags & 528 /* BooleanLike */ && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== void 0) {
|
|
78054
|
-
|
|
78080
|
+
error2(errorNode || operatorToken, Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, tokenToString(operatorToken.kind), tokenToString(suggestedOperator));
|
|
78055
78081
|
return numberType;
|
|
78056
78082
|
} else {
|
|
78057
78083
|
const leftOk = checkArithmeticOperandType(
|
|
@@ -78081,7 +78107,7 @@ function createTypeChecker(host) {
|
|
|
78081
78107
|
case 43 /* AsteriskAsteriskToken */:
|
|
78082
78108
|
case 68 /* AsteriskAsteriskEqualsToken */:
|
|
78083
78109
|
if (languageVersion < 3 /* ES2016 */) {
|
|
78084
|
-
|
|
78110
|
+
error2(errorNode, Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later);
|
|
78085
78111
|
}
|
|
78086
78112
|
}
|
|
78087
78113
|
resultType2 = bigintType;
|
|
@@ -78176,10 +78202,10 @@ function createTypeChecker(host) {
|
|
|
78176
78202
|
case 36 /* ExclamationEqualsToken */:
|
|
78177
78203
|
case 37 /* EqualsEqualsEqualsToken */:
|
|
78178
78204
|
case 38 /* ExclamationEqualsEqualsToken */:
|
|
78179
|
-
if (!(checkMode && checkMode &
|
|
78205
|
+
if (!(checkMode && checkMode & 256 /* TypeOnly */)) {
|
|
78180
78206
|
if (isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) {
|
|
78181
78207
|
const eqType = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
|
|
78182
|
-
|
|
78208
|
+
error2(errorNode, Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true");
|
|
78183
78209
|
}
|
|
78184
78210
|
checkNaNEquality(errorNode, operator, left, right);
|
|
78185
78211
|
reportOperatorErrorUnless((left2, right2) => isTypeEqualityComparableTo(left2, right2) || isTypeEqualityComparableTo(right2, left2));
|
|
@@ -78236,7 +78262,7 @@ function createTypeChecker(host) {
|
|
|
78236
78262
|
return textSpanContainsPosition(diag2, start2);
|
|
78237
78263
|
});
|
|
78238
78264
|
if (!isInDiag2657)
|
|
78239
|
-
|
|
78265
|
+
error2(left, Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects);
|
|
78240
78266
|
}
|
|
78241
78267
|
return rightType;
|
|
78242
78268
|
default:
|
|
@@ -78276,7 +78302,7 @@ function createTypeChecker(host) {
|
|
|
78276
78302
|
function checkForDisallowedESSymbolOperand(operator2) {
|
|
78277
78303
|
const offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* ESSymbolLike */) ? left : maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* ESSymbolLike */) ? right : void 0;
|
|
78278
78304
|
if (offendingSymbolOperand) {
|
|
78279
|
-
|
|
78305
|
+
error2(offendingSymbolOperand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(operator2));
|
|
78280
78306
|
return false;
|
|
78281
78307
|
}
|
|
78282
78308
|
return true;
|
|
@@ -78397,7 +78423,7 @@ function createTypeChecker(host) {
|
|
|
78397
78423
|
const isLeftNaN = isGlobalNaN(skipParentheses(left2));
|
|
78398
78424
|
const isRightNaN = isGlobalNaN(skipParentheses(right2));
|
|
78399
78425
|
if (isLeftNaN || isRightNaN) {
|
|
78400
|
-
const err =
|
|
78426
|
+
const err = error2(
|
|
78401
78427
|
errorNode2,
|
|
78402
78428
|
Diagnostics.This_condition_will_always_return_0,
|
|
78403
78429
|
tokenToString(operator2 === 37 /* EqualsEqualsEqualsToken */ || operator2 === 35 /* EqualsEqualsToken */ ? 97 /* FalseKeyword */ : 112 /* TrueKeyword */)
|
|
@@ -78478,7 +78504,7 @@ function createTypeChecker(host) {
|
|
|
78478
78504
|
void 0
|
|
78479
78505
|
);
|
|
78480
78506
|
if (!contextualType || isTypeAny(contextualType)) {
|
|
78481
|
-
|
|
78507
|
+
error2(node, Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation);
|
|
78482
78508
|
}
|
|
78483
78509
|
}
|
|
78484
78510
|
});
|
|
@@ -78489,7 +78515,7 @@ function createTypeChecker(host) {
|
|
|
78489
78515
|
grammarErrorOnFirstToken(node, Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body);
|
|
78490
78516
|
}
|
|
78491
78517
|
if (isInParameterInitializerBeforeContainingFunction(node)) {
|
|
78492
|
-
|
|
78518
|
+
error2(node, Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer);
|
|
78493
78519
|
}
|
|
78494
78520
|
}
|
|
78495
78521
|
}
|
|
@@ -78510,7 +78536,7 @@ function createTypeChecker(host) {
|
|
|
78510
78536
|
for (const span of node.templateSpans) {
|
|
78511
78537
|
const type = checkExpression(span.expression);
|
|
78512
78538
|
if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* ESSymbolLike */)) {
|
|
78513
|
-
|
|
78539
|
+
error2(span.expression, Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String);
|
|
78514
78540
|
}
|
|
78515
78541
|
texts.push(span.literal.text);
|
|
78516
78542
|
types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType);
|
|
@@ -78835,7 +78861,7 @@ function createTypeChecker(host) {
|
|
|
78835
78861
|
}
|
|
78836
78862
|
}
|
|
78837
78863
|
const startInvocationCount = flowInvocationCount;
|
|
78838
|
-
const type = checkExpression(node,
|
|
78864
|
+
const type = checkExpression(node, 256 /* TypeOnly */);
|
|
78839
78865
|
if (flowInvocationCount !== startInvocationCount) {
|
|
78840
78866
|
const cache = flowTypeCache || (flowTypeCache = []);
|
|
78841
78867
|
cache[getNodeId(node)] = type;
|
|
@@ -78906,13 +78932,13 @@ function createTypeChecker(host) {
|
|
|
78906
78932
|
function checkConstEnumAccess(node, type) {
|
|
78907
78933
|
const ok = node.parent.kind === 210 /* PropertyAccessExpression */ && node.parent.expression === node || node.parent.kind === 211 /* ElementAccessExpression */ && node.parent.expression === node || ((node.kind === 80 /* Identifier */ || node.kind === 165 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || node.parent.kind === 185 /* TypeQuery */ && node.parent.exprName === node) || node.parent.kind === 280 /* ExportSpecifier */;
|
|
78908
78934
|
if (!ok) {
|
|
78909
|
-
|
|
78935
|
+
error2(node, Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query);
|
|
78910
78936
|
}
|
|
78911
78937
|
if (getIsolatedModules(compilerOptions)) {
|
|
78912
78938
|
Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */));
|
|
78913
78939
|
const constEnumDeclaration = type.symbol.valueDeclaration;
|
|
78914
78940
|
if (constEnumDeclaration.flags & 16777216 /* Ambient */ && !isValidTypeOnlyAliasUseSite(node)) {
|
|
78915
|
-
|
|
78941
|
+
error2(node, Diagnostics.Cannot_access_ambient_const_enums_when_0_is_enabled, isolatedModulesLikeFlagName);
|
|
78916
78942
|
}
|
|
78917
78943
|
}
|
|
78918
78944
|
}
|
|
@@ -79053,7 +79079,7 @@ function createTypeChecker(host) {
|
|
|
79053
79079
|
const typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfDeclaration(node));
|
|
79054
79080
|
getBaseConstraintOfType(typeParameter);
|
|
79055
79081
|
if (!hasNonCircularTypeParameterDefault(typeParameter)) {
|
|
79056
|
-
|
|
79082
|
+
error2(node.default, Diagnostics.Type_parameter_0_has_a_circular_default, typeToString(typeParameter));
|
|
79057
79083
|
}
|
|
79058
79084
|
const constraintType = getConstraintOfTypeParameter(typeParameter);
|
|
79059
79085
|
const defaultType = getDefaultFromTypeParameter(typeParameter);
|
|
@@ -79071,7 +79097,7 @@ function createTypeChecker(host) {
|
|
|
79071
79097
|
if (modifiers) {
|
|
79072
79098
|
const symbol = getSymbolOfDeclaration(node.parent);
|
|
79073
79099
|
if (isTypeAliasDeclaration(node.parent) && !(getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* Anonymous */ | 32 /* Mapped */))) {
|
|
79074
|
-
|
|
79100
|
+
error2(node, Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types);
|
|
79075
79101
|
} else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) {
|
|
79076
79102
|
(_a = tracing) == null ? void 0 : _a.push(tracing.Phase.CheckTypes, "checkTypeParameterDeferred", { parent: getTypeId(getDeclaredTypeOfSymbol(symbol)), id: getTypeId(typeParameter) });
|
|
79077
79103
|
const source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubTypeForCheck : markerSuperTypeForCheck);
|
|
@@ -79091,37 +79117,37 @@ function createTypeChecker(host) {
|
|
|
79091
79117
|
const func = getContainingFunction(node);
|
|
79092
79118
|
if (hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) {
|
|
79093
79119
|
if (!(func.kind === 175 /* Constructor */ && nodeIsPresent(func.body))) {
|
|
79094
|
-
|
|
79120
|
+
error2(node, Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation);
|
|
79095
79121
|
}
|
|
79096
79122
|
if (func.kind === 175 /* Constructor */ && isIdentifier(node.name) && node.name.escapedText === "constructor") {
|
|
79097
|
-
|
|
79123
|
+
error2(node.name, Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name);
|
|
79098
79124
|
}
|
|
79099
79125
|
}
|
|
79100
79126
|
if (!node.initializer && isOptionalDeclaration(node) && isBindingPattern(node.name) && func.body) {
|
|
79101
|
-
|
|
79127
|
+
error2(node, Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature);
|
|
79102
79128
|
}
|
|
79103
79129
|
if (node.name && isIdentifier(node.name) && (node.name.escapedText === "this" || node.name.escapedText === "new")) {
|
|
79104
79130
|
if (func.parameters.indexOf(node) !== 0) {
|
|
79105
|
-
|
|
79131
|
+
error2(node, Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText);
|
|
79106
79132
|
}
|
|
79107
79133
|
if (func.kind === 175 /* Constructor */ || func.kind === 179 /* ConstructSignature */ || func.kind === 184 /* ConstructorType */) {
|
|
79108
|
-
|
|
79134
|
+
error2(node, Diagnostics.A_constructor_cannot_have_a_this_parameter);
|
|
79109
79135
|
}
|
|
79110
79136
|
if (func.kind === 218 /* ArrowFunction */) {
|
|
79111
|
-
|
|
79137
|
+
error2(node, Diagnostics.An_arrow_function_cannot_have_a_this_parameter);
|
|
79112
79138
|
}
|
|
79113
79139
|
if (func.kind === 176 /* GetAccessor */ || func.kind === 177 /* SetAccessor */) {
|
|
79114
|
-
|
|
79140
|
+
error2(node, Diagnostics.get_and_set_accessors_cannot_declare_this_parameters);
|
|
79115
79141
|
}
|
|
79116
79142
|
}
|
|
79117
79143
|
if (node.dotDotDotToken && !isBindingPattern(node.name) && !isTypeAssignableTo(getReducedType(getTypeOfSymbol(node.symbol)), anyReadonlyArrayType)) {
|
|
79118
|
-
|
|
79144
|
+
error2(node, Diagnostics.A_rest_parameter_must_be_of_an_array_type);
|
|
79119
79145
|
}
|
|
79120
79146
|
}
|
|
79121
79147
|
function checkTypePredicate(node) {
|
|
79122
79148
|
const parent2 = getTypePredicateParent(node);
|
|
79123
79149
|
if (!parent2) {
|
|
79124
|
-
|
|
79150
|
+
error2(node, Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods);
|
|
79125
79151
|
return;
|
|
79126
79152
|
}
|
|
79127
79153
|
const signature = getSignatureFromDeclaration(parent2);
|
|
@@ -79136,7 +79162,7 @@ function createTypeChecker(host) {
|
|
|
79136
79162
|
} else {
|
|
79137
79163
|
if (typePredicate.parameterIndex >= 0) {
|
|
79138
79164
|
if (signatureHasRestParameter(signature) && typePredicate.parameterIndex === signature.parameters.length - 1) {
|
|
79139
|
-
|
|
79165
|
+
error2(parameterName, Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter);
|
|
79140
79166
|
} else {
|
|
79141
79167
|
if (typePredicate.type) {
|
|
79142
79168
|
const leadingError = () => chainDiagnosticMessages(
|
|
@@ -79163,7 +79189,7 @@ function createTypeChecker(host) {
|
|
|
79163
79189
|
}
|
|
79164
79190
|
}
|
|
79165
79191
|
if (!hasReportedError) {
|
|
79166
|
-
|
|
79192
|
+
error2(node.parameterName, Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName);
|
|
79167
79193
|
}
|
|
79168
79194
|
}
|
|
79169
79195
|
}
|
|
@@ -79190,7 +79216,7 @@ function createTypeChecker(host) {
|
|
|
79190
79216
|
}
|
|
79191
79217
|
const name = element.name;
|
|
79192
79218
|
if (name.kind === 80 /* Identifier */ && name.escapedText === predicateVariableName) {
|
|
79193
|
-
|
|
79219
|
+
error2(
|
|
79194
79220
|
predicateVariableNode,
|
|
79195
79221
|
Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern,
|
|
79196
79222
|
predicateVariableName
|
|
@@ -79238,10 +79264,10 @@ function createTypeChecker(host) {
|
|
|
79238
79264
|
if (noImplicitAny && !returnTypeNode) {
|
|
79239
79265
|
switch (node.kind) {
|
|
79240
79266
|
case 179 /* ConstructSignature */:
|
|
79241
|
-
|
|
79267
|
+
error2(node, Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
|
|
79242
79268
|
break;
|
|
79243
79269
|
case 178 /* CallSignature */:
|
|
79244
|
-
|
|
79270
|
+
error2(node, Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
|
|
79245
79271
|
break;
|
|
79246
79272
|
}
|
|
79247
79273
|
}
|
|
@@ -79250,7 +79276,7 @@ function createTypeChecker(host) {
|
|
|
79250
79276
|
if ((functionFlags2 & (4 /* Invalid */ | 1 /* Generator */)) === 1 /* Generator */) {
|
|
79251
79277
|
const returnType = getTypeFromTypeNode(returnTypeNode);
|
|
79252
79278
|
if (returnType === voidType) {
|
|
79253
|
-
|
|
79279
|
+
error2(returnTypeNode, Diagnostics.A_generator_cannot_have_a_void_type_annotation);
|
|
79254
79280
|
} else {
|
|
79255
79281
|
const generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || anyType;
|
|
79256
79282
|
const generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || generatorYieldType;
|
|
@@ -79310,16 +79336,16 @@ function createTypeChecker(host) {
|
|
|
79310
79336
|
const prev = names.get(name);
|
|
79311
79337
|
if (prev) {
|
|
79312
79338
|
if ((prev & 16 /* PrivateStatic */) !== (meaning & 16 /* PrivateStatic */)) {
|
|
79313
|
-
|
|
79339
|
+
error2(location, Diagnostics.Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name, getTextOfNode(location));
|
|
79314
79340
|
} else {
|
|
79315
79341
|
const prevIsMethod = !!(prev & 8 /* Method */);
|
|
79316
79342
|
const isMethod = !!(meaning & 8 /* Method */);
|
|
79317
79343
|
if (prevIsMethod || isMethod) {
|
|
79318
79344
|
if (prevIsMethod !== isMethod) {
|
|
79319
|
-
|
|
79345
|
+
error2(location, Diagnostics.Duplicate_identifier_0, getTextOfNode(location));
|
|
79320
79346
|
}
|
|
79321
79347
|
} else if (prev & meaning & ~16 /* PrivateStatic */) {
|
|
79322
|
-
|
|
79348
|
+
error2(location, Diagnostics.Duplicate_identifier_0, getTextOfNode(location));
|
|
79323
79349
|
} else {
|
|
79324
79350
|
names.set(name, prev | meaning);
|
|
79325
79351
|
}
|
|
@@ -79346,7 +79372,7 @@ function createTypeChecker(host) {
|
|
|
79346
79372
|
case "prototype":
|
|
79347
79373
|
const message = Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1;
|
|
79348
79374
|
const className = getNameOfSymbolAsWritten(getSymbolOfDeclaration(node));
|
|
79349
|
-
|
|
79375
|
+
error2(memberNameNode, message, memberName, className);
|
|
79350
79376
|
break;
|
|
79351
79377
|
}
|
|
79352
79378
|
}
|
|
@@ -79370,8 +79396,8 @@ function createTypeChecker(host) {
|
|
|
79370
79396
|
continue;
|
|
79371
79397
|
}
|
|
79372
79398
|
if (names.get(memberName)) {
|
|
79373
|
-
|
|
79374
|
-
|
|
79399
|
+
error2(getNameOfDeclaration(member.symbol.valueDeclaration), Diagnostics.Duplicate_identifier_0, memberName);
|
|
79400
|
+
error2(member.name, Diagnostics.Duplicate_identifier_0, memberName);
|
|
79375
79401
|
} else {
|
|
79376
79402
|
names.set(memberName, true);
|
|
79377
79403
|
}
|
|
@@ -79403,7 +79429,7 @@ function createTypeChecker(host) {
|
|
|
79403
79429
|
indexSignatureMap.forEach((entry) => {
|
|
79404
79430
|
if (entry.declarations.length > 1) {
|
|
79405
79431
|
for (const declaration of entry.declarations) {
|
|
79406
|
-
|
|
79432
|
+
error2(declaration, Diagnostics.Duplicate_index_signature_for_type_0, typeToString(entry.type));
|
|
79407
79433
|
}
|
|
79408
79434
|
}
|
|
79409
79435
|
});
|
|
@@ -79415,12 +79441,12 @@ function createTypeChecker(host) {
|
|
|
79415
79441
|
checkVariableLikeDeclaration(node);
|
|
79416
79442
|
setNodeLinksForPrivateIdentifierScope(node);
|
|
79417
79443
|
if (hasSyntacticModifier(node, 256 /* Abstract */) && node.kind === 171 /* PropertyDeclaration */ && node.initializer) {
|
|
79418
|
-
|
|
79444
|
+
error2(node, Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, declarationNameToString(node.name));
|
|
79419
79445
|
}
|
|
79420
79446
|
}
|
|
79421
79447
|
function checkPropertySignature(node) {
|
|
79422
79448
|
if (isPrivateIdentifier(node.name)) {
|
|
79423
|
-
|
|
79449
|
+
error2(node, Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
|
|
79424
79450
|
}
|
|
79425
79451
|
return checkPropertyDeclaration(node);
|
|
79426
79452
|
}
|
|
@@ -79428,14 +79454,14 @@ function createTypeChecker(host) {
|
|
|
79428
79454
|
if (!checkGrammarMethod(node))
|
|
79429
79455
|
checkGrammarComputedPropertyName(node.name);
|
|
79430
79456
|
if (isMethodDeclaration(node) && node.asteriskToken && isIdentifier(node.name) && idText(node.name) === "constructor") {
|
|
79431
|
-
|
|
79457
|
+
error2(node.name, Diagnostics.Class_constructor_may_not_be_a_generator);
|
|
79432
79458
|
}
|
|
79433
79459
|
checkFunctionOrMethodDeclaration(node);
|
|
79434
79460
|
if (hasSyntacticModifier(node, 256 /* Abstract */) && node.kind === 173 /* MethodDeclaration */ && node.body) {
|
|
79435
|
-
|
|
79461
|
+
error2(node, Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, declarationNameToString(node.name));
|
|
79436
79462
|
}
|
|
79437
79463
|
if (isPrivateIdentifier(node.name) && !getContainingClass(node)) {
|
|
79438
|
-
|
|
79464
|
+
error2(node, Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
|
|
79439
79465
|
}
|
|
79440
79466
|
setNodeLinksForPrivateIdentifierScope(node);
|
|
79441
79467
|
}
|
|
@@ -79486,12 +79512,12 @@ function createTypeChecker(host) {
|
|
|
79486
79512
|
const superCall = findFirstSuperCall(node.body);
|
|
79487
79513
|
if (superCall) {
|
|
79488
79514
|
if (classExtendsNull) {
|
|
79489
|
-
|
|
79515
|
+
error2(superCall, Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
|
|
79490
79516
|
}
|
|
79491
79517
|
const superCallShouldBeRootLevel = (getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) && (some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || some(node.parameters, (p) => hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */)));
|
|
79492
79518
|
if (superCallShouldBeRootLevel) {
|
|
79493
79519
|
if (!superCallIsRootLevelInConstructor(superCall, node.body)) {
|
|
79494
|
-
|
|
79520
|
+
error2(superCall, Diagnostics.A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers);
|
|
79495
79521
|
} else {
|
|
79496
79522
|
let superCallStatement;
|
|
79497
79523
|
for (const statement of node.body.statements) {
|
|
@@ -79504,12 +79530,12 @@ function createTypeChecker(host) {
|
|
|
79504
79530
|
}
|
|
79505
79531
|
}
|
|
79506
79532
|
if (superCallStatement === void 0) {
|
|
79507
|
-
|
|
79533
|
+
error2(node, Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_class_contains_initialized_properties_parameter_properties_or_private_identifiers);
|
|
79508
79534
|
}
|
|
79509
79535
|
}
|
|
79510
79536
|
}
|
|
79511
79537
|
} else if (!classExtendsNull) {
|
|
79512
|
-
|
|
79538
|
+
error2(node, Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call);
|
|
79513
79539
|
}
|
|
79514
79540
|
}
|
|
79515
79541
|
}
|
|
@@ -79529,7 +79555,7 @@ function createTypeChecker(host) {
|
|
|
79529
79555
|
}
|
|
79530
79556
|
function checkAccessorDeclaration(node) {
|
|
79531
79557
|
if (isIdentifier(node.name) && idText(node.name) === "constructor" && isClassLike(node.parent)) {
|
|
79532
|
-
|
|
79558
|
+
error2(node.name, Diagnostics.Class_constructor_may_not_be_an_accessor);
|
|
79533
79559
|
}
|
|
79534
79560
|
addLazyDiagnostic(checkAccessorDeclarationDiagnostics);
|
|
79535
79561
|
checkSourceElement(node.body);
|
|
@@ -79542,7 +79568,7 @@ function createTypeChecker(host) {
|
|
|
79542
79568
|
if (node.kind === 176 /* GetAccessor */) {
|
|
79543
79569
|
if (!(node.flags & 16777216 /* Ambient */) && nodeIsPresent(node.body) && node.flags & 256 /* HasImplicitReturn */) {
|
|
79544
79570
|
if (!(node.flags & 512 /* HasExplicitReturn */)) {
|
|
79545
|
-
|
|
79571
|
+
error2(node.name, Diagnostics.A_get_accessor_must_return_a_value);
|
|
79546
79572
|
}
|
|
79547
79573
|
}
|
|
79548
79574
|
}
|
|
@@ -79558,12 +79584,12 @@ function createTypeChecker(host) {
|
|
|
79558
79584
|
const getterFlags = getEffectiveModifierFlags(getter);
|
|
79559
79585
|
const setterFlags = getEffectiveModifierFlags(setter);
|
|
79560
79586
|
if ((getterFlags & 256 /* Abstract */) !== (setterFlags & 256 /* Abstract */)) {
|
|
79561
|
-
|
|
79562
|
-
|
|
79587
|
+
error2(getter.name, Diagnostics.Accessors_must_both_be_abstract_or_non_abstract);
|
|
79588
|
+
error2(setter.name, Diagnostics.Accessors_must_both_be_abstract_or_non_abstract);
|
|
79563
79589
|
}
|
|
79564
79590
|
if (getterFlags & 16 /* Protected */ && !(setterFlags & (16 /* Protected */ | 8 /* Private */)) || getterFlags & 8 /* Private */ && !(setterFlags & 8 /* Private */)) {
|
|
79565
|
-
|
|
79566
|
-
|
|
79591
|
+
error2(getter.name, Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter);
|
|
79592
|
+
error2(setter.name, Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter);
|
|
79567
79593
|
}
|
|
79568
79594
|
}
|
|
79569
79595
|
}
|
|
@@ -79701,7 +79727,7 @@ function createTypeChecker(host) {
|
|
|
79701
79727
|
if (flags & 8 /* Variadic */) {
|
|
79702
79728
|
const type = getTypeFromTypeNode(e.type);
|
|
79703
79729
|
if (!isArrayLikeType(type)) {
|
|
79704
|
-
|
|
79730
|
+
error2(e, Diagnostics.A_rest_element_type_must_be_an_array_type);
|
|
79705
79731
|
break;
|
|
79706
79732
|
}
|
|
79707
79733
|
if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4 /* Rest */) {
|
|
@@ -79739,7 +79765,7 @@ function createTypeChecker(host) {
|
|
|
79739
79765
|
const indexType = type.indexType;
|
|
79740
79766
|
if (isTypeAssignableTo(indexType, getIndexType(objectType, 0 /* None */))) {
|
|
79741
79767
|
if (accessNode.kind === 211 /* ElementAccessExpression */ && isAssignmentTarget(accessNode) && getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) {
|
|
79742
|
-
|
|
79768
|
+
error2(accessNode, Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
|
|
79743
79769
|
}
|
|
79744
79770
|
return type;
|
|
79745
79771
|
}
|
|
@@ -79752,12 +79778,12 @@ function createTypeChecker(host) {
|
|
|
79752
79778
|
if (propertyName) {
|
|
79753
79779
|
const propertySymbol = forEachType(apparentObjectType, (t) => getPropertyOfType(t, propertyName));
|
|
79754
79780
|
if (propertySymbol && getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* NonPublicAccessibilityModifier */) {
|
|
79755
|
-
|
|
79781
|
+
error2(accessNode, Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter, unescapeLeadingUnderscores(propertyName));
|
|
79756
79782
|
return errorType;
|
|
79757
79783
|
}
|
|
79758
79784
|
}
|
|
79759
79785
|
}
|
|
79760
|
-
|
|
79786
|
+
error2(accessNode, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType));
|
|
79761
79787
|
return errorType;
|
|
79762
79788
|
}
|
|
79763
79789
|
function checkIndexedAccessType(node) {
|
|
@@ -79813,7 +79839,7 @@ function createTypeChecker(host) {
|
|
|
79813
79839
|
if (!areTypeParametersIdentical(declarations, [typeParameter], (decl) => [decl])) {
|
|
79814
79840
|
const name = symbolToString(symbol);
|
|
79815
79841
|
for (const declaration of declarations) {
|
|
79816
|
-
|
|
79842
|
+
error2(declaration.name, Diagnostics.All_declarations_of_0_must_have_identical_constraints, name);
|
|
79817
79843
|
}
|
|
79818
79844
|
}
|
|
79819
79845
|
}
|
|
@@ -79884,13 +79910,13 @@ function createTypeChecker(host) {
|
|
|
79884
79910
|
forEach(overloads, (o) => {
|
|
79885
79911
|
const deviation = getEffectiveDeclarationFlags(o, flagsToCheck2) ^ canonicalFlags;
|
|
79886
79912
|
if (deviation & 1 /* Export */) {
|
|
79887
|
-
|
|
79913
|
+
error2(getNameOfDeclaration(o), Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported);
|
|
79888
79914
|
} else if (deviation & 2 /* Ambient */) {
|
|
79889
|
-
|
|
79915
|
+
error2(getNameOfDeclaration(o), Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient);
|
|
79890
79916
|
} else if (deviation & (8 /* Private */ | 16 /* Protected */)) {
|
|
79891
|
-
|
|
79917
|
+
error2(getNameOfDeclaration(o) || o, Diagnostics.Overload_signatures_must_all_be_public_private_or_protected);
|
|
79892
79918
|
} else if (deviation & 256 /* Abstract */) {
|
|
79893
|
-
|
|
79919
|
+
error2(getNameOfDeclaration(o), Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract);
|
|
79894
79920
|
}
|
|
79895
79921
|
});
|
|
79896
79922
|
}
|
|
@@ -79901,7 +79927,7 @@ function createTypeChecker(host) {
|
|
|
79901
79927
|
forEach(overloads, (o) => {
|
|
79902
79928
|
const deviation = hasQuestionToken(o) !== canonicalHasQuestionToken;
|
|
79903
79929
|
if (deviation) {
|
|
79904
|
-
|
|
79930
|
+
error2(getNameOfDeclaration(o), Diagnostics.Overload_signatures_must_all_be_optional_or_required);
|
|
79905
79931
|
}
|
|
79906
79932
|
});
|
|
79907
79933
|
}
|
|
@@ -79940,24 +79966,24 @@ function createTypeChecker(host) {
|
|
|
79940
79966
|
const reportError = (node.kind === 173 /* MethodDeclaration */ || node.kind === 172 /* MethodSignature */) && isStatic(node) !== isStatic(subsequentNode);
|
|
79941
79967
|
if (reportError) {
|
|
79942
79968
|
const diagnostic = isStatic(node) ? Diagnostics.Function_overload_must_be_static : Diagnostics.Function_overload_must_not_be_static;
|
|
79943
|
-
|
|
79969
|
+
error2(errorNode2, diagnostic);
|
|
79944
79970
|
}
|
|
79945
79971
|
return;
|
|
79946
79972
|
}
|
|
79947
79973
|
if (nodeIsPresent(subsequentNode.body)) {
|
|
79948
|
-
|
|
79974
|
+
error2(errorNode2, Diagnostics.Function_implementation_name_must_be_0, declarationNameToString(node.name));
|
|
79949
79975
|
return;
|
|
79950
79976
|
}
|
|
79951
79977
|
}
|
|
79952
79978
|
}
|
|
79953
79979
|
const errorNode = node.name || node;
|
|
79954
79980
|
if (isConstructor) {
|
|
79955
|
-
|
|
79981
|
+
error2(errorNode, Diagnostics.Constructor_implementation_is_missing);
|
|
79956
79982
|
} else {
|
|
79957
79983
|
if (hasSyntacticModifier(node, 256 /* Abstract */)) {
|
|
79958
|
-
|
|
79984
|
+
error2(errorNode, Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive);
|
|
79959
79985
|
} else {
|
|
79960
|
-
|
|
79986
|
+
error2(errorNode, Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration);
|
|
79961
79987
|
}
|
|
79962
79988
|
}
|
|
79963
79989
|
}
|
|
@@ -80020,12 +80046,12 @@ function createTypeChecker(host) {
|
|
|
80020
80046
|
}
|
|
80021
80047
|
if (multipleConstructorImplementation) {
|
|
80022
80048
|
forEach(functionDeclarations, (declaration) => {
|
|
80023
|
-
|
|
80049
|
+
error2(declaration, Diagnostics.Multiple_constructor_implementations_are_not_allowed);
|
|
80024
80050
|
});
|
|
80025
80051
|
}
|
|
80026
80052
|
if (duplicateFunctionDeclaration) {
|
|
80027
80053
|
forEach(functionDeclarations, (declaration) => {
|
|
80028
|
-
|
|
80054
|
+
error2(getNameOfDeclaration(declaration) || declaration, Diagnostics.Duplicate_function_implementation);
|
|
80029
80055
|
});
|
|
80030
80056
|
}
|
|
80031
80057
|
if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */ && declarations) {
|
|
@@ -80034,7 +80060,7 @@ function createTypeChecker(host) {
|
|
|
80034
80060
|
const diagnostic = declaration.kind === 262 /* ClassDeclaration */ ? Diagnostics.Class_declaration_cannot_implement_overload_list_for_0 : declaration.kind === 261 /* FunctionDeclaration */ ? Diagnostics.Function_with_bodies_can_only_merge_with_classes_that_are_ambient : void 0;
|
|
80035
80061
|
if (diagnostic) {
|
|
80036
80062
|
addRelatedInfo(
|
|
80037
|
-
|
|
80063
|
+
error2(getNameOfDeclaration(declaration) || declaration, diagnostic, symbolName(symbol)),
|
|
80038
80064
|
...relatedDiagnostics
|
|
80039
80065
|
);
|
|
80040
80066
|
}
|
|
@@ -80055,7 +80081,7 @@ function createTypeChecker(host) {
|
|
|
80055
80081
|
if (!isImplementationCompatibleWithOverload(bodySignature, signature)) {
|
|
80056
80082
|
const errorNode = signature.declaration && isJSDocSignature(signature.declaration) ? signature.declaration.parent.tagName : signature.declaration;
|
|
80057
80083
|
addRelatedInfo(
|
|
80058
|
-
|
|
80084
|
+
error2(errorNode, Diagnostics.This_overload_signature_is_not_compatible_with_its_implementation_signature),
|
|
80059
80085
|
createDiagnosticForNode(bodyDeclaration, Diagnostics.The_implementation_signature_is_declared_here)
|
|
80060
80086
|
);
|
|
80061
80087
|
break;
|
|
@@ -80102,9 +80128,9 @@ function createTypeChecker(host) {
|
|
|
80102
80128
|
const declarationSpaces = getDeclarationSpaces(d);
|
|
80103
80129
|
const name = getNameOfDeclaration(d);
|
|
80104
80130
|
if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) {
|
|
80105
|
-
|
|
80131
|
+
error2(name, Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, declarationNameToString(name));
|
|
80106
80132
|
} else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) {
|
|
80107
|
-
|
|
80133
|
+
error2(name, Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, declarationNameToString(name));
|
|
80108
80134
|
}
|
|
80109
80135
|
}
|
|
80110
80136
|
}
|
|
@@ -80184,7 +80210,7 @@ function createTypeChecker(host) {
|
|
|
80184
80210
|
const thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* Call */) : emptyArray;
|
|
80185
80211
|
if (thenSignatures.length === 0) {
|
|
80186
80212
|
if (errorNode) {
|
|
80187
|
-
|
|
80213
|
+
error2(errorNode, Diagnostics.A_promise_must_have_a_then_method);
|
|
80188
80214
|
}
|
|
80189
80215
|
return void 0;
|
|
80190
80216
|
}
|
|
@@ -80204,7 +80230,7 @@ function createTypeChecker(host) {
|
|
|
80204
80230
|
thisTypeForErrorOut.value = thisTypeForError;
|
|
80205
80231
|
}
|
|
80206
80232
|
if (errorNode) {
|
|
80207
|
-
|
|
80233
|
+
error2(errorNode, Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1, typeToString(type), typeToString(thisTypeForError));
|
|
80208
80234
|
}
|
|
80209
80235
|
return void 0;
|
|
80210
80236
|
}
|
|
@@ -80215,7 +80241,7 @@ function createTypeChecker(host) {
|
|
|
80215
80241
|
const onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* Call */);
|
|
80216
80242
|
if (onfulfilledParameterSignatures.length === 0) {
|
|
80217
80243
|
if (errorNode) {
|
|
80218
|
-
|
|
80244
|
+
error2(errorNode, Diagnostics.The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback);
|
|
80219
80245
|
}
|
|
80220
80246
|
return void 0;
|
|
80221
80247
|
}
|
|
@@ -80296,7 +80322,7 @@ function createTypeChecker(host) {
|
|
|
80296
80322
|
if (type.flags & 1048576 /* Union */) {
|
|
80297
80323
|
if (awaitedTypeStack.lastIndexOf(type.id) >= 0) {
|
|
80298
80324
|
if (errorNode) {
|
|
80299
|
-
|
|
80325
|
+
error2(errorNode, Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method);
|
|
80300
80326
|
}
|
|
80301
80327
|
return void 0;
|
|
80302
80328
|
}
|
|
@@ -80319,7 +80345,7 @@ function createTypeChecker(host) {
|
|
|
80319
80345
|
if (promisedType) {
|
|
80320
80346
|
if (type.id === promisedType.id || awaitedTypeStack.lastIndexOf(promisedType.id) >= 0) {
|
|
80321
80347
|
if (errorNode) {
|
|
80322
|
-
|
|
80348
|
+
error2(errorNode, Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method);
|
|
80323
80349
|
}
|
|
80324
80350
|
return void 0;
|
|
80325
80351
|
}
|
|
@@ -80356,7 +80382,7 @@ function createTypeChecker(host) {
|
|
|
80356
80382
|
true
|
|
80357
80383
|
);
|
|
80358
80384
|
if (globalPromiseType !== emptyGenericType && !isReferenceToType2(returnType, globalPromiseType)) {
|
|
80359
|
-
|
|
80385
|
+
error2(returnTypeNode, Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0, typeToString(getAwaitedTypeNoAlias(returnType) || voidType));
|
|
80360
80386
|
return;
|
|
80361
80387
|
}
|
|
80362
80388
|
} else {
|
|
@@ -80366,7 +80392,7 @@ function createTypeChecker(host) {
|
|
|
80366
80392
|
}
|
|
80367
80393
|
const promiseConstructorName = getEntityNameFromTypeNode(returnTypeNode);
|
|
80368
80394
|
if (promiseConstructorName === void 0) {
|
|
80369
|
-
|
|
80395
|
+
error2(returnTypeNode, Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType));
|
|
80370
80396
|
return;
|
|
80371
80397
|
}
|
|
80372
80398
|
const promiseConstructorSymbol = resolveEntityName(
|
|
@@ -80381,9 +80407,9 @@ function createTypeChecker(host) {
|
|
|
80381
80407
|
/*reportErrors*/
|
|
80382
80408
|
false
|
|
80383
80409
|
)) {
|
|
80384
|
-
|
|
80410
|
+
error2(returnTypeNode, Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option);
|
|
80385
80411
|
} else {
|
|
80386
|
-
|
|
80412
|
+
error2(returnTypeNode, Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, entityNameToString(promiseConstructorName));
|
|
80387
80413
|
}
|
|
80388
80414
|
return;
|
|
80389
80415
|
}
|
|
@@ -80392,7 +80418,7 @@ function createTypeChecker(host) {
|
|
|
80392
80418
|
true
|
|
80393
80419
|
);
|
|
80394
80420
|
if (globalPromiseConstructorLikeType === emptyObjectType) {
|
|
80395
|
-
|
|
80421
|
+
error2(returnTypeNode, Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, entityNameToString(promiseConstructorName));
|
|
80396
80422
|
return;
|
|
80397
80423
|
}
|
|
80398
80424
|
if (!checkTypeAssignableTo(
|
|
@@ -80406,7 +80432,7 @@ function createTypeChecker(host) {
|
|
|
80406
80432
|
const rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName);
|
|
80407
80433
|
const collidingSymbol = getSymbol2(node.locals, rootName.escapedText, 111551 /* Value */);
|
|
80408
80434
|
if (collidingSymbol) {
|
|
80409
|
-
|
|
80435
|
+
error2(
|
|
80410
80436
|
collidingSymbol.valueDeclaration,
|
|
80411
80437
|
Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions,
|
|
80412
80438
|
idText(rootName),
|
|
@@ -80519,7 +80545,7 @@ function createTypeChecker(host) {
|
|
|
80519
80545
|
if (canCollectSymbolAliasAccessabilityData && symbolIsValue(rootSymbol) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol)) && !getTypeOnlyAliasDeclaration(rootSymbol)) {
|
|
80520
80546
|
markAliasSymbolAsReferenced(rootSymbol);
|
|
80521
80547
|
} else if (forDecoratorMetadata && getIsolatedModules(compilerOptions) && getEmitModuleKind(compilerOptions) >= 5 /* ES2015 */ && !symbolIsValue(rootSymbol) && !some(rootSymbol.declarations, isTypeOnlyImportOrExportDeclaration)) {
|
|
80522
|
-
const diag2 =
|
|
80548
|
+
const diag2 = error2(typeName, Diagnostics.A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_when_isolatedModules_and_emitDecoratorMetadata_are_enabled);
|
|
80523
80549
|
const aliasDeclaration = find(rootSymbol.declarations || emptyArray, isAliasSymbolDeclaration2);
|
|
80524
80550
|
if (aliasDeclaration) {
|
|
80525
80551
|
addRelatedInfo(diag2, createDiagnosticForNode(aliasDeclaration, Diagnostics._0_was_imported_here, idText(rootName)));
|
|
@@ -80667,7 +80693,7 @@ function createTypeChecker(host) {
|
|
|
80667
80693
|
}
|
|
80668
80694
|
function checkJSDocTypeAliasTag(node) {
|
|
80669
80695
|
if (!node.typeExpression) {
|
|
80670
|
-
|
|
80696
|
+
error2(node.name, Diagnostics.JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags);
|
|
80671
80697
|
}
|
|
80672
80698
|
if (node.name) {
|
|
80673
80699
|
checkTypeNameIsReserved(node.name, Diagnostics.Type_alias_name_cannot_be_0);
|
|
@@ -80692,7 +80718,7 @@ function createTypeChecker(host) {
|
|
|
80692
80718
|
if (length(tags) > 1) {
|
|
80693
80719
|
for (let i = 1; i < length(tags); i++) {
|
|
80694
80720
|
const tagName = tags[i].tagName;
|
|
80695
|
-
|
|
80721
|
+
error2(tagName, Diagnostics._0_tag_already_specified, idText(tagName));
|
|
80696
80722
|
}
|
|
80697
80723
|
}
|
|
80698
80724
|
}
|
|
@@ -80724,33 +80750,33 @@ function createTypeChecker(host) {
|
|
|
80724
80750
|
function checkJSDocImplementsTag(node) {
|
|
80725
80751
|
const classLike = getEffectiveJSDocHost(node);
|
|
80726
80752
|
if (!classLike || !isClassDeclaration(classLike) && !isClassExpression(classLike)) {
|
|
80727
|
-
|
|
80753
|
+
error2(classLike, Diagnostics.JSDoc_0_is_not_attached_to_a_class, idText(node.tagName));
|
|
80728
80754
|
}
|
|
80729
80755
|
}
|
|
80730
80756
|
function checkJSDocAugmentsTag(node) {
|
|
80731
80757
|
const classLike = getEffectiveJSDocHost(node);
|
|
80732
80758
|
if (!classLike || !isClassDeclaration(classLike) && !isClassExpression(classLike)) {
|
|
80733
|
-
|
|
80759
|
+
error2(classLike, Diagnostics.JSDoc_0_is_not_attached_to_a_class, idText(node.tagName));
|
|
80734
80760
|
return;
|
|
80735
80761
|
}
|
|
80736
80762
|
const augmentsTags = getJSDocTags(classLike).filter(isJSDocAugmentsTag);
|
|
80737
80763
|
Debug.assert(augmentsTags.length > 0);
|
|
80738
80764
|
if (augmentsTags.length > 1) {
|
|
80739
|
-
|
|
80765
|
+
error2(augmentsTags[1], Diagnostics.Class_declarations_cannot_have_more_than_one_augments_or_extends_tag);
|
|
80740
80766
|
}
|
|
80741
80767
|
const name = getIdentifierFromEntityNameExpression(node.class.expression);
|
|
80742
80768
|
const extend2 = getClassExtendsHeritageElement(classLike);
|
|
80743
80769
|
if (extend2) {
|
|
80744
80770
|
const className = getIdentifierFromEntityNameExpression(extend2.expression);
|
|
80745
80771
|
if (className && name.escapedText !== className.escapedText) {
|
|
80746
|
-
|
|
80772
|
+
error2(name, Diagnostics.JSDoc_0_1_does_not_match_the_extends_2_clause, idText(node.tagName), idText(name), idText(className));
|
|
80747
80773
|
}
|
|
80748
80774
|
}
|
|
80749
80775
|
}
|
|
80750
80776
|
function checkJSDocAccessibilityModifiers(node) {
|
|
80751
80777
|
const host2 = getJSDocHost(node);
|
|
80752
80778
|
if (host2 && isPrivateIdentifierClassElementDeclaration(host2)) {
|
|
80753
|
-
|
|
80779
|
+
error2(node, Diagnostics.An_accessibility_modifier_cannot_be_used_with_a_private_identifier);
|
|
80754
80780
|
}
|
|
80755
80781
|
}
|
|
80756
80782
|
function getIdentifierFromEntityNameExpression(node) {
|
|
@@ -80792,7 +80818,7 @@ function createTypeChecker(host) {
|
|
|
80792
80818
|
if (isInJSFile(node)) {
|
|
80793
80819
|
const typeTag = getJSDocTypeTag(node);
|
|
80794
80820
|
if (typeTag && typeTag.typeExpression && !getContextualCallSignature(getTypeFromTypeNode(typeTag.typeExpression), node)) {
|
|
80795
|
-
|
|
80821
|
+
error2(typeTag.typeExpression.type, Diagnostics.The_type_of_a_function_declaration_must_match_the_function_s_signature);
|
|
80796
80822
|
}
|
|
80797
80823
|
}
|
|
80798
80824
|
function checkFunctionOrMethodDeclarationDiagnostics() {
|
|
@@ -81116,9 +81142,9 @@ function createTypeChecker(host) {
|
|
|
81116
81142
|
if (getNodeCheckFlags(current) & 4 /* CaptureThis */) {
|
|
81117
81143
|
const isDeclaration2 = node.kind !== 80 /* Identifier */;
|
|
81118
81144
|
if (isDeclaration2) {
|
|
81119
|
-
|
|
81145
|
+
error2(getNameOfDeclaration(node), Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference);
|
|
81120
81146
|
} else {
|
|
81121
|
-
|
|
81147
|
+
error2(node, Diagnostics.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference);
|
|
81122
81148
|
}
|
|
81123
81149
|
return true;
|
|
81124
81150
|
}
|
|
@@ -81130,9 +81156,9 @@ function createTypeChecker(host) {
|
|
|
81130
81156
|
if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) {
|
|
81131
81157
|
const isDeclaration2 = node.kind !== 80 /* Identifier */;
|
|
81132
81158
|
if (isDeclaration2) {
|
|
81133
|
-
|
|
81159
|
+
error2(getNameOfDeclaration(node), Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference);
|
|
81134
81160
|
} else {
|
|
81135
|
-
|
|
81161
|
+
error2(node, Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference);
|
|
81136
81162
|
}
|
|
81137
81163
|
return true;
|
|
81138
81164
|
}
|
|
@@ -81270,7 +81296,7 @@ function createTypeChecker(host) {
|
|
|
81270
81296
|
const namesShareScope = container && (container.kind === 240 /* Block */ && isFunctionLike(container.parent) || container.kind === 267 /* ModuleBlock */ || container.kind === 266 /* ModuleDeclaration */ || container.kind === 311 /* SourceFile */);
|
|
81271
81297
|
if (!namesShareScope) {
|
|
81272
81298
|
const name = symbolToString(localDeclarationSymbol);
|
|
81273
|
-
|
|
81299
|
+
error2(node, Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name);
|
|
81274
81300
|
}
|
|
81275
81301
|
}
|
|
81276
81302
|
}
|
|
@@ -81306,7 +81332,7 @@ function createTypeChecker(host) {
|
|
|
81306
81332
|
checkComputedPropertyName(node.propertyName);
|
|
81307
81333
|
}
|
|
81308
81334
|
const parent2 = node.parent.parent;
|
|
81309
|
-
const parentCheckMode = node.dotDotDotToken ?
|
|
81335
|
+
const parentCheckMode = node.dotDotDotToken ? 128 /* RestBindingElement */ : 0 /* Normal */;
|
|
81310
81336
|
const parentType = getTypeForBindingElementParent(parent2, parentCheckMode);
|
|
81311
81337
|
const name = node.propertyName || node.name;
|
|
81312
81338
|
if (parentType && !isBindingPattern(name)) {
|
|
@@ -81341,7 +81367,7 @@ function createTypeChecker(host) {
|
|
|
81341
81367
|
forEach(node.name.elements, checkSourceElement);
|
|
81342
81368
|
}
|
|
81343
81369
|
if (isParameter(node) && node.initializer && nodeIsMissing(getContainingFunction(node).body)) {
|
|
81344
|
-
|
|
81370
|
+
error2(node, Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation);
|
|
81345
81371
|
return;
|
|
81346
81372
|
}
|
|
81347
81373
|
if (isBindingPattern(node.name)) {
|
|
@@ -81393,7 +81419,7 @@ function createTypeChecker(host) {
|
|
|
81393
81419
|
}
|
|
81394
81420
|
if (symbol.declarations && symbol.declarations.length > 1) {
|
|
81395
81421
|
if (some(symbol.declarations, (d) => d !== node && isVariableLike(d) && !areDeclarationFlagsIdentical(d, node))) {
|
|
81396
|
-
|
|
81422
|
+
error2(node.name, Diagnostics.All_declarations_of_0_must_have_identical_modifiers, declarationNameToString(node.name));
|
|
81397
81423
|
}
|
|
81398
81424
|
}
|
|
81399
81425
|
} else {
|
|
@@ -81412,7 +81438,7 @@ function createTypeChecker(host) {
|
|
|
81412
81438
|
);
|
|
81413
81439
|
}
|
|
81414
81440
|
if (symbol.valueDeclaration && !areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) {
|
|
81415
|
-
|
|
81441
|
+
error2(node.name, Diagnostics.All_declarations_of_0_must_have_identical_modifiers, declarationNameToString(node.name));
|
|
81416
81442
|
}
|
|
81417
81443
|
}
|
|
81418
81444
|
if (node.kind !== 171 /* PropertyDeclaration */ && node.kind !== 170 /* PropertySignature */) {
|
|
@@ -81427,7 +81453,7 @@ function createTypeChecker(host) {
|
|
|
81427
81453
|
const nextDeclarationName = getNameOfDeclaration(nextDeclaration);
|
|
81428
81454
|
const message = nextDeclaration.kind === 171 /* PropertyDeclaration */ || nextDeclaration.kind === 170 /* PropertySignature */ ? Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 : Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2;
|
|
81429
81455
|
const declName = declarationNameToString(nextDeclarationName);
|
|
81430
|
-
const err =
|
|
81456
|
+
const err = error2(
|
|
81431
81457
|
nextDeclarationName,
|
|
81432
81458
|
message,
|
|
81433
81459
|
declName,
|
|
@@ -81477,7 +81503,7 @@ function createTypeChecker(host) {
|
|
|
81477
81503
|
checkTestingKnownTruthyCallableOrAwaitableType(node.expression, type, node.thenStatement);
|
|
81478
81504
|
checkSourceElement(node.thenStatement);
|
|
81479
81505
|
if (node.thenStatement.kind === 241 /* EmptyStatement */) {
|
|
81480
|
-
|
|
81506
|
+
error2(node.thenStatement, Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement);
|
|
81481
81507
|
}
|
|
81482
81508
|
checkSourceElement(node.elseStatement);
|
|
81483
81509
|
}
|
|
@@ -81527,7 +81553,7 @@ function createTypeChecker(host) {
|
|
|
81527
81553
|
getTypeNameForErrorDisplay(type)
|
|
81528
81554
|
);
|
|
81529
81555
|
} else {
|
|
81530
|
-
|
|
81556
|
+
error2(location, Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead);
|
|
81531
81557
|
}
|
|
81532
81558
|
}
|
|
81533
81559
|
}
|
|
@@ -81593,7 +81619,7 @@ function createTypeChecker(host) {
|
|
|
81593
81619
|
}
|
|
81594
81620
|
function checkTruthinessOfType(type, node) {
|
|
81595
81621
|
if (type.flags & 16384 /* Void */) {
|
|
81596
|
-
|
|
81622
|
+
error2(node, Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness);
|
|
81597
81623
|
}
|
|
81598
81624
|
return type;
|
|
81599
81625
|
}
|
|
@@ -81667,16 +81693,16 @@ function createTypeChecker(host) {
|
|
|
81667
81693
|
if (node.initializer.kind === 260 /* VariableDeclarationList */) {
|
|
81668
81694
|
const variable = node.initializer.declarations[0];
|
|
81669
81695
|
if (variable && isBindingPattern(variable.name)) {
|
|
81670
|
-
|
|
81696
|
+
error2(variable.name, Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern);
|
|
81671
81697
|
}
|
|
81672
81698
|
checkForInOrForOfVariableDeclaration(node);
|
|
81673
81699
|
} else {
|
|
81674
81700
|
const varExpr = node.initializer;
|
|
81675
81701
|
const leftType = checkExpression(varExpr);
|
|
81676
81702
|
if (varExpr.kind === 208 /* ArrayLiteralExpression */ || varExpr.kind === 209 /* ObjectLiteralExpression */) {
|
|
81677
|
-
|
|
81703
|
+
error2(varExpr, Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern);
|
|
81678
81704
|
} else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) {
|
|
81679
|
-
|
|
81705
|
+
error2(varExpr, Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any);
|
|
81680
81706
|
} else {
|
|
81681
81707
|
checkReferenceExpression(
|
|
81682
81708
|
varExpr,
|
|
@@ -81686,7 +81712,7 @@ function createTypeChecker(host) {
|
|
|
81686
81712
|
}
|
|
81687
81713
|
}
|
|
81688
81714
|
if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) {
|
|
81689
|
-
|
|
81715
|
+
error2(node.expression, Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0, typeToString(rightType));
|
|
81690
81716
|
}
|
|
81691
81717
|
checkSourceElement(node.statement);
|
|
81692
81718
|
if (node.locals) {
|
|
@@ -81757,7 +81783,7 @@ function createTypeChecker(host) {
|
|
|
81757
81783
|
if (hasStringConstituent) {
|
|
81758
81784
|
if (languageVersion < 1 /* ES5 */) {
|
|
81759
81785
|
if (errorNode) {
|
|
81760
|
-
|
|
81786
|
+
error2(errorNode, Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher);
|
|
81761
81787
|
reportedError = true;
|
|
81762
81788
|
}
|
|
81763
81789
|
}
|
|
@@ -82217,7 +82243,7 @@ function createTypeChecker(host) {
|
|
|
82217
82243
|
errorOutputContainer.errors ?? (errorOutputContainer.errors = []);
|
|
82218
82244
|
errorOutputContainer.errors.push(createDiagnosticForNode(errorNode, diagnostic, methodName));
|
|
82219
82245
|
} else {
|
|
82220
|
-
|
|
82246
|
+
error2(errorNode, diagnostic, methodName);
|
|
82221
82247
|
}
|
|
82222
82248
|
}
|
|
82223
82249
|
return methodName === "next" ? noIterationTypes : void 0;
|
|
@@ -82272,7 +82298,7 @@ function createTypeChecker(host) {
|
|
|
82272
82298
|
errorOutputContainer.errors ?? (errorOutputContainer.errors = []);
|
|
82273
82299
|
errorOutputContainer.errors.push(createDiagnosticForNode(errorNode, resolver.mustHaveAValueDiagnostic, methodName));
|
|
82274
82300
|
} else {
|
|
82275
|
-
|
|
82301
|
+
error2(errorNode, resolver.mustHaveAValueDiagnostic, methodName);
|
|
82276
82302
|
}
|
|
82277
82303
|
}
|
|
82278
82304
|
yieldType = anyType;
|
|
@@ -82358,11 +82384,11 @@ function createTypeChecker(host) {
|
|
|
82358
82384
|
const exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
|
|
82359
82385
|
if (container.kind === 177 /* SetAccessor */) {
|
|
82360
82386
|
if (node.expression) {
|
|
82361
|
-
|
|
82387
|
+
error2(node, Diagnostics.Setters_cannot_return_a_value);
|
|
82362
82388
|
}
|
|
82363
82389
|
} else if (container.kind === 175 /* Constructor */) {
|
|
82364
82390
|
if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) {
|
|
82365
|
-
|
|
82391
|
+
error2(node, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
|
|
82366
82392
|
}
|
|
82367
82393
|
} else if (getReturnTypeFromAnnotation(container)) {
|
|
82368
82394
|
const unwrappedReturnType = unwrapReturnType(returnType, functionFlags) ?? returnType;
|
|
@@ -82378,7 +82404,7 @@ function createTypeChecker(host) {
|
|
|
82378
82404
|
}
|
|
82379
82405
|
}
|
|
82380
82406
|
} else if (container.kind !== 175 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeUndefinedVoidOrAny(container, returnType)) {
|
|
82381
|
-
|
|
82407
|
+
error2(node, Diagnostics.Not_all_code_paths_return_a_value);
|
|
82382
82408
|
}
|
|
82383
82409
|
}
|
|
82384
82410
|
function checkWithStatement(node) {
|
|
@@ -82414,7 +82440,7 @@ function createTypeChecker(host) {
|
|
|
82414
82440
|
}
|
|
82415
82441
|
forEach(clause.statements, checkSourceElement);
|
|
82416
82442
|
if (compilerOptions.noFallthroughCasesInSwitch && clause.fallthroughFlowNode && isReachableFlowNode(clause.fallthroughFlowNode)) {
|
|
82417
|
-
|
|
82443
|
+
error2(clause, Diagnostics.Fallthrough_case_in_switch);
|
|
82418
82444
|
}
|
|
82419
82445
|
function createLazyCaseClauseDiagnostics(clause2) {
|
|
82420
82446
|
return () => {
|
|
@@ -82564,7 +82590,7 @@ function createTypeChecker(host) {
|
|
|
82564
82590
|
const localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfDeclaration(info.declaration)) === type.symbol ? info.declaration : void 0;
|
|
82565
82591
|
const errorNode = localCheckDeclaration || localIndexDeclaration || (interfaceDeclaration && !some(getBaseTypes(type), (base) => !!getIndexInfoOfType(base, checkInfo.keyType) && !!getIndexTypeOfType(base, info.keyType)) ? interfaceDeclaration : void 0);
|
|
82566
82592
|
if (errorNode && !isTypeAssignableTo(checkInfo.type, info.type)) {
|
|
82567
|
-
|
|
82593
|
+
error2(
|
|
82568
82594
|
errorNode,
|
|
82569
82595
|
Diagnostics._0_index_type_1_is_not_assignable_to_2_index_type_3,
|
|
82570
82596
|
typeToString(checkInfo.keyType),
|
|
@@ -82587,12 +82613,12 @@ function createTypeChecker(host) {
|
|
|
82587
82613
|
case "symbol":
|
|
82588
82614
|
case "void":
|
|
82589
82615
|
case "object":
|
|
82590
|
-
|
|
82616
|
+
error2(name, message, name.escapedText);
|
|
82591
82617
|
}
|
|
82592
82618
|
}
|
|
82593
82619
|
function checkClassNameCollisionWithObject(name) {
|
|
82594
82620
|
if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(name).impliedNodeFormat === 1 /* CommonJS */)) {
|
|
82595
|
-
|
|
82621
|
+
error2(name, Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ModuleKind[moduleKind]);
|
|
82596
82622
|
}
|
|
82597
82623
|
}
|
|
82598
82624
|
function checkUnmatchedJSDocParameters(node) {
|
|
@@ -82615,7 +82641,7 @@ function createTypeChecker(host) {
|
|
|
82615
82641
|
const lastJSDocParamIndex = jsdocParameters.length - 1;
|
|
82616
82642
|
const lastJSDocParam = jsdocParameters[lastJSDocParamIndex];
|
|
82617
82643
|
if (isJs && lastJSDocParam && isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression && lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !excludedParameters.has(lastJSDocParamIndex) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
|
|
82618
|
-
|
|
82644
|
+
error2(lastJSDocParam.name, Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, idText(lastJSDocParam.name));
|
|
82619
82645
|
}
|
|
82620
82646
|
} else {
|
|
82621
82647
|
forEach(jsdocParameters, ({ name, isNameFirst }, index) => {
|
|
@@ -82624,7 +82650,7 @@ function createTypeChecker(host) {
|
|
|
82624
82650
|
}
|
|
82625
82651
|
if (isQualifiedName(name)) {
|
|
82626
82652
|
if (isJs) {
|
|
82627
|
-
|
|
82653
|
+
error2(name, Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, entityNameToString(name), entityNameToString(name.left));
|
|
82628
82654
|
}
|
|
82629
82655
|
} else {
|
|
82630
82656
|
if (!isNameFirst) {
|
|
@@ -82649,11 +82675,11 @@ function createTypeChecker(host) {
|
|
|
82649
82675
|
seenDefault = true;
|
|
82650
82676
|
checkTypeParametersNotReferenced(node.default, typeParameterDeclarations, i);
|
|
82651
82677
|
} else if (seenDefault) {
|
|
82652
|
-
|
|
82678
|
+
error2(node, Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters);
|
|
82653
82679
|
}
|
|
82654
82680
|
for (let j = 0; j < i; j++) {
|
|
82655
82681
|
if (typeParameterDeclarations[j].symbol === node.symbol) {
|
|
82656
|
-
|
|
82682
|
+
error2(node.name, Diagnostics.Duplicate_identifier_0, declarationNameToString(node.name));
|
|
82657
82683
|
}
|
|
82658
82684
|
}
|
|
82659
82685
|
};
|
|
@@ -82667,7 +82693,7 @@ function createTypeChecker(host) {
|
|
|
82667
82693
|
if (type.flags & 262144 /* TypeParameter */) {
|
|
82668
82694
|
for (let i = index; i < typeParameters.length; i++) {
|
|
82669
82695
|
if (type.symbol === getSymbolOfDeclaration(typeParameters[i])) {
|
|
82670
|
-
|
|
82696
|
+
error2(node, Diagnostics.Type_parameter_defaults_can_only_reference_previously_declared_type_parameters);
|
|
82671
82697
|
}
|
|
82672
82698
|
}
|
|
82673
82699
|
}
|
|
@@ -82690,7 +82716,7 @@ function createTypeChecker(host) {
|
|
|
82690
82716
|
if (!areTypeParametersIdentical(declarations, type.localTypeParameters, getEffectiveTypeParameterDeclarations)) {
|
|
82691
82717
|
const name = symbolToString(symbol);
|
|
82692
82718
|
for (const declaration of declarations) {
|
|
82693
|
-
|
|
82719
|
+
error2(declaration.name, Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name);
|
|
82694
82720
|
}
|
|
82695
82721
|
}
|
|
82696
82722
|
}
|
|
@@ -82861,18 +82887,18 @@ function createTypeChecker(host) {
|
|
|
82861
82887
|
}
|
|
82862
82888
|
if (baseConstructorType.flags & 8650752 /* TypeVariable */) {
|
|
82863
82889
|
if (!isMixinConstructorType(staticType)) {
|
|
82864
|
-
|
|
82890
|
+
error2(node.name || node, Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any);
|
|
82865
82891
|
} else {
|
|
82866
82892
|
const constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */);
|
|
82867
82893
|
if (constructSignatures.some((signature) => signature.flags & 4 /* Abstract */) && !hasSyntacticModifier(node, 256 /* Abstract */)) {
|
|
82868
|
-
|
|
82894
|
+
error2(node.name || node, Diagnostics.A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract);
|
|
82869
82895
|
}
|
|
82870
82896
|
}
|
|
82871
82897
|
}
|
|
82872
82898
|
if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 8650752 /* TypeVariable */)) {
|
|
82873
82899
|
const constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode);
|
|
82874
82900
|
if (forEach(constructors, (sig) => !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType))) {
|
|
82875
|
-
|
|
82901
|
+
error2(baseTypeNode.expression, Diagnostics.Base_constructors_must_all_have_the_same_return_type);
|
|
82876
82902
|
}
|
|
82877
82903
|
}
|
|
82878
82904
|
checkKindsOfPropertyMemberOverrides(type, baseType);
|
|
@@ -82884,7 +82910,7 @@ function createTypeChecker(host) {
|
|
|
82884
82910
|
if (implementedTypeNodes) {
|
|
82885
82911
|
for (const typeRefNode of implementedTypeNodes) {
|
|
82886
82912
|
if (!isEntityNameExpression(typeRefNode.expression) || isOptionalChain(typeRefNode.expression)) {
|
|
82887
|
-
|
|
82913
|
+
error2(typeRefNode.expression, Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments);
|
|
82888
82914
|
}
|
|
82889
82915
|
checkTypeReferenceNode(typeRefNode);
|
|
82890
82916
|
addLazyDiagnostic(createImplementsDiagnostics(typeRefNode));
|
|
@@ -82917,7 +82943,7 @@ function createTypeChecker(host) {
|
|
|
82917
82943
|
issueMemberSpecificError(node, typeWithThis, baseWithThis, genericDiag);
|
|
82918
82944
|
}
|
|
82919
82945
|
} else {
|
|
82920
|
-
|
|
82946
|
+
error2(typeRefNode, Diagnostics.A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members);
|
|
82921
82947
|
}
|
|
82922
82948
|
}
|
|
82923
82949
|
};
|
|
@@ -82995,12 +83021,12 @@ function createTypeChecker(host) {
|
|
|
82995
83021
|
if (prop && !baseProp && memberHasOverrideModifier) {
|
|
82996
83022
|
if (errorNode) {
|
|
82997
83023
|
const suggestion = getSuggestedSymbolForNonexistentClassMember(memberName, baseType);
|
|
82998
|
-
suggestion ?
|
|
83024
|
+
suggestion ? error2(
|
|
82999
83025
|
errorNode,
|
|
83000
83026
|
isJs ? Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1 : Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1,
|
|
83001
83027
|
baseClassName,
|
|
83002
83028
|
symbolToString(suggestion)
|
|
83003
|
-
) :
|
|
83029
|
+
) : error2(
|
|
83004
83030
|
errorNode,
|
|
83005
83031
|
isJs ? Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0 : Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0,
|
|
83006
83032
|
baseClassName
|
|
@@ -83015,12 +83041,12 @@ function createTypeChecker(host) {
|
|
|
83015
83041
|
if (!baseHasAbstract) {
|
|
83016
83042
|
if (errorNode) {
|
|
83017
83043
|
const diag2 = memberIsParameterProperty ? isJs ? Diagnostics.This_parameter_property_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0 : Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0 : isJs ? Diagnostics.This_member_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0 : Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0;
|
|
83018
|
-
|
|
83044
|
+
error2(errorNode, diag2, baseClassName);
|
|
83019
83045
|
}
|
|
83020
83046
|
return 1 /* NeedsOverride */;
|
|
83021
83047
|
} else if (memberHasAbstractModifier && baseHasAbstract) {
|
|
83022
83048
|
if (errorNode) {
|
|
83023
|
-
|
|
83049
|
+
error2(errorNode, Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0, baseClassName);
|
|
83024
83050
|
}
|
|
83025
83051
|
return 1 /* NeedsOverride */;
|
|
83026
83052
|
}
|
|
@@ -83028,7 +83054,7 @@ function createTypeChecker(host) {
|
|
|
83028
83054
|
} else if (memberHasOverrideModifier) {
|
|
83029
83055
|
if (errorNode) {
|
|
83030
83056
|
const className = typeToString(type);
|
|
83031
|
-
|
|
83057
|
+
error2(
|
|
83032
83058
|
errorNode,
|
|
83033
83059
|
isJs ? Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class : Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class,
|
|
83034
83060
|
className
|
|
@@ -83081,7 +83107,7 @@ function createTypeChecker(host) {
|
|
|
83081
83107
|
if (declaration && hasEffectiveModifier(declaration, 8 /* Private */)) {
|
|
83082
83108
|
const typeClassDeclaration = getClassLikeDeclarationOfSymbol(type.symbol);
|
|
83083
83109
|
if (!isNodeWithinClass(node, typeClassDeclaration)) {
|
|
83084
|
-
|
|
83110
|
+
error2(node, Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol));
|
|
83085
83111
|
}
|
|
83086
83112
|
}
|
|
83087
83113
|
}
|
|
@@ -83150,7 +83176,7 @@ function createTypeChecker(host) {
|
|
|
83150
83176
|
}
|
|
83151
83177
|
}
|
|
83152
83178
|
if (!inheritedAbstractMemberNotImplementedError) {
|
|
83153
|
-
inheritedAbstractMemberNotImplementedError =
|
|
83179
|
+
inheritedAbstractMemberNotImplementedError = error2(
|
|
83154
83180
|
derivedClassDecl,
|
|
83155
83181
|
Diagnostics.Non_abstract_class_0_does_not_implement_all_abstract_members_of_1,
|
|
83156
83182
|
typeToString(type),
|
|
@@ -83196,7 +83222,7 @@ function createTypeChecker(host) {
|
|
|
83196
83222
|
const overriddenInstanceAccessor = basePropertyFlags === 4 /* Property */ && derivedPropertyFlags !== 4 /* Property */;
|
|
83197
83223
|
if (overriddenInstanceProperty || overriddenInstanceAccessor) {
|
|
83198
83224
|
const errorMessage2 = overriddenInstanceProperty ? Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property : Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor;
|
|
83199
|
-
|
|
83225
|
+
error2(getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage2, symbolToString(base), typeToString(baseType), typeToString(type));
|
|
83200
83226
|
} else if (useDefineForClassFields) {
|
|
83201
83227
|
const uninitialized = (_c = derived.declarations) == null ? void 0 : _c.find((d) => d.kind === 171 /* PropertyDeclaration */ && !d.initializer);
|
|
83202
83228
|
if (uninitialized && !(derived.flags & 33554432 /* Transient */) && !(baseDeclarationFlags & 256 /* Abstract */) && !(derivedDeclarationFlags & 256 /* Abstract */) && !((_d = derived.declarations) == null ? void 0 : _d.some((d) => !!(d.flags & 16777216 /* Ambient */)))) {
|
|
@@ -83204,7 +83230,7 @@ function createTypeChecker(host) {
|
|
|
83204
83230
|
const propName = uninitialized.name;
|
|
83205
83231
|
if (uninitialized.exclamationToken || !constructor || !isIdentifier(propName) || !strictNullChecks || !isPropertyInitializedInConstructor(propName, type, constructor)) {
|
|
83206
83232
|
const errorMessage2 = Diagnostics.Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration;
|
|
83207
|
-
|
|
83233
|
+
error2(getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage2, symbolToString(base), typeToString(baseType));
|
|
83208
83234
|
}
|
|
83209
83235
|
}
|
|
83210
83236
|
}
|
|
@@ -83221,7 +83247,7 @@ function createTypeChecker(host) {
|
|
|
83221
83247
|
} else {
|
|
83222
83248
|
errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function;
|
|
83223
83249
|
}
|
|
83224
|
-
|
|
83250
|
+
error2(getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type));
|
|
83225
83251
|
}
|
|
83226
83252
|
}
|
|
83227
83253
|
}
|
|
@@ -83300,7 +83326,7 @@ function createTypeChecker(host) {
|
|
|
83300
83326
|
const type = getTypeOfSymbol(getSymbolOfDeclaration(member));
|
|
83301
83327
|
if (!(type.flags & 3 /* AnyOrUnknown */ || containsUndefinedType(type))) {
|
|
83302
83328
|
if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) {
|
|
83303
|
-
|
|
83329
|
+
error2(member.name, Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, declarationNameToString(propName));
|
|
83304
83330
|
}
|
|
83305
83331
|
}
|
|
83306
83332
|
}
|
|
@@ -83357,7 +83383,7 @@ function createTypeChecker(host) {
|
|
|
83357
83383
|
});
|
|
83358
83384
|
forEach(getInterfaceBaseTypeNodes(node), (heritageElement) => {
|
|
83359
83385
|
if (!isEntityNameExpression(heritageElement.expression) || isOptionalChain(heritageElement.expression)) {
|
|
83360
|
-
|
|
83386
|
+
error2(heritageElement.expression, Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments);
|
|
83361
83387
|
}
|
|
83362
83388
|
checkTypeReferenceNode(heritageElement);
|
|
83363
83389
|
});
|
|
@@ -83374,7 +83400,7 @@ function createTypeChecker(host) {
|
|
|
83374
83400
|
checkTypeParameters(node.typeParameters);
|
|
83375
83401
|
if (node.type.kind === 141 /* IntrinsicKeyword */) {
|
|
83376
83402
|
if (!intrinsicTypeKinds.has(node.name.escapedText) || length(node.typeParameters) !== 1) {
|
|
83377
|
-
|
|
83403
|
+
error2(node.type, Diagnostics.The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types);
|
|
83378
83404
|
}
|
|
83379
83405
|
} else {
|
|
83380
83406
|
checkSourceElement(node.type);
|
|
@@ -83395,11 +83421,11 @@ function createTypeChecker(host) {
|
|
|
83395
83421
|
}
|
|
83396
83422
|
function computeMemberValue(member, autoValue) {
|
|
83397
83423
|
if (isComputedNonLiteralName(member.name)) {
|
|
83398
|
-
|
|
83424
|
+
error2(member.name, Diagnostics.Computed_property_names_are_not_allowed_in_enums);
|
|
83399
83425
|
} else {
|
|
83400
83426
|
const text = getTextOfPropertyName(member.name);
|
|
83401
83427
|
if (isNumericLiteralName(text) && !isInfinityOrNaNString(text)) {
|
|
83402
|
-
|
|
83428
|
+
error2(member.name, Diagnostics.An_enum_member_cannot_have_a_numeric_name);
|
|
83403
83429
|
}
|
|
83404
83430
|
}
|
|
83405
83431
|
if (member.initializer) {
|
|
@@ -83411,7 +83437,7 @@ function createTypeChecker(host) {
|
|
|
83411
83437
|
if (autoValue !== void 0) {
|
|
83412
83438
|
return autoValue;
|
|
83413
83439
|
}
|
|
83414
|
-
|
|
83440
|
+
error2(member.name, Diagnostics.Enum_member_must_have_initializer);
|
|
83415
83441
|
return void 0;
|
|
83416
83442
|
}
|
|
83417
83443
|
function computeConstantValue(member) {
|
|
@@ -83420,12 +83446,12 @@ function createTypeChecker(host) {
|
|
|
83420
83446
|
const value = evaluate(initializer, member);
|
|
83421
83447
|
if (value !== void 0) {
|
|
83422
83448
|
if (isConstEnum && typeof value === "number" && !isFinite(value)) {
|
|
83423
|
-
|
|
83449
|
+
error2(initializer, isNaN(value) ? Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN : Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value);
|
|
83424
83450
|
}
|
|
83425
83451
|
} else if (isConstEnum) {
|
|
83426
|
-
|
|
83452
|
+
error2(initializer, Diagnostics.const_enum_member_initializers_must_be_constant_expressions);
|
|
83427
83453
|
} else if (member.parent.flags & 16777216 /* Ambient */) {
|
|
83428
|
-
|
|
83454
|
+
error2(initializer, Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression);
|
|
83429
83455
|
} else {
|
|
83430
83456
|
checkTypeAssignableTo(checkExpression(initializer), numberType, initializer, Diagnostics.Type_0_is_not_assignable_to_type_1_as_required_for_computed_enum_member_values);
|
|
83431
83457
|
}
|
|
@@ -83539,11 +83565,11 @@ function createTypeChecker(host) {
|
|
|
83539
83565
|
function evaluateEnumMember(expr, symbol, location) {
|
|
83540
83566
|
const declaration = symbol.valueDeclaration;
|
|
83541
83567
|
if (!declaration || declaration === location) {
|
|
83542
|
-
|
|
83568
|
+
error2(expr, Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(symbol));
|
|
83543
83569
|
return void 0;
|
|
83544
83570
|
}
|
|
83545
83571
|
if (!isBlockScopedNameDeclaredBeforeUse(declaration, location)) {
|
|
83546
|
-
|
|
83572
|
+
error2(expr, Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
|
|
83547
83573
|
return 0;
|
|
83548
83574
|
}
|
|
83549
83575
|
return getEnumMemberValue(declaration);
|
|
@@ -83576,7 +83602,7 @@ function createTypeChecker(host) {
|
|
|
83576
83602
|
const enumIsConst = isEnumConst(node);
|
|
83577
83603
|
forEach(enumSymbol.declarations, (decl) => {
|
|
83578
83604
|
if (isEnumDeclaration(decl) && isEnumConst(decl) !== enumIsConst) {
|
|
83579
|
-
|
|
83605
|
+
error2(getNameOfDeclaration(decl), Diagnostics.Enum_declarations_must_all_be_const_or_non_const);
|
|
83580
83606
|
}
|
|
83581
83607
|
});
|
|
83582
83608
|
}
|
|
@@ -83592,7 +83618,7 @@ function createTypeChecker(host) {
|
|
|
83592
83618
|
const firstEnumMember = enumDeclaration.members[0];
|
|
83593
83619
|
if (!firstEnumMember.initializer) {
|
|
83594
83620
|
if (seenEnumMissingInitialInitializer) {
|
|
83595
|
-
|
|
83621
|
+
error2(firstEnumMember.name, Diagnostics.In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element);
|
|
83596
83622
|
} else {
|
|
83597
83623
|
seenEnumMissingInitialInitializer = true;
|
|
83598
83624
|
}
|
|
@@ -83602,7 +83628,7 @@ function createTypeChecker(host) {
|
|
|
83602
83628
|
}
|
|
83603
83629
|
function checkEnumMember(node) {
|
|
83604
83630
|
if (isPrivateIdentifier(node.name)) {
|
|
83605
|
-
|
|
83631
|
+
error2(node, Diagnostics.An_enum_member_cannot_be_named_with_a_private_identifier);
|
|
83606
83632
|
}
|
|
83607
83633
|
if (node.initializer) {
|
|
83608
83634
|
checkExpression(node.initializer);
|
|
@@ -83643,7 +83669,7 @@ function createTypeChecker(host) {
|
|
|
83643
83669
|
const isGlobalAugmentation = isGlobalScopeAugmentation(node);
|
|
83644
83670
|
const inAmbientContext = node.flags & 16777216 /* Ambient */;
|
|
83645
83671
|
if (isGlobalAugmentation && !inAmbientContext) {
|
|
83646
|
-
|
|
83672
|
+
error2(node.name, Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context);
|
|
83647
83673
|
}
|
|
83648
83674
|
const isAmbientExternalModule = isAmbientModule(node);
|
|
83649
83675
|
const contextErrorMessage = isAmbientExternalModule ? Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file : Diagnostics.A_namespace_declaration_is_only_allowed_at_the_top_level_of_a_namespace_or_module;
|
|
@@ -83662,15 +83688,15 @@ function createTypeChecker(host) {
|
|
|
83662
83688
|
const symbol = getSymbolOfDeclaration(node);
|
|
83663
83689
|
if (symbol.flags & 512 /* ValueModule */ && !inAmbientContext && isInstantiatedModule(node, shouldPreserveConstEnums(compilerOptions))) {
|
|
83664
83690
|
if (getIsolatedModules(compilerOptions) && !getSourceFileOfNode(node).externalModuleIndicator) {
|
|
83665
|
-
|
|
83691
|
+
error2(node.name, Diagnostics.Namespaces_are_not_allowed_in_global_script_files_when_0_is_enabled_If_this_file_is_not_intended_to_be_a_global_script_set_moduleDetection_to_force_or_add_an_empty_export_statement, isolatedModulesLikeFlagName);
|
|
83666
83692
|
}
|
|
83667
83693
|
if (((_a = symbol.declarations) == null ? void 0 : _a.length) > 1) {
|
|
83668
83694
|
const firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol);
|
|
83669
83695
|
if (firstNonAmbientClassOrFunc) {
|
|
83670
83696
|
if (getSourceFileOfNode(node) !== getSourceFileOfNode(firstNonAmbientClassOrFunc)) {
|
|
83671
|
-
|
|
83697
|
+
error2(node.name, Diagnostics.A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged);
|
|
83672
83698
|
} else if (node.pos < firstNonAmbientClassOrFunc.pos) {
|
|
83673
|
-
|
|
83699
|
+
error2(node.name, Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged);
|
|
83674
83700
|
}
|
|
83675
83701
|
}
|
|
83676
83702
|
const mergedClass = getDeclarationOfKind(symbol, 262 /* ClassDeclaration */);
|
|
@@ -83681,7 +83707,7 @@ function createTypeChecker(host) {
|
|
|
83681
83707
|
if (compilerOptions.verbatimModuleSyntax && node.parent.kind === 311 /* SourceFile */ && (moduleKind === 1 /* CommonJS */ || node.parent.impliedNodeFormat === 1 /* CommonJS */)) {
|
|
83682
83708
|
const exportModifier = (_b = node.modifiers) == null ? void 0 : _b.find((m) => m.kind === 95 /* ExportKeyword */);
|
|
83683
83709
|
if (exportModifier) {
|
|
83684
|
-
|
|
83710
|
+
error2(exportModifier, Diagnostics.A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
|
|
83685
83711
|
}
|
|
83686
83712
|
}
|
|
83687
83713
|
}
|
|
@@ -83695,15 +83721,15 @@ function createTypeChecker(host) {
|
|
|
83695
83721
|
}
|
|
83696
83722
|
} else if (isGlobalSourceFile(node.parent)) {
|
|
83697
83723
|
if (isGlobalAugmentation) {
|
|
83698
|
-
|
|
83724
|
+
error2(node.name, Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations);
|
|
83699
83725
|
} else if (isExternalModuleNameRelative(getTextOfIdentifierOrLiteral(node.name))) {
|
|
83700
|
-
|
|
83726
|
+
error2(node.name, Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name);
|
|
83701
83727
|
}
|
|
83702
83728
|
} else {
|
|
83703
83729
|
if (isGlobalAugmentation) {
|
|
83704
|
-
|
|
83730
|
+
error2(node.name, Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations);
|
|
83705
83731
|
} else {
|
|
83706
|
-
|
|
83732
|
+
error2(node.name, Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces);
|
|
83707
83733
|
}
|
|
83708
83734
|
}
|
|
83709
83735
|
}
|
|
@@ -83770,17 +83796,17 @@ function createTypeChecker(host) {
|
|
|
83770
83796
|
return false;
|
|
83771
83797
|
}
|
|
83772
83798
|
if (!isStringLiteral(moduleName)) {
|
|
83773
|
-
|
|
83799
|
+
error2(moduleName, Diagnostics.String_literal_expected);
|
|
83774
83800
|
return false;
|
|
83775
83801
|
}
|
|
83776
83802
|
const inAmbientExternalModule = node.parent.kind === 267 /* ModuleBlock */ && isAmbientModule(node.parent.parent);
|
|
83777
83803
|
if (node.parent.kind !== 311 /* SourceFile */ && !inAmbientExternalModule) {
|
|
83778
|
-
|
|
83804
|
+
error2(moduleName, node.kind === 277 /* ExportDeclaration */ ? Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module);
|
|
83779
83805
|
return false;
|
|
83780
83806
|
}
|
|
83781
83807
|
if (inAmbientExternalModule && isExternalModuleNameRelative(moduleName.text)) {
|
|
83782
83808
|
if (!isTopLevelInExternalModuleAugmentation(node)) {
|
|
83783
|
-
|
|
83809
|
+
error2(node, Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name);
|
|
83784
83810
|
return false;
|
|
83785
83811
|
}
|
|
83786
83812
|
}
|
|
@@ -83789,7 +83815,7 @@ function createTypeChecker(host) {
|
|
|
83789
83815
|
for (const clause of node.assertClause.elements) {
|
|
83790
83816
|
if (!isStringLiteral(clause.value)) {
|
|
83791
83817
|
hasError = true;
|
|
83792
|
-
|
|
83818
|
+
error2(clause.value, Diagnostics.Import_assertion_values_must_be_string_literal_expressions);
|
|
83793
83819
|
}
|
|
83794
83820
|
}
|
|
83795
83821
|
return !hasError;
|
|
@@ -83806,7 +83832,7 @@ function createTypeChecker(host) {
|
|
|
83806
83832
|
const errorNode = isImportOrExportSpecifier(node) ? node.propertyName || node.name : isNamedDeclaration(node) ? node.name : node;
|
|
83807
83833
|
Debug.assert(node.kind !== 279 /* NamespaceExport */);
|
|
83808
83834
|
if (node.kind === 280 /* ExportSpecifier */) {
|
|
83809
|
-
const diag2 =
|
|
83835
|
+
const diag2 = error2(errorNode, Diagnostics.Types_cannot_appear_in_export_declarations_in_JavaScript_files);
|
|
83810
83836
|
const alreadyExportedSymbol = (_b = (_a = getSourceFileOfNode(node).symbol) == null ? void 0 : _a.exports) == null ? void 0 : _b.get((node.propertyName || node.name).escapedText);
|
|
83811
83837
|
if (alreadyExportedSymbol === target) {
|
|
83812
83838
|
const exportingDeclaration = (_c = alreadyExportedSymbol.declarations) == null ? void 0 : _c.find(isJSDocNode);
|
|
@@ -83823,7 +83849,7 @@ function createTypeChecker(host) {
|
|
|
83823
83849
|
const importDeclaration = findAncestor(node, or(isImportDeclaration, isImportEqualsDeclaration));
|
|
83824
83850
|
const moduleSpecifier = (importDeclaration && ((_d = tryGetModuleSpecifierFromDeclaration(importDeclaration)) == null ? void 0 : _d.text)) ?? "...";
|
|
83825
83851
|
const importedIdentifier = unescapeLeadingUnderscores(isIdentifier(errorNode) ? errorNode.escapedText : symbol.escapedName);
|
|
83826
|
-
|
|
83852
|
+
error2(
|
|
83827
83853
|
errorNode,
|
|
83828
83854
|
Diagnostics._0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation,
|
|
83829
83855
|
importedIdentifier,
|
|
@@ -83836,7 +83862,7 @@ function createTypeChecker(host) {
|
|
|
83836
83862
|
const excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0);
|
|
83837
83863
|
if (targetFlags & excludedMeanings) {
|
|
83838
83864
|
const message = node.kind === 280 /* ExportSpecifier */ ? Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
|
|
83839
|
-
|
|
83865
|
+
error2(node, message, symbolToString(symbol));
|
|
83840
83866
|
}
|
|
83841
83867
|
if (getIsolatedModules(compilerOptions) && !isTypeOnlyImportOrExportDeclaration(node) && !(node.flags & 16777216 /* Ambient */)) {
|
|
83842
83868
|
const typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol);
|
|
@@ -83851,20 +83877,20 @@ function createTypeChecker(host) {
|
|
|
83851
83877
|
const message = compilerOptions.verbatimModuleSyntax && isInternalModuleImportEqualsDeclaration(node) ? Diagnostics.An_import_alias_cannot_resolve_to_a_type_or_type_only_declaration_when_verbatimModuleSyntax_is_enabled : isType ? compilerOptions.verbatimModuleSyntax ? Diagnostics._0_is_a_type_and_must_be_imported_using_a_type_only_import_when_verbatimModuleSyntax_is_enabled : Diagnostics._0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled : compilerOptions.verbatimModuleSyntax ? Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_verbatimModuleSyntax_is_enabled : Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled;
|
|
83852
83878
|
const name = idText(node.kind === 275 /* ImportSpecifier */ ? node.propertyName || node.name : node.name);
|
|
83853
83879
|
addTypeOnlyDeclarationRelatedInfo(
|
|
83854
|
-
|
|
83880
|
+
error2(node, message, name),
|
|
83855
83881
|
isType ? void 0 : typeOnlyAlias,
|
|
83856
83882
|
name
|
|
83857
83883
|
);
|
|
83858
83884
|
}
|
|
83859
83885
|
if (isType && node.kind === 270 /* ImportEqualsDeclaration */ && hasEffectiveModifier(node, 1 /* Export */)) {
|
|
83860
|
-
|
|
83886
|
+
error2(node, Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_0_is_enabled, isolatedModulesLikeFlagName);
|
|
83861
83887
|
}
|
|
83862
83888
|
break;
|
|
83863
83889
|
}
|
|
83864
83890
|
case 280 /* ExportSpecifier */: {
|
|
83865
83891
|
if (compilerOptions.verbatimModuleSyntax || getSourceFileOfNode(typeOnlyAlias) !== getSourceFileOfNode(node)) {
|
|
83866
83892
|
const name = idText(node.propertyName || node.name);
|
|
83867
|
-
const diagnostic = isType ?
|
|
83893
|
+
const diagnostic = isType ? error2(node, Diagnostics.Re_exporting_a_type_when_0_is_enabled_requires_using_export_type, isolatedModulesLikeFlagName) : error2(node, Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_re_exported_using_a_type_only_re_export_when_1_is_enabled, name, isolatedModulesLikeFlagName);
|
|
83868
83894
|
addTypeOnlyDeclarationRelatedInfo(diagnostic, isType ? void 0 : typeOnlyAlias, name);
|
|
83869
83895
|
break;
|
|
83870
83896
|
}
|
|
@@ -83872,7 +83898,7 @@ function createTypeChecker(host) {
|
|
|
83872
83898
|
}
|
|
83873
83899
|
}
|
|
83874
83900
|
if (compilerOptions.verbatimModuleSyntax && node.kind !== 270 /* ImportEqualsDeclaration */ && !isInJSFile(node) && (moduleKind === 1 /* CommonJS */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
|
|
83875
|
-
|
|
83901
|
+
error2(node, Diagnostics.ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
|
|
83876
83902
|
}
|
|
83877
83903
|
}
|
|
83878
83904
|
if (isImportSpecifier(node)) {
|
|
@@ -83994,7 +84020,7 @@ function createTypeChecker(host) {
|
|
|
83994
84020
|
if (targetFlags & 111551 /* Value */) {
|
|
83995
84021
|
const moduleName = getFirstIdentifier(node.moduleReference);
|
|
83996
84022
|
if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) {
|
|
83997
|
-
|
|
84023
|
+
error2(moduleName, Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, declarationNameToString(moduleName));
|
|
83998
84024
|
}
|
|
83999
84025
|
}
|
|
84000
84026
|
if (targetFlags & 788968 /* Type */) {
|
|
@@ -84028,12 +84054,12 @@ function createTypeChecker(host) {
|
|
|
84028
84054
|
const inAmbientExternalModule = node.parent.kind === 267 /* ModuleBlock */ && isAmbientModule(node.parent.parent);
|
|
84029
84055
|
const inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 267 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 16777216 /* Ambient */;
|
|
84030
84056
|
if (node.parent.kind !== 311 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) {
|
|
84031
|
-
|
|
84057
|
+
error2(node, Diagnostics.Export_declarations_are_not_permitted_in_a_namespace);
|
|
84032
84058
|
}
|
|
84033
84059
|
} else {
|
|
84034
84060
|
const moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier);
|
|
84035
84061
|
if (moduleSymbol && hasExportAssignmentSymbol(moduleSymbol)) {
|
|
84036
|
-
|
|
84062
|
+
error2(node.moduleSpecifier, Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol));
|
|
84037
84063
|
} else if (node.exportClause) {
|
|
84038
84064
|
checkAliasSymbol(node.exportClause);
|
|
84039
84065
|
}
|
|
@@ -84094,7 +84120,7 @@ function createTypeChecker(host) {
|
|
|
84094
84120
|
}
|
|
84095
84121
|
for (const statement of sourceFile.statements) {
|
|
84096
84122
|
if (canConvertImportDeclarationToTypeOnly(statement) || canConvertImportEqualsDeclarationToTypeOnly(statement)) {
|
|
84097
|
-
|
|
84123
|
+
error2(
|
|
84098
84124
|
statement,
|
|
84099
84125
|
Diagnostics.This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set_to_error
|
|
84100
84126
|
);
|
|
@@ -84124,7 +84150,7 @@ function createTypeChecker(host) {
|
|
|
84124
84150
|
true
|
|
84125
84151
|
);
|
|
84126
84152
|
if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || symbol.declarations && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) {
|
|
84127
|
-
|
|
84153
|
+
error2(exportedName, Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, idText(exportedName));
|
|
84128
84154
|
} else {
|
|
84129
84155
|
if (!node.isTypeOnly && !node.parent.parent.isTypeOnly) {
|
|
84130
84156
|
markExportAsReferenced(node);
|
|
@@ -84148,9 +84174,9 @@ function createTypeChecker(host) {
|
|
|
84148
84174
|
const container = node.parent.kind === 311 /* SourceFile */ ? node.parent : node.parent.parent;
|
|
84149
84175
|
if (container.kind === 266 /* ModuleDeclaration */ && !isAmbientModule(container)) {
|
|
84150
84176
|
if (node.isExportEquals) {
|
|
84151
|
-
|
|
84177
|
+
error2(node, Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace);
|
|
84152
84178
|
} else {
|
|
84153
|
-
|
|
84179
|
+
error2(node, Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module);
|
|
84154
84180
|
}
|
|
84155
84181
|
return;
|
|
84156
84182
|
}
|
|
@@ -84178,14 +84204,14 @@ function createTypeChecker(host) {
|
|
|
84178
84204
|
if (getAllSymbolFlags(sym) & 111551 /* Value */) {
|
|
84179
84205
|
checkExpressionCached(id);
|
|
84180
84206
|
if (!isIllegalExportDefaultInCJS && !(node.flags & 16777216 /* Ambient */) && compilerOptions.verbatimModuleSyntax && getTypeOnlyAliasDeclaration(sym, 111551 /* Value */)) {
|
|
84181
|
-
|
|
84207
|
+
error2(
|
|
84182
84208
|
id,
|
|
84183
84209
|
node.isExportEquals ? Diagnostics.An_export_declaration_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration : Diagnostics.An_export_default_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration,
|
|
84184
84210
|
idText(id)
|
|
84185
84211
|
);
|
|
84186
84212
|
}
|
|
84187
84213
|
} else if (!isIllegalExportDefaultInCJS && !(node.flags & 16777216 /* Ambient */) && compilerOptions.verbatimModuleSyntax) {
|
|
84188
|
-
|
|
84214
|
+
error2(
|
|
84189
84215
|
id,
|
|
84190
84216
|
node.isExportEquals ? Diagnostics.An_export_declaration_must_reference_a_value_when_verbatimModuleSyntax_is_enabled_but_0_only_refers_to_a_type : Diagnostics.An_export_default_must_reference_a_value_when_verbatimModuleSyntax_is_enabled_but_0_only_refers_to_a_type,
|
|
84191
84217
|
idText(id)
|
|
@@ -84205,7 +84231,7 @@ function createTypeChecker(host) {
|
|
|
84205
84231
|
checkExpressionCached(node.expression);
|
|
84206
84232
|
}
|
|
84207
84233
|
if (isIllegalExportDefaultInCJS) {
|
|
84208
|
-
|
|
84234
|
+
error2(node, Diagnostics.ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
|
|
84209
84235
|
}
|
|
84210
84236
|
checkExternalModuleExports(container);
|
|
84211
84237
|
if (node.flags & 16777216 /* Ambient */ && !isEntityNameExpression(node.expression)) {
|
|
@@ -84230,7 +84256,7 @@ function createTypeChecker(host) {
|
|
|
84230
84256
|
if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) {
|
|
84231
84257
|
const declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration;
|
|
84232
84258
|
if (declaration && !isTopLevelInExternalModuleAugmentation(declaration) && !isInJSFile(declaration)) {
|
|
84233
|
-
|
|
84259
|
+
error2(declaration, Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements);
|
|
84234
84260
|
}
|
|
84235
84261
|
}
|
|
84236
84262
|
const exports = getExportsOfModule(moduleSymbol);
|
|
@@ -84496,16 +84522,16 @@ function createTypeChecker(host) {
|
|
|
84496
84522
|
const { parent: parent2 } = node;
|
|
84497
84523
|
if (isParameter(parent2) && isJSDocFunctionType(parent2.parent)) {
|
|
84498
84524
|
if (last(parent2.parent.parameters) !== parent2) {
|
|
84499
|
-
|
|
84525
|
+
error2(node, Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
|
|
84500
84526
|
}
|
|
84501
84527
|
return;
|
|
84502
84528
|
}
|
|
84503
84529
|
if (!isJSDocTypeExpression(parent2)) {
|
|
84504
|
-
|
|
84530
|
+
error2(node, Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature);
|
|
84505
84531
|
}
|
|
84506
84532
|
const paramTag = node.parent.parent;
|
|
84507
84533
|
if (!isJSDocParameterTag(paramTag)) {
|
|
84508
|
-
|
|
84534
|
+
error2(node, Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature);
|
|
84509
84535
|
return;
|
|
84510
84536
|
}
|
|
84511
84537
|
const param = getParameterSymbolFromJSDoc(paramTag);
|
|
@@ -84514,7 +84540,7 @@ function createTypeChecker(host) {
|
|
|
84514
84540
|
}
|
|
84515
84541
|
const host2 = getHostSignatureFromJSDoc(paramTag);
|
|
84516
84542
|
if (!host2 || last(host2.parameters).symbol !== param) {
|
|
84517
|
-
|
|
84543
|
+
error2(node, Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
|
|
84518
84544
|
}
|
|
84519
84545
|
}
|
|
84520
84546
|
function getTypeFromJSDocVariadicType(node) {
|
|
@@ -86351,18 +86377,18 @@ function createTypeChecker(host) {
|
|
|
86351
86377
|
requestedExternalEmitHelperNames.add(name);
|
|
86352
86378
|
const symbol = resolveSymbol(getSymbol2(getExportsOfModule(helpersModule), escapeLeadingUnderscores(name), 111551 /* Value */));
|
|
86353
86379
|
if (!symbol) {
|
|
86354
|
-
|
|
86380
|
+
error2(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name);
|
|
86355
86381
|
} else if (helper & 524288 /* ClassPrivateFieldGet */) {
|
|
86356
86382
|
if (!some(getSignaturesOfSymbol(symbol), (signature) => getParameterCount(signature) > 3)) {
|
|
86357
|
-
|
|
86383
|
+
error2(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name, 4);
|
|
86358
86384
|
}
|
|
86359
86385
|
} else if (helper & 1048576 /* ClassPrivateFieldSet */) {
|
|
86360
86386
|
if (!some(getSignaturesOfSymbol(symbol), (signature) => getParameterCount(signature) > 4)) {
|
|
86361
|
-
|
|
86387
|
+
error2(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name, 5);
|
|
86362
86388
|
}
|
|
86363
86389
|
} else if (helper & 1024 /* SpreadArray */) {
|
|
86364
86390
|
if (!some(getSignaturesOfSymbol(symbol), (signature) => getParameterCount(signature) > 2)) {
|
|
86365
|
-
|
|
86391
|
+
error2(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name, 3);
|
|
86366
86392
|
}
|
|
86367
86393
|
}
|
|
86368
86394
|
}
|
|
@@ -86469,7 +86495,7 @@ function createTypeChecker(host) {
|
|
|
86469
86495
|
const sourceFile = getSourceFileOfNode(modifier);
|
|
86470
86496
|
if (!hasParseDiagnostics(sourceFile)) {
|
|
86471
86497
|
addRelatedInfo(
|
|
86472
|
-
|
|
86498
|
+
error2(modifier, Diagnostics.Decorators_may_not_appear_after_export_or_export_default_if_they_also_appear_before_export),
|
|
86473
86499
|
createDiagnosticForNode(firstDecorator, Diagnostics.Decorator_used_before_export_here)
|
|
86474
86500
|
);
|
|
86475
86501
|
return true;
|
|
@@ -86862,12 +86888,12 @@ function createTypeChecker(host) {
|
|
|
86862
86888
|
if (length(nonSimpleParameters)) {
|
|
86863
86889
|
forEach(nonSimpleParameters, (parameter) => {
|
|
86864
86890
|
addRelatedInfo(
|
|
86865
|
-
|
|
86891
|
+
error2(parameter, Diagnostics.This_parameter_is_not_allowed_with_use_strict_directive),
|
|
86866
86892
|
createDiagnosticForNode(useStrictDirective, Diagnostics.use_strict_directive_used_here)
|
|
86867
86893
|
);
|
|
86868
86894
|
});
|
|
86869
86895
|
const diagnostics2 = nonSimpleParameters.map((parameter, index) => index === 0 ? createDiagnosticForNode(parameter, Diagnostics.Non_simple_parameter_declared_here) : createDiagnosticForNode(parameter, Diagnostics.and_here));
|
|
86870
|
-
addRelatedInfo(
|
|
86896
|
+
addRelatedInfo(error2(useStrictDirective, Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list), ...diagnostics2);
|
|
86871
86897
|
return true;
|
|
86872
86898
|
}
|
|
86873
86899
|
}
|
|
@@ -89635,13 +89661,13 @@ function decodeMappings(mappings) {
|
|
|
89635
89661
|
let sourceLine = 0;
|
|
89636
89662
|
let sourceCharacter = 0;
|
|
89637
89663
|
let nameIndex = 0;
|
|
89638
|
-
let
|
|
89664
|
+
let error2;
|
|
89639
89665
|
return {
|
|
89640
89666
|
get pos() {
|
|
89641
89667
|
return pos;
|
|
89642
89668
|
},
|
|
89643
89669
|
get error() {
|
|
89644
|
-
return
|
|
89670
|
+
return error2;
|
|
89645
89671
|
},
|
|
89646
89672
|
get state() {
|
|
89647
89673
|
return captureMapping(
|
|
@@ -89726,8 +89752,8 @@ function decodeMappings(mappings) {
|
|
|
89726
89752
|
return { value: void 0, done: true };
|
|
89727
89753
|
}
|
|
89728
89754
|
function setError(message) {
|
|
89729
|
-
if (
|
|
89730
|
-
|
|
89755
|
+
if (error2 === void 0) {
|
|
89756
|
+
error2 = message;
|
|
89731
89757
|
}
|
|
89732
89758
|
}
|
|
89733
89759
|
function setErrorAndStopIterating(message) {
|
|
@@ -89735,7 +89761,7 @@ function decodeMappings(mappings) {
|
|
|
89735
89761
|
return stopIterating();
|
|
89736
89762
|
}
|
|
89737
89763
|
function hasReportedError() {
|
|
89738
|
-
return
|
|
89764
|
+
return error2 !== void 0;
|
|
89739
89765
|
}
|
|
89740
89766
|
function isSourceMappingSegmentEnd() {
|
|
89741
89767
|
return pos === mappings.length || mappings.charCodeAt(pos) === 44 /* comma */ || mappings.charCodeAt(pos) === 59 /* semicolon */;
|
|
@@ -119364,13 +119390,13 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
119364
119390
|
sourceFileOptions,
|
|
119365
119391
|
/*onError*/
|
|
119366
119392
|
void 0,
|
|
119367
|
-
shouldCreateNewSourceFile
|
|
119393
|
+
shouldCreateNewSourceFile
|
|
119368
119394
|
) : host.getSourceFile(
|
|
119369
119395
|
oldSourceFile.fileName,
|
|
119370
119396
|
sourceFileOptions,
|
|
119371
119397
|
/*onError*/
|
|
119372
119398
|
void 0,
|
|
119373
|
-
shouldCreateNewSourceFile
|
|
119399
|
+
shouldCreateNewSourceFile
|
|
119374
119400
|
);
|
|
119375
119401
|
if (!newSourceFile) {
|
|
119376
119402
|
return 0 /* Not */;
|
|
@@ -120326,7 +120352,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
120326
120352
|
return typeof result === "object" ? { ...result, languageVersion, setExternalModuleIndicator: setExternalModuleIndicator2 } : { languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator2 };
|
|
120327
120353
|
}
|
|
120328
120354
|
function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
|
|
120329
|
-
var _a2
|
|
120355
|
+
var _a2;
|
|
120330
120356
|
const path = toPath3(fileName);
|
|
120331
120357
|
if (useSourceOfProjectReferenceRedirect) {
|
|
120332
120358
|
let source = getSourceOfProjectReferenceRedirect(path);
|
|
@@ -120405,7 +120431,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
120405
120431
|
Diagnostics.Cannot_read_file_0_Colon_1,
|
|
120406
120432
|
[fileName, hostErrorMessage]
|
|
120407
120433
|
),
|
|
120408
|
-
shouldCreateNewSourceFile
|
|
120434
|
+
shouldCreateNewSourceFile
|
|
120409
120435
|
);
|
|
120410
120436
|
if (packageId) {
|
|
120411
120437
|
const packageIdKey = packageIdToString(packageId);
|
|
@@ -120430,7 +120456,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
120430
120456
|
file.path = path;
|
|
120431
120457
|
file.resolvedPath = toPath3(fileName);
|
|
120432
120458
|
file.originalFileName = originalFileName;
|
|
120433
|
-
file.packageJsonLocations = ((
|
|
120459
|
+
file.packageJsonLocations = ((_a2 = sourceFileOptions.packageJsonLocations) == null ? void 0 : _a2.length) ? sourceFileOptions.packageJsonLocations : void 0;
|
|
120434
120460
|
file.packageJsonScope = sourceFileOptions.packageJsonScope;
|
|
120435
120461
|
addFileIncludeReason(file, reason);
|
|
120436
120462
|
if (host.useCaseSensitiveFileNames()) {
|
|
@@ -124685,17 +124711,17 @@ function getFilesInErrorForSummary(diagnostics) {
|
|
|
124685
124711
|
function getWatchErrorSummaryDiagnosticMessage(errorCount) {
|
|
124686
124712
|
return errorCount === 1 ? Diagnostics.Found_1_error_Watching_for_file_changes : Diagnostics.Found_0_errors_Watching_for_file_changes;
|
|
124687
124713
|
}
|
|
124688
|
-
function prettyPathForFileError(
|
|
124689
|
-
const line = formatColorAndReset(":" +
|
|
124690
|
-
if (pathIsAbsolute(
|
|
124714
|
+
function prettyPathForFileError(error2, cwd) {
|
|
124715
|
+
const line = formatColorAndReset(":" + error2.line, "\x1B[90m" /* Grey */);
|
|
124716
|
+
if (pathIsAbsolute(error2.fileName) && pathIsAbsolute(cwd)) {
|
|
124691
124717
|
return getRelativePathFromDirectory(
|
|
124692
124718
|
cwd,
|
|
124693
|
-
|
|
124719
|
+
error2.fileName,
|
|
124694
124720
|
/*ignoreCase*/
|
|
124695
124721
|
false
|
|
124696
124722
|
) + line;
|
|
124697
124723
|
}
|
|
124698
|
-
return
|
|
124724
|
+
return error2.fileName + line;
|
|
124699
124725
|
}
|
|
124700
124726
|
function getErrorSummaryText(errorCount, filesInError, newLine, host) {
|
|
124701
124727
|
if (errorCount === 0)
|
|
@@ -125560,7 +125586,8 @@ function createWatchProgram(host) {
|
|
|
125560
125586
|
if (isFileMissingOnHost(hostSourceFile)) {
|
|
125561
125587
|
return void 0;
|
|
125562
125588
|
}
|
|
125563
|
-
|
|
125589
|
+
const impliedNodeFormat = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions.impliedNodeFormat : void 0;
|
|
125590
|
+
if (hostSourceFile === void 0 || shouldCreateNewSourceFile || isFilePresenceUnknownOnHost(hostSourceFile) || hostSourceFile.sourceFile.impliedNodeFormat !== impliedNodeFormat) {
|
|
125564
125591
|
const sourceFile = getNewSourceFile(fileName, languageVersionOrOptions, onError);
|
|
125565
125592
|
if (hostSourceFile) {
|
|
125566
125593
|
if (sourceFile) {
|
|
@@ -133344,13 +133371,6 @@ function createDocumentRegistryInternal(useCaseSensitiveFileNames, currentDirect
|
|
|
133344
133371
|
}
|
|
133345
133372
|
}
|
|
133346
133373
|
}
|
|
133347
|
-
function getLanguageServiceRefCounts(path, scriptKind) {
|
|
133348
|
-
return arrayFrom(buckets.entries(), ([key, bucket]) => {
|
|
133349
|
-
const bucketEntry = bucket.get(path);
|
|
133350
|
-
const entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind);
|
|
133351
|
-
return [key, entry && entry.languageServiceRefCount];
|
|
133352
|
-
});
|
|
133353
|
-
}
|
|
133354
133374
|
return {
|
|
133355
133375
|
acquireDocument,
|
|
133356
133376
|
acquireDocumentWithKey,
|
|
@@ -133358,9 +133378,10 @@ function createDocumentRegistryInternal(useCaseSensitiveFileNames, currentDirect
|
|
|
133358
133378
|
updateDocumentWithKey,
|
|
133359
133379
|
releaseDocument,
|
|
133360
133380
|
releaseDocumentWithKey,
|
|
133361
|
-
|
|
133381
|
+
getKeyForCompilationSettings,
|
|
133382
|
+
getDocumentRegistryBucketKeyWithMode,
|
|
133362
133383
|
reportStats,
|
|
133363
|
-
|
|
133384
|
+
getBuckets: () => buckets
|
|
133364
133385
|
};
|
|
133365
133386
|
}
|
|
133366
133387
|
function getKeyForCompilationSettings(settings) {
|
|
@@ -136554,15 +136575,22 @@ registerRefactor(refactorNameForMoveToFile, {
|
|
|
136554
136575
|
getEditsForAction: function getRefactorEditsToMoveToFile(context, actionName2, interactiveRefactorArguments) {
|
|
136555
136576
|
Debug.assert(actionName2 === refactorNameForMoveToFile, "Wrong refactor invoked");
|
|
136556
136577
|
const statements = Debug.checkDefined(getStatementsToMove(context));
|
|
136578
|
+
const { host, program } = context;
|
|
136557
136579
|
Debug.assert(interactiveRefactorArguments, "No interactive refactor arguments available");
|
|
136558
136580
|
const targetFile = interactiveRefactorArguments.targetFile;
|
|
136559
136581
|
if (hasJSFileExtension(targetFile) || hasTSFileExtension(targetFile)) {
|
|
136560
|
-
|
|
136582
|
+
if (host.fileExists(targetFile) && program.getSourceFile(targetFile) === void 0) {
|
|
136583
|
+
return error(getLocaleSpecificMessage(Diagnostics.Cannot_move_statements_to_the_selected_file));
|
|
136584
|
+
}
|
|
136585
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange4(context, context.file, interactiveRefactorArguments.targetFile, program, statements, t, context.host, context.preferences));
|
|
136561
136586
|
return { edits, renameFilename: void 0, renameLocation: void 0 };
|
|
136562
136587
|
}
|
|
136563
|
-
return
|
|
136588
|
+
return error(getLocaleSpecificMessage(Diagnostics.Cannot_move_to_file_selected_file_is_invalid));
|
|
136564
136589
|
}
|
|
136565
136590
|
});
|
|
136591
|
+
function error(notApplicableReason) {
|
|
136592
|
+
return { edits: [], renameFilename: void 0, renameLocation: void 0, notApplicableReason };
|
|
136593
|
+
}
|
|
136566
136594
|
function doChange4(context, oldFile, targetFile, program, toMove, changes, host, preferences) {
|
|
136567
136595
|
const checker = program.getTypeChecker();
|
|
136568
136596
|
const usage = getUsageInfo(oldFile, toMove.all, checker);
|
|
@@ -137791,25 +137819,25 @@ function getRefactorActionsToConvertFunctionExpressions(context) {
|
|
|
137791
137819
|
const possibleActions = [];
|
|
137792
137820
|
const errors = [];
|
|
137793
137821
|
if (refactorKindBeginsWith(toNamedFunctionAction.kind, kind)) {
|
|
137794
|
-
const
|
|
137795
|
-
if (
|
|
137796
|
-
errors.push({ ...toNamedFunctionAction, notApplicableReason:
|
|
137822
|
+
const error2 = selectedVariableDeclaration || isArrowFunction(func) && isVariableDeclaration(func.parent) ? void 0 : getLocaleSpecificMessage(Diagnostics.Could_not_convert_to_named_function);
|
|
137823
|
+
if (error2) {
|
|
137824
|
+
errors.push({ ...toNamedFunctionAction, notApplicableReason: error2 });
|
|
137797
137825
|
} else {
|
|
137798
137826
|
possibleActions.push(toNamedFunctionAction);
|
|
137799
137827
|
}
|
|
137800
137828
|
}
|
|
137801
137829
|
if (refactorKindBeginsWith(toAnonymousFunctionAction.kind, kind)) {
|
|
137802
|
-
const
|
|
137803
|
-
if (
|
|
137804
|
-
errors.push({ ...toAnonymousFunctionAction, notApplicableReason:
|
|
137830
|
+
const error2 = !selectedVariableDeclaration && isArrowFunction(func) ? void 0 : getLocaleSpecificMessage(Diagnostics.Could_not_convert_to_anonymous_function);
|
|
137831
|
+
if (error2) {
|
|
137832
|
+
errors.push({ ...toAnonymousFunctionAction, notApplicableReason: error2 });
|
|
137805
137833
|
} else {
|
|
137806
137834
|
possibleActions.push(toAnonymousFunctionAction);
|
|
137807
137835
|
}
|
|
137808
137836
|
}
|
|
137809
137837
|
if (refactorKindBeginsWith(toArrowFunctionAction.kind, kind)) {
|
|
137810
|
-
const
|
|
137811
|
-
if (
|
|
137812
|
-
errors.push({ ...toArrowFunctionAction, notApplicableReason:
|
|
137838
|
+
const error2 = isFunctionExpression(func) ? void 0 : getLocaleSpecificMessage(Diagnostics.Could_not_convert_to_arrow_function);
|
|
137839
|
+
if (error2) {
|
|
137840
|
+
errors.push({ ...toArrowFunctionAction, notApplicableReason: error2 });
|
|
137813
137841
|
} else {
|
|
137814
137842
|
possibleActions.push(toArrowFunctionAction);
|
|
137815
137843
|
}
|
|
@@ -139096,11 +139124,11 @@ function getRefactorActionsToExtractSymbol(context) {
|
|
|
139096
139124
|
}
|
|
139097
139125
|
return infos.length ? infos : emptyArray;
|
|
139098
139126
|
function getStringError(errors) {
|
|
139099
|
-
let
|
|
139100
|
-
if (typeof
|
|
139101
|
-
|
|
139127
|
+
let error2 = errors[0].messageText;
|
|
139128
|
+
if (typeof error2 !== "string") {
|
|
139129
|
+
error2 = error2.messageText;
|
|
139102
139130
|
}
|
|
139103
|
-
return
|
|
139131
|
+
return error2;
|
|
139104
139132
|
}
|
|
139105
139133
|
}
|
|
139106
139134
|
function getRefactorEditsToExtractSymbol(context, actionName2) {
|
|
@@ -141876,9 +141904,9 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
141876
141904
|
function getValidSourceFile(fileName) {
|
|
141877
141905
|
const sourceFile = program.getSourceFile(fileName);
|
|
141878
141906
|
if (!sourceFile) {
|
|
141879
|
-
const
|
|
141880
|
-
|
|
141881
|
-
throw
|
|
141907
|
+
const error2 = new Error(`Could not find source file: '${fileName}'.`);
|
|
141908
|
+
error2.ProgramFiles = program.getSourceFiles().map((f) => f.fileName);
|
|
141909
|
+
throw error2;
|
|
141882
141910
|
}
|
|
141883
141911
|
return sourceFile;
|
|
141884
141912
|
}
|
|
@@ -142111,14 +142139,14 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
142111
142139
|
}
|
|
142112
142140
|
}
|
|
142113
142141
|
function cleanupSemanticCache() {
|
|
142114
|
-
program = void 0;
|
|
142115
|
-
}
|
|
142116
|
-
function dispose() {
|
|
142117
142142
|
if (program) {
|
|
142118
142143
|
const key = documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions());
|
|
142119
142144
|
forEach(program.getSourceFiles(), (f) => documentRegistry.releaseDocumentWithKey(f.resolvedPath, key, f.scriptKind, f.impliedNodeFormat));
|
|
142120
142145
|
program = void 0;
|
|
142121
142146
|
}
|
|
142147
|
+
}
|
|
142148
|
+
function dispose() {
|
|
142149
|
+
cleanupSemanticCache();
|
|
142122
142150
|
host = void 0;
|
|
142123
142151
|
}
|
|
142124
142152
|
function getSyntacticDiagnostics(fileName) {
|
|
@@ -145094,9 +145122,9 @@ function createCodeFixActionWorker(fixName8, description3, changes, fixId52, fix
|
|
|
145094
145122
|
return { fixName: fixName8, description: description3, changes, fixId: fixId52, fixAllDescription, commands: command ? [command] : void 0 };
|
|
145095
145123
|
}
|
|
145096
145124
|
function registerCodeFix(reg) {
|
|
145097
|
-
for (const
|
|
145125
|
+
for (const error2 of reg.errorCodes) {
|
|
145098
145126
|
errorCodeToFixesArray = void 0;
|
|
145099
|
-
errorCodeToFixes.add(String(
|
|
145127
|
+
errorCodeToFixes.add(String(error2), reg);
|
|
145100
145128
|
}
|
|
145101
145129
|
if (reg.fixIds) {
|
|
145102
145130
|
for (const fixId52 of reg.fixIds) {
|
|
@@ -154770,8 +154798,8 @@ registerCodeFix({
|
|
|
154770
154798
|
return [createCodeFixAction(fixId48, changes, Diagnostics.Split_into_two_separate_import_declarations, fixId48, Diagnostics.Split_all_invalid_type_only_imports)];
|
|
154771
154799
|
}
|
|
154772
154800
|
},
|
|
154773
|
-
getAllCodeActions: (context) => codeFixAll(context, errorCodes60, (changes,
|
|
154774
|
-
splitTypeOnlyImport(changes, getImportDeclaration2(context.sourceFile,
|
|
154801
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes60, (changes, error2) => {
|
|
154802
|
+
splitTypeOnlyImport(changes, getImportDeclaration2(context.sourceFile, error2), context);
|
|
154775
154803
|
})
|
|
154776
154804
|
});
|
|
154777
154805
|
function getImportDeclaration2(sourceFile, span) {
|
|
@@ -162741,13 +162769,29 @@ function provideInlayHints(context) {
|
|
|
162741
162769
|
if (!signature || !candidates.length) {
|
|
162742
162770
|
return;
|
|
162743
162771
|
}
|
|
162744
|
-
|
|
162745
|
-
|
|
162772
|
+
let signatureParamPos = 0;
|
|
162773
|
+
for (const originalArg of args) {
|
|
162746
162774
|
const arg = skipParentheses(originalArg);
|
|
162747
162775
|
if (shouldShowLiteralParameterNameHintsOnly(preferences) && !isHintableLiteral(arg)) {
|
|
162748
162776
|
continue;
|
|
162749
162777
|
}
|
|
162750
|
-
|
|
162778
|
+
let spreadArgs = 0;
|
|
162779
|
+
if (isSpreadElement(arg)) {
|
|
162780
|
+
const spreadType = checker.getTypeAtLocation(arg.expression);
|
|
162781
|
+
if (checker.isTupleType(spreadType)) {
|
|
162782
|
+
const { elementFlags, fixedLength } = spreadType.target;
|
|
162783
|
+
if (fixedLength === 0) {
|
|
162784
|
+
continue;
|
|
162785
|
+
}
|
|
162786
|
+
const firstOptionalIndex = findIndex(elementFlags, (f) => !(f & 1 /* Required */));
|
|
162787
|
+
const requiredArgs = firstOptionalIndex < 0 ? fixedLength : firstOptionalIndex;
|
|
162788
|
+
if (requiredArgs > 0) {
|
|
162789
|
+
spreadArgs = firstOptionalIndex < 0 ? fixedLength : firstOptionalIndex;
|
|
162790
|
+
}
|
|
162791
|
+
}
|
|
162792
|
+
}
|
|
162793
|
+
const identifierNameInfo = checker.getParameterIdentifierNameAtPosition(signature, signatureParamPos);
|
|
162794
|
+
signatureParamPos = signatureParamPos + (spreadArgs || 1);
|
|
162751
162795
|
if (identifierNameInfo) {
|
|
162752
162796
|
const [parameterName, isFirstVariadicArgument] = identifierNameInfo;
|
|
162753
162797
|
const isParameterNameNotSameAsArgument = preferences.includeInlayParameterNameHintsWhenArgumentMatchesName || !identifierOrAccessExpressionPostfixMatchesParameterName(arg, parameterName);
|
|
@@ -163371,7 +163415,7 @@ function organizeImports(sourceFile, formatContext, host, program, preferences,
|
|
|
163371
163415
|
if (length(oldImportDecls) === 0) {
|
|
163372
163416
|
return;
|
|
163373
163417
|
}
|
|
163374
|
-
|
|
163418
|
+
setEmitFlags(oldImportDecls[0], 1024 /* NoLeadingComments */);
|
|
163375
163419
|
const oldImportGroups = shouldCombine ? group(oldImportDecls, (importDecl) => getExternalModuleName2(importDecl.moduleSpecifier)) : [oldImportDecls];
|
|
163376
163420
|
const sortedImportGroups = shouldSort ? stableSort(oldImportGroups, (group1, group2) => compareModuleSpecifiersWorker(group1[0].moduleSpecifier, group2[0].moduleSpecifier, comparer)) : oldImportGroups;
|
|
163377
163421
|
const newImportDecls = flatMap(sortedImportGroups, (importGroup) => getExternalModuleName2(importGroup[0].moduleSpecifier) || importGroup[0].moduleSpecifier === void 0 ? coalesce(importGroup) : importGroup);
|
|
@@ -168466,11 +168510,11 @@ function prepareRangeContainsErrorFunction(errors, originalRange) {
|
|
|
168466
168510
|
if (index >= sorted.length) {
|
|
168467
168511
|
return false;
|
|
168468
168512
|
}
|
|
168469
|
-
const
|
|
168470
|
-
if (r.end <=
|
|
168513
|
+
const error2 = sorted[index];
|
|
168514
|
+
if (r.end <= error2.start) {
|
|
168471
168515
|
return false;
|
|
168472
168516
|
}
|
|
168473
|
-
if (startEndOverlapsWithStartEnd(r.pos, r.end,
|
|
168517
|
+
if (startEndOverlapsWithStartEnd(r.pos, r.end, error2.start, error2.start + error2.length)) {
|
|
168474
168518
|
return true;
|
|
168475
168519
|
}
|
|
168476
168520
|
index++;
|
|
@@ -171147,6 +171191,7 @@ __export(ts_exports2, {
|
|
|
171147
171191
|
isDiagnosticWithLocation: () => isDiagnosticWithLocation,
|
|
171148
171192
|
isDiskPathRoot: () => isDiskPathRoot,
|
|
171149
171193
|
isDoStatement: () => isDoStatement,
|
|
171194
|
+
isDocumentRegistryEntry: () => isDocumentRegistryEntry,
|
|
171150
171195
|
isDotDotDotToken: () => isDotDotDotToken,
|
|
171151
171196
|
isDottedName: () => isDottedName,
|
|
171152
171197
|
isDynamicName: () => isDynamicName,
|
|
@@ -172169,11 +172214,11 @@ var typeScriptVersion2;
|
|
|
172169
172214
|
function getTypeScriptVersion() {
|
|
172170
172215
|
return typeScriptVersion2 ?? (typeScriptVersion2 = new Version(version));
|
|
172171
172216
|
}
|
|
172172
|
-
function formatDeprecationMessage(name,
|
|
172173
|
-
let deprecationMessage =
|
|
172217
|
+
function formatDeprecationMessage(name, error2, errorAfter, since, message) {
|
|
172218
|
+
let deprecationMessage = error2 ? "DeprecationError: " : "DeprecationWarning: ";
|
|
172174
172219
|
deprecationMessage += `'${name}' `;
|
|
172175
172220
|
deprecationMessage += since ? `has been deprecated since v${since}` : "is deprecated";
|
|
172176
|
-
deprecationMessage +=
|
|
172221
|
+
deprecationMessage += error2 ? " and can no longer be used." : errorAfter ? ` and will no longer be usable after v${errorAfter}.` : ".";
|
|
172177
172222
|
deprecationMessage += message ? ` ${formatStringFromArgs(message, [name], 0)}` : "";
|
|
172178
172223
|
return deprecationMessage;
|
|
172179
172224
|
}
|
|
@@ -172211,9 +172256,9 @@ function createDeprecation(name, options = {}) {
|
|
|
172211
172256
|
const errorAfter = typeof options.errorAfter === "string" ? new Version(options.errorAfter) : options.errorAfter;
|
|
172212
172257
|
const warnAfter = typeof options.warnAfter === "string" ? new Version(options.warnAfter) : options.warnAfter;
|
|
172213
172258
|
const since = typeof options.since === "string" ? new Version(options.since) : options.since ?? warnAfter;
|
|
172214
|
-
const
|
|
172259
|
+
const error2 = options.error || errorAfter && version2.compareTo(errorAfter) >= 0;
|
|
172215
172260
|
const warn = !warnAfter || version2.compareTo(warnAfter) >= 0;
|
|
172216
|
-
return
|
|
172261
|
+
return error2 ? createErrorDeprecation(name, errorAfter, since, options.message) : warn ? createWarningDeprecation(name, errorAfter, since, options.message) : noop;
|
|
172217
172262
|
}
|
|
172218
172263
|
function wrapFunction(deprecation, func) {
|
|
172219
172264
|
return function() {
|
|
@@ -172311,6 +172356,7 @@ __export(ts_server_exports3, {
|
|
|
172311
172356
|
ActionWatchTypingLocations: () => ActionWatchTypingLocations,
|
|
172312
172357
|
Arguments: () => Arguments,
|
|
172313
172358
|
AutoImportProviderProject: () => AutoImportProviderProject,
|
|
172359
|
+
AuxiliaryProject: () => AuxiliaryProject,
|
|
172314
172360
|
CharRangeSection: () => CharRangeSection,
|
|
172315
172361
|
CommandNames: () => CommandNames,
|
|
172316
172362
|
ConfigFileDiagEvent: () => ConfigFileDiagEvent,
|
|
@@ -174344,6 +174390,16 @@ var Project3 = class {
|
|
|
174344
174390
|
true
|
|
174345
174391
|
);
|
|
174346
174392
|
}
|
|
174393
|
+
/** @internal */
|
|
174394
|
+
cleanupProgram() {
|
|
174395
|
+
if (this.program) {
|
|
174396
|
+
for (const f of this.program.getSourceFiles()) {
|
|
174397
|
+
this.detachScriptInfoIfNotRoot(f.fileName);
|
|
174398
|
+
}
|
|
174399
|
+
this.program.forEachResolvedProjectReference((ref) => this.detachScriptInfoFromProject(ref.sourceFile.fileName));
|
|
174400
|
+
this.program = void 0;
|
|
174401
|
+
}
|
|
174402
|
+
}
|
|
174347
174403
|
disableLanguageService(lastFileExceededProgramSize) {
|
|
174348
174404
|
if (!this.languageServiceEnabled) {
|
|
174349
174405
|
return;
|
|
@@ -174351,6 +174407,7 @@ var Project3 = class {
|
|
|
174351
174407
|
Debug.assert(this.projectService.serverMode !== 2 /* Syntactic */);
|
|
174352
174408
|
this.languageService.cleanupSemanticCache();
|
|
174353
174409
|
this.languageServiceEnabled = false;
|
|
174410
|
+
this.cleanupProgram();
|
|
174354
174411
|
this.lastFileExceededProgramSize = lastFileExceededProgramSize;
|
|
174355
174412
|
this.builderState = void 0;
|
|
174356
174413
|
if (this.autoImportProviderHost) {
|
|
@@ -174359,6 +174416,7 @@ var Project3 = class {
|
|
|
174359
174416
|
this.autoImportProviderHost = void 0;
|
|
174360
174417
|
this.resolutionCache.closeTypeRootsWatch();
|
|
174361
174418
|
this.clearGeneratedFileWatch();
|
|
174419
|
+
this.projectService.verifyDocumentRegistry();
|
|
174362
174420
|
this.projectService.onUpdateLanguageServiceStateForProject(
|
|
174363
174421
|
this,
|
|
174364
174422
|
/*languageServiceEnabled*/
|
|
@@ -174402,12 +174460,7 @@ var Project3 = class {
|
|
|
174402
174460
|
close() {
|
|
174403
174461
|
this.projectService.typingsCache.onProjectClosed(this);
|
|
174404
174462
|
this.closeWatchingTypingLocations();
|
|
174405
|
-
|
|
174406
|
-
for (const f of this.program.getSourceFiles()) {
|
|
174407
|
-
this.detachScriptInfoIfNotRoot(f.fileName);
|
|
174408
|
-
}
|
|
174409
|
-
this.program.forEachResolvedProjectReference((ref) => this.detachScriptInfoFromProject(ref.sourceFile.fileName));
|
|
174410
|
-
}
|
|
174463
|
+
this.cleanupProgram();
|
|
174411
174464
|
forEach(this.externalFiles, (externalFile) => this.detachScriptInfoIfNotRoot(externalFile));
|
|
174412
174465
|
for (const root of this.rootFiles) {
|
|
174413
174466
|
root.detachFromProject(this);
|
|
@@ -174785,6 +174838,7 @@ var Project3 = class {
|
|
|
174785
174838
|
updateGraphWorker() {
|
|
174786
174839
|
var _a, _b;
|
|
174787
174840
|
const oldProgram = this.languageService.getCurrentProgram();
|
|
174841
|
+
Debug.assert(oldProgram === this.program);
|
|
174788
174842
|
Debug.assert(!this.isClosed(), "Called update graph worker of closed project");
|
|
174789
174843
|
this.writeLog(`Starting updateGraphWorker: Project: ${this.getProjectName()}`);
|
|
174790
174844
|
const start2 = timestamp();
|
|
@@ -174915,6 +174969,7 @@ var Project3 = class {
|
|
|
174915
174969
|
} else if (this.program !== oldProgram) {
|
|
174916
174970
|
this.writeLog(`Different program with same set of files`);
|
|
174917
174971
|
}
|
|
174972
|
+
this.projectService.verifyDocumentRegistry();
|
|
174918
174973
|
return hasNewProgram;
|
|
174919
174974
|
}
|
|
174920
174975
|
/** @internal */
|
|
@@ -175559,7 +175614,6 @@ var AuxiliaryProject = class extends Project3 {
|
|
|
175559
175614
|
isOrphan() {
|
|
175560
175615
|
return true;
|
|
175561
175616
|
}
|
|
175562
|
-
/** @internal */
|
|
175563
175617
|
scheduleInvalidateResolutionsOfFailedLookupLocations() {
|
|
175564
175618
|
return;
|
|
175565
175619
|
}
|
|
@@ -176439,6 +176493,9 @@ var _ProjectService = class {
|
|
|
176439
176493
|
this.sharedExtendedConfigFileWatchers = /* @__PURE__ */ new Map();
|
|
176440
176494
|
/** @internal */
|
|
176441
176495
|
this.extendedConfigCache = /* @__PURE__ */ new Map();
|
|
176496
|
+
/** @internal */
|
|
176497
|
+
this.verifyDocumentRegistry = noop;
|
|
176498
|
+
var _a;
|
|
176442
176499
|
this.host = opts.host;
|
|
176443
176500
|
this.logger = opts.logger;
|
|
176444
176501
|
this.cancellationToken = opts.cancellationToken;
|
|
@@ -176486,6 +176543,7 @@ var _ProjectService = class {
|
|
|
176486
176543
|
watchFile: returnNoopFileWatcher,
|
|
176487
176544
|
watchDirectory: returnNoopFileWatcher
|
|
176488
176545
|
} : getWatchFactory(this.host, watchLogLevel, log, getDetailWatchInfo);
|
|
176546
|
+
(_a = opts.incrementalVerifier) == null ? void 0 : _a.call(opts, this);
|
|
176489
176547
|
}
|
|
176490
176548
|
toPath(fileName) {
|
|
176491
176549
|
return toPath(fileName, this.currentDirectory, this.toCanonicalFileName);
|
|
@@ -177814,6 +177872,7 @@ var _ProjectService = class {
|
|
|
177814
177872
|
/*ensureSynchronized*/
|
|
177815
177873
|
false
|
|
177816
177874
|
).cleanupSemanticCache();
|
|
177875
|
+
project.cleanupProgram();
|
|
177817
177876
|
project.markAsDirty();
|
|
177818
177877
|
}
|
|
177819
177878
|
sendConfigFileDiagEvent(project, triggerFile) {
|
|
@@ -180683,7 +180742,8 @@ var Session3 = class {
|
|
|
180683
180742
|
allowLocalPluginLoads: opts.allowLocalPluginLoads,
|
|
180684
180743
|
typesMapLocation: opts.typesMapLocation,
|
|
180685
180744
|
serverMode: opts.serverMode,
|
|
180686
|
-
session: this
|
|
180745
|
+
session: this,
|
|
180746
|
+
incrementalVerifier: opts.incrementalVerifier
|
|
180687
180747
|
};
|
|
180688
180748
|
this.projectService = new ProjectService3(settings);
|
|
180689
180749
|
this.projectService.setPerformanceEventHandler(this.performanceEventHandler.bind(this));
|
|
@@ -181003,6 +181063,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
|
181003
181063
|
/*ensureSynchronized*/
|
|
181004
181064
|
false
|
|
181005
181065
|
).cleanupSemanticCache();
|
|
181066
|
+
p.cleanupProgram();
|
|
181006
181067
|
}
|
|
181007
181068
|
}
|
|
181008
181069
|
cleanup() {
|
|
@@ -183541,6 +183602,7 @@ __export(ts_server_exports4, {
|
|
|
183541
183602
|
ActionWatchTypingLocations: () => ActionWatchTypingLocations,
|
|
183542
183603
|
Arguments: () => Arguments,
|
|
183543
183604
|
AutoImportProviderProject: () => AutoImportProviderProject,
|
|
183605
|
+
AuxiliaryProject: () => AuxiliaryProject,
|
|
183544
183606
|
CharRangeSection: () => CharRangeSection,
|
|
183545
183607
|
CommandNames: () => CommandNames,
|
|
183546
183608
|
ConfigFileDiagEvent: () => ConfigFileDiagEvent,
|
|
@@ -185620,6 +185682,7 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
185620
185682
|
isDiagnosticWithLocation,
|
|
185621
185683
|
isDiskPathRoot,
|
|
185622
185684
|
isDoStatement,
|
|
185685
|
+
isDocumentRegistryEntry,
|
|
185623
185686
|
isDotDotDotToken,
|
|
185624
185687
|
isDottedName,
|
|
185625
185688
|
isDynamicName,
|