typescript 4.6.0-dev.20220116 → 4.6.0-dev.20220120
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/lib.dom.d.ts +144 -58
- package/lib/lib.dom.iterable.d.ts +7 -0
- package/lib/lib.es2015.iterable.d.ts +2 -1
- package/lib/lib.es2020.intl.d.ts +4 -0
- package/lib/lib.es5.d.ts +0 -2
- package/lib/lib.webworker.d.ts +80 -17
- package/lib/lib.webworker.iterable.d.ts +7 -0
- package/lib/protocol.d.ts +1 -0
- package/lib/tsc.js +94 -41
- package/lib/tsserver.js +200 -115
- package/lib/tsserverlibrary.d.ts +2 -0
- package/lib/tsserverlibrary.js +200 -115
- package/lib/typescript.d.ts +1 -0
- package/lib/typescript.js +186 -113
- package/lib/typescriptServices.d.ts +1 -0
- package/lib/typescriptServices.js +186 -113
- package/lib/typingsInstaller.js +103 -42
- package/package.json +1 -1
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220120";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -7004,11 +7004,15 @@ var ts;
|
|
|
7004
7004
|
ts.getFileWatcherEventKind = getFileWatcherEventKind;
|
|
7005
7005
|
/*@internal*/
|
|
7006
7006
|
ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"];
|
|
7007
|
+
var curSysLog = ts.noop; // eslint-disable-line prefer-const
|
|
7007
7008
|
/*@internal*/
|
|
7008
|
-
|
|
7009
|
+
function sysLog(s) {
|
|
7010
|
+
return curSysLog(s);
|
|
7011
|
+
}
|
|
7012
|
+
ts.sysLog = sysLog;
|
|
7009
7013
|
/*@internal*/
|
|
7010
7014
|
function setSysLog(logger) {
|
|
7011
|
-
|
|
7015
|
+
curSysLog = logger;
|
|
7012
7016
|
}
|
|
7013
7017
|
ts.setSysLog = setSysLog;
|
|
7014
7018
|
/**
|
|
@@ -7143,7 +7147,7 @@ var ts;
|
|
|
7143
7147
|
}
|
|
7144
7148
|
function onTimerToUpdateChildWatches() {
|
|
7145
7149
|
timerToUpdateChildWatches = undefined;
|
|
7146
|
-
|
|
7150
|
+
sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size);
|
|
7147
7151
|
var start = ts.timestamp();
|
|
7148
7152
|
var invokeMap = new ts.Map();
|
|
7149
7153
|
while (!timerToUpdateChildWatches && cacheToUpdateChildWatches.size) {
|
|
@@ -7156,7 +7160,7 @@ var ts;
|
|
|
7156
7160
|
var hasChanges = updateChildWatches(dirName, dirPath, options);
|
|
7157
7161
|
invokeCallbacks(dirPath, invokeMap, hasChanges ? undefined : fileNames);
|
|
7158
7162
|
}
|
|
7159
|
-
|
|
7163
|
+
sysLog("sysLog:: invokingWatchers:: Elapsed:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size);
|
|
7160
7164
|
callbackCache.forEach(function (callbacks, rootDirName) {
|
|
7161
7165
|
var existing = invokeMap.get(rootDirName);
|
|
7162
7166
|
if (existing) {
|
|
@@ -7172,7 +7176,7 @@ var ts;
|
|
|
7172
7176
|
}
|
|
7173
7177
|
});
|
|
7174
7178
|
var elapsed = ts.timestamp() - start;
|
|
7175
|
-
|
|
7179
|
+
sysLog("sysLog:: Elapsed:: " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches);
|
|
7176
7180
|
}
|
|
7177
7181
|
function removeChildWatches(parentWatcher) {
|
|
7178
7182
|
if (!parentWatcher)
|
|
@@ -7759,7 +7763,7 @@ var ts;
|
|
|
7759
7763
|
* @param createWatcher
|
|
7760
7764
|
*/
|
|
7761
7765
|
function invokeCallbackAndUpdateWatcher(createWatcher) {
|
|
7762
|
-
|
|
7766
|
+
sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
|
|
7763
7767
|
// Call the callback for current directory
|
|
7764
7768
|
callback("rename", "");
|
|
7765
7769
|
// If watcher is not closed, update it
|
|
@@ -7784,7 +7788,7 @@ var ts;
|
|
|
7784
7788
|
}
|
|
7785
7789
|
}
|
|
7786
7790
|
if (hitSystemWatcherLimit) {
|
|
7787
|
-
|
|
7791
|
+
sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile");
|
|
7788
7792
|
return watchPresentFileSystemEntryWithFsWatchFile();
|
|
7789
7793
|
}
|
|
7790
7794
|
try {
|
|
@@ -7800,7 +7804,7 @@ var ts;
|
|
|
7800
7804
|
// Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
|
|
7801
7805
|
// so instead of throwing error, use fs.watchFile
|
|
7802
7806
|
hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
|
|
7803
|
-
|
|
7807
|
+
sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile");
|
|
7804
7808
|
return watchPresentFileSystemEntryWithFsWatchFile();
|
|
7805
7809
|
}
|
|
7806
7810
|
}
|
|
@@ -8399,6 +8403,7 @@ var ts;
|
|
|
8399
8403
|
Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression: diag(1451, ts.DiagnosticCategory.Error, "Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member__1451", "Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression"),
|
|
8400
8404
|
The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."),
|
|
8401
8405
|
Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."),
|
|
8406
|
+
catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
|
|
8402
8407
|
The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
|
|
8403
8408
|
The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
|
|
8404
8409
|
Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
|
|
@@ -9279,7 +9284,7 @@ var ts;
|
|
|
9279
9284
|
Completeness: diag(6257, ts.DiagnosticCategory.Message, "Completeness_6257", "Completeness"),
|
|
9280
9285
|
_0_should_be_set_inside_the_compilerOptions_object_of_the_config_json_file: diag(6258, ts.DiagnosticCategory.Error, "_0_should_be_set_inside_the_compilerOptions_object_of_the_config_json_file_6258", "'{0}' should be set inside the 'compilerOptions' object of the config json file"),
|
|
9281
9286
|
Found_1_error_in_1: diag(6259, ts.DiagnosticCategory.Message, "Found_1_error_in_1_6259", "Found 1 error in {1}"),
|
|
9282
|
-
|
|
9287
|
+
Found_0_errors_in_the_same_file_starting_at_Colon_1: diag(6260, ts.DiagnosticCategory.Message, "Found_0_errors_in_the_same_file_starting_at_Colon_1_6260", "Found {0} errors in the same file, starting at: {1}"),
|
|
9283
9288
|
Found_0_errors_in_1_files: diag(6261, ts.DiagnosticCategory.Message, "Found_0_errors_in_1_files_6261", "Found {0} errors in {1} files."),
|
|
9284
9289
|
Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve: diag(6270, ts.DiagnosticCategory.Message, "Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve_6270", "Directory '{0}' has no containing package.json scope. Imports will not resolve."),
|
|
9285
9290
|
Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1: diag(6271, ts.DiagnosticCategory.Message, "Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1_6271", "Import specifier '{0}' does not exist in package.json scope at path '{1}'."),
|
|
@@ -16052,7 +16057,7 @@ var ts;
|
|
|
16052
16057
|
}
|
|
16053
16058
|
ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression;
|
|
16054
16059
|
function getExternalModuleRequireArgument(node) {
|
|
16055
|
-
return
|
|
16060
|
+
return isVariableDeclarationInitializedToBareOrAccessedRequire(node) && getLeftmostAccessExpression(node.initializer).arguments[0];
|
|
16056
16061
|
}
|
|
16057
16062
|
ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument;
|
|
16058
16063
|
function isInternalModuleImportEqualsDeclaration(node) {
|
|
@@ -16110,17 +16115,29 @@ var ts;
|
|
|
16110
16115
|
* Returns true if the node is a VariableDeclaration initialized to a require call (see `isRequireCall`).
|
|
16111
16116
|
* This function does not test if the node is in a JavaScript file or not.
|
|
16112
16117
|
*/
|
|
16113
|
-
function
|
|
16118
|
+
function isVariableDeclarationInitializedToRequire(node) {
|
|
16119
|
+
return isVariableDeclarationInitializedWithRequireHelper(node, /*allowAccessedRequire*/ false);
|
|
16120
|
+
}
|
|
16121
|
+
ts.isVariableDeclarationInitializedToRequire = isVariableDeclarationInitializedToRequire;
|
|
16122
|
+
/**
|
|
16123
|
+
* Like {@link isVariableDeclarationInitializedToRequire} but allows things like `require("...").foo.bar` or `require("...")["baz"]`.
|
|
16124
|
+
*/
|
|
16125
|
+
function isVariableDeclarationInitializedToBareOrAccessedRequire(node) {
|
|
16126
|
+
return isVariableDeclarationInitializedWithRequireHelper(node, /*allowAccessedRequire*/ true);
|
|
16127
|
+
}
|
|
16128
|
+
ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
|
|
16129
|
+
function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
|
|
16114
16130
|
if (node.kind === 202 /* BindingElement */) {
|
|
16115
16131
|
node = node.parent.parent;
|
|
16116
16132
|
}
|
|
16117
|
-
return ts.isVariableDeclaration(node) &&
|
|
16133
|
+
return ts.isVariableDeclaration(node) &&
|
|
16134
|
+
!!node.initializer &&
|
|
16135
|
+
isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
|
|
16118
16136
|
}
|
|
16119
|
-
ts.isRequireVariableDeclaration = isRequireVariableDeclaration;
|
|
16120
16137
|
function isRequireVariableStatement(node) {
|
|
16121
16138
|
return ts.isVariableStatement(node)
|
|
16122
16139
|
&& node.declarationList.declarations.length > 0
|
|
16123
|
-
&& ts.every(node.declarationList.declarations, function (decl) { return
|
|
16140
|
+
&& ts.every(node.declarationList.declarations, function (decl) { return isVariableDeclarationInitializedToRequire(decl); });
|
|
16124
16141
|
}
|
|
16125
16142
|
ts.isRequireVariableStatement = isRequireVariableStatement;
|
|
16126
16143
|
function isSingleOrDoubleQuote(charCode) {
|
|
@@ -19607,7 +19624,7 @@ var ts;
|
|
|
19607
19624
|
getSourceMapSourceConstructor: function () { return SourceMapSource; },
|
|
19608
19625
|
};
|
|
19609
19626
|
function setObjectAllocator(alloc) {
|
|
19610
|
-
ts.objectAllocator
|
|
19627
|
+
Object.assign(ts.objectAllocator, alloc);
|
|
19611
19628
|
}
|
|
19612
19629
|
ts.setObjectAllocator = setObjectAllocator;
|
|
19613
19630
|
function formatStringFromArgs(text, args, baseIndex) {
|
|
@@ -19615,13 +19632,22 @@ var ts;
|
|
|
19615
19632
|
return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.checkDefined(args[+index + baseIndex]); });
|
|
19616
19633
|
}
|
|
19617
19634
|
ts.formatStringFromArgs = formatStringFromArgs;
|
|
19635
|
+
var localizedDiagnosticMessages;
|
|
19618
19636
|
/* @internal */
|
|
19619
19637
|
function setLocalizedDiagnosticMessages(messages) {
|
|
19620
|
-
|
|
19638
|
+
localizedDiagnosticMessages = messages;
|
|
19621
19639
|
}
|
|
19622
19640
|
ts.setLocalizedDiagnosticMessages = setLocalizedDiagnosticMessages;
|
|
19641
|
+
/* @internal */
|
|
19642
|
+
// If the localized messages json is unset, and if given function use it to set the json
|
|
19643
|
+
function maybeSetLocalizedDiagnosticMessages(getMessages) {
|
|
19644
|
+
if (!localizedDiagnosticMessages && getMessages) {
|
|
19645
|
+
localizedDiagnosticMessages = getMessages();
|
|
19646
|
+
}
|
|
19647
|
+
}
|
|
19648
|
+
ts.maybeSetLocalizedDiagnosticMessages = maybeSetLocalizedDiagnosticMessages;
|
|
19623
19649
|
function getLocaleSpecificMessage(message) {
|
|
19624
|
-
return
|
|
19650
|
+
return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] || message.message;
|
|
19625
19651
|
}
|
|
19626
19652
|
ts.getLocaleSpecificMessage = getLocaleSpecificMessage;
|
|
19627
19653
|
function createDetachedDiagnostic(fileName, start, length, message) {
|
|
@@ -35230,7 +35256,7 @@ var ts;
|
|
|
35230
35256
|
// one out no matter what.
|
|
35231
35257
|
var finallyBlock;
|
|
35232
35258
|
if (!catchClause || token() === 96 /* FinallyKeyword */) {
|
|
35233
|
-
parseExpected(96 /* FinallyKeyword
|
|
35259
|
+
parseExpected(96 /* FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected);
|
|
35234
35260
|
finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false);
|
|
35235
35261
|
}
|
|
35236
35262
|
return withJSDoc(finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc);
|
|
@@ -44691,7 +44717,7 @@ var ts;
|
|
|
44691
44717
|
maybeBindExpressionFlowIfCall(node.expression);
|
|
44692
44718
|
}
|
|
44693
44719
|
function maybeBindExpressionFlowIfCall(node) {
|
|
44694
|
-
// A top level or
|
|
44720
|
+
// A top level or comma expression call expression with a dotted function name and at least one argument
|
|
44695
44721
|
// is potentially an assertion and is therefore included in the control flow.
|
|
44696
44722
|
if (node.kind === 207 /* CallExpression */) {
|
|
44697
44723
|
var call = node;
|
|
@@ -44859,22 +44885,27 @@ var ts;
|
|
|
44859
44885
|
}
|
|
44860
44886
|
return state;
|
|
44861
44887
|
}
|
|
44862
|
-
function onLeft(left, state,
|
|
44888
|
+
function onLeft(left, state, node) {
|
|
44863
44889
|
if (!state.skip) {
|
|
44864
|
-
|
|
44890
|
+
var maybeBound = maybeBind(left);
|
|
44891
|
+
if (node.operatorToken.kind === 27 /* CommaToken */) {
|
|
44892
|
+
maybeBindExpressionFlowIfCall(left);
|
|
44893
|
+
}
|
|
44894
|
+
return maybeBound;
|
|
44865
44895
|
}
|
|
44866
44896
|
}
|
|
44867
|
-
function onOperator(operatorToken, state,
|
|
44897
|
+
function onOperator(operatorToken, state, _node) {
|
|
44868
44898
|
if (!state.skip) {
|
|
44869
|
-
if (operatorToken.kind === 27 /* CommaToken */) {
|
|
44870
|
-
maybeBindExpressionFlowIfCall(node.left);
|
|
44871
|
-
}
|
|
44872
44899
|
bind(operatorToken);
|
|
44873
44900
|
}
|
|
44874
44901
|
}
|
|
44875
|
-
function onRight(right, state,
|
|
44902
|
+
function onRight(right, state, node) {
|
|
44876
44903
|
if (!state.skip) {
|
|
44877
|
-
|
|
44904
|
+
var maybeBound = maybeBind(right);
|
|
44905
|
+
if (node.operatorToken.kind === 27 /* CommaToken */) {
|
|
44906
|
+
maybeBindExpressionFlowIfCall(right);
|
|
44907
|
+
}
|
|
44908
|
+
return maybeBound;
|
|
44878
44909
|
}
|
|
44879
44910
|
}
|
|
44880
44911
|
function onExit(node, state) {
|
|
@@ -46437,7 +46468,7 @@ var ts;
|
|
|
46437
46468
|
checkStrictModeEvalOrArguments(node, node.name);
|
|
46438
46469
|
}
|
|
46439
46470
|
if (!ts.isBindingPattern(node.name)) {
|
|
46440
|
-
if (ts.isInJSFile(node) && ts.
|
|
46471
|
+
if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node)) {
|
|
46441
46472
|
declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
|
|
46442
46473
|
}
|
|
46443
46474
|
else if (ts.isBlockOrCatchScoped(node)) {
|
|
@@ -49220,7 +49251,7 @@ var ts;
|
|
|
49220
49251
|
&& isAliasableOrJsExpression(node.parent.right)
|
|
49221
49252
|
|| node.kind === 295 /* ShorthandPropertyAssignment */
|
|
49222
49253
|
|| node.kind === 294 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
|
|
49223
|
-
|| ts.
|
|
49254
|
+
|| ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
|
|
49224
49255
|
}
|
|
49225
49256
|
function isAliasableOrJsExpression(e) {
|
|
49226
49257
|
return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
|
|
@@ -51151,6 +51182,7 @@ var ts;
|
|
|
51151
51182
|
getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; },
|
|
51152
51183
|
getCurrentDirectory: function () { return host.getCurrentDirectory(); },
|
|
51153
51184
|
getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache),
|
|
51185
|
+
getPackageJsonInfoCache: function () { var _a; return (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host); },
|
|
51154
51186
|
useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames),
|
|
51155
51187
|
redirectTargetsMap: host.redirectTargetsMap,
|
|
51156
51188
|
getProjectReferenceRedirect: function (fileName) { return host.getProjectReferenceRedirect(fileName); },
|
|
@@ -80778,7 +80810,7 @@ var ts;
|
|
|
80778
80810
|
}
|
|
80779
80811
|
// For a commonjs `const x = require`, validate the alias and exit
|
|
80780
80812
|
var symbol = getSymbolOfNode(node);
|
|
80781
|
-
if (symbol.flags & 2097152 /* Alias */ && ts.
|
|
80813
|
+
if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
|
|
80782
80814
|
checkAliasSymbol(node);
|
|
80783
80815
|
return;
|
|
80784
80816
|
}
|
|
@@ -95723,10 +95755,19 @@ var ts;
|
|
|
95723
95755
|
var _a;
|
|
95724
95756
|
var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
|
|
95725
95757
|
var isStaticChildren = ts.length(nonWhitespaceChildren) > 1 || !!((_a = nonWhitespaceChildren[0]) === null || _a === void 0 ? void 0 : _a.dotDotDotToken);
|
|
95726
|
-
var args = [tagName, objectProperties
|
|
95758
|
+
var args = [tagName, objectProperties];
|
|
95759
|
+
// function jsx(type, config, maybeKey) {}
|
|
95760
|
+
// "maybeKey" is optional. It is acceptable to use "_jsx" without a third argument
|
|
95761
|
+
if (keyAttr) {
|
|
95762
|
+
args.push(transformJsxAttributeInitializer(keyAttr.initializer));
|
|
95763
|
+
}
|
|
95727
95764
|
if (compilerOptions.jsx === 5 /* ReactJSXDev */) {
|
|
95728
95765
|
var originalFile = ts.getOriginalNode(currentSourceFile);
|
|
95729
95766
|
if (originalFile && ts.isSourceFile(originalFile)) {
|
|
95767
|
+
// "maybeKey" has to be replaced with "void 0" to not break the jsxDEV signature
|
|
95768
|
+
if (keyAttr === undefined) {
|
|
95769
|
+
args.push(factory.createVoidZero());
|
|
95770
|
+
}
|
|
95730
95771
|
// isStaticChildren development flag
|
|
95731
95772
|
args.push(isStaticChildren ? factory.createTrue() : factory.createFalse());
|
|
95732
95773
|
// __source development flag
|
|
@@ -119591,11 +119632,12 @@ var ts;
|
|
|
119591
119632
|
};
|
|
119592
119633
|
}
|
|
119593
119634
|
function isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) {
|
|
119635
|
+
var _a;
|
|
119594
119636
|
if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12
|
|
119595
119637
|
&& ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
|
|
119596
119638
|
return false;
|
|
119597
119639
|
}
|
|
119598
|
-
return ts.getImpliedNodeFormatForFile(importingSourceFileName,
|
|
119640
|
+
return ts.getImpliedNodeFormatForFile(importingSourceFileName, (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host), getModuleResolutionHost(host), compilerOptions) !== ts.ModuleKind.CommonJS;
|
|
119599
119641
|
}
|
|
119600
119642
|
function getModuleResolutionHost(host) {
|
|
119601
119643
|
var _a;
|
|
@@ -120155,11 +120197,13 @@ var ts;
|
|
|
120155
120197
|
// For classic resolution, only allow importing from node_modules/@types, not other node_modules
|
|
120156
120198
|
return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Classic && packageName === nodeModulesDirectoryName ? undefined : packageName;
|
|
120157
120199
|
function tryDirectoryWithPackageJson(packageRootIndex) {
|
|
120200
|
+
var _a, _b;
|
|
120158
120201
|
var packageRootPath = path.substring(0, packageRootIndex);
|
|
120159
120202
|
var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
|
|
120160
120203
|
var moduleFileToTry = path;
|
|
120161
|
-
|
|
120162
|
-
|
|
120204
|
+
var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
|
|
120205
|
+
if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) {
|
|
120206
|
+
var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath));
|
|
120163
120207
|
if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
|
|
120164
120208
|
// `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate
|
|
120165
120209
|
// an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is
|
|
@@ -120459,22 +120503,31 @@ var ts;
|
|
|
120459
120503
|
ts.Diagnostics.Found_0_errors_Watching_for_file_changes;
|
|
120460
120504
|
}
|
|
120461
120505
|
ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage;
|
|
120506
|
+
function prettyPathForFileError(error, cwd) {
|
|
120507
|
+
var line = ts.formatColorAndReset(":" + error.line, ts.ForegroundColorEscapeSequences.Grey);
|
|
120508
|
+
if (ts.pathIsAbsolute(error.fileName) && ts.pathIsAbsolute(cwd)) {
|
|
120509
|
+
return ts.getRelativePathFromDirectory(cwd, error.fileName, /* ignoreCase */ false) + line;
|
|
120510
|
+
}
|
|
120511
|
+
return error.fileName + line;
|
|
120512
|
+
}
|
|
120462
120513
|
function getErrorSummaryText(errorCount, filesInError, newLine, host) {
|
|
120463
120514
|
if (errorCount === 0)
|
|
120464
120515
|
return "";
|
|
120465
120516
|
var nonNilFiles = filesInError.filter(function (fileInError) { return fileInError !== undefined; });
|
|
120466
120517
|
var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return fileInError.fileName + ":" + fileInError.line; })
|
|
120467
120518
|
.filter(function (value, index, self) { return self.indexOf(value) === index; });
|
|
120519
|
+
var firstFileReference = nonNilFiles[0] && prettyPathForFileError(nonNilFiles[0], host.getCurrentDirectory());
|
|
120468
120520
|
var d = errorCount === 1 ?
|
|
120469
120521
|
ts.createCompilerDiagnostic(filesInError[0] !== undefined ?
|
|
120470
120522
|
ts.Diagnostics.Found_1_error_in_1 :
|
|
120471
|
-
ts.Diagnostics.Found_1_error, errorCount,
|
|
120523
|
+
ts.Diagnostics.Found_1_error, errorCount, firstFileReference) :
|
|
120472
120524
|
ts.createCompilerDiagnostic(distinctFileNamesWithLines.length === 0 ?
|
|
120473
120525
|
ts.Diagnostics.Found_0_errors :
|
|
120474
120526
|
distinctFileNamesWithLines.length === 1 ?
|
|
120475
|
-
ts.Diagnostics.
|
|
120476
|
-
ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length);
|
|
120477
|
-
|
|
120527
|
+
ts.Diagnostics.Found_0_errors_in_the_same_file_starting_at_Colon_1 :
|
|
120528
|
+
ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length === 1 ? firstFileReference : distinctFileNamesWithLines.length);
|
|
120529
|
+
var suffix = distinctFileNamesWithLines.length > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : "";
|
|
120530
|
+
return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + suffix;
|
|
120478
120531
|
}
|
|
120479
120532
|
ts.getErrorSummaryText = getErrorSummaryText;
|
|
120480
120533
|
function createTabularErrorsDisplay(filesInError, host) {
|
|
@@ -120496,8 +120549,8 @@ var ts;
|
|
|
120496
120549
|
var leftPadding = errorCountDigitsLength < leftPaddingGoal ?
|
|
120497
120550
|
" ".repeat(leftPaddingGoal - errorCountDigitsLength)
|
|
120498
120551
|
: "";
|
|
120499
|
-
var
|
|
120500
|
-
tabularData += "" + leftPadding + errorCount + " " +
|
|
120552
|
+
var fileRef = prettyPathForFileError(file, host.getCurrentDirectory());
|
|
120553
|
+
tabularData += "" + leftPadding + errorCount + " " + fileRef + "\n";
|
|
120501
120554
|
});
|
|
120502
120555
|
return tabularData;
|
|
120503
120556
|
}
|
|
@@ -120998,6 +121051,7 @@ var ts;
|
|
|
120998
121051
|
var sharedExtendedConfigFileWatchers; // Map of file watchers for extended files, shared between different referenced projects
|
|
120999
121052
|
var extendedConfigCache = host.extendedConfigCache; // Cache for extended config evaluation
|
|
121000
121053
|
var changesAffectResolution = false; // Flag for indicating non-config changes affect module resolution
|
|
121054
|
+
var reportFileChangeDetectedOnCreateProgram = false; // True if synchronizeProgram should report "File change detected..." when a new program is created
|
|
121001
121055
|
var sourceFilesCache = new ts.Map(); // Cache that stores the source file and version info
|
|
121002
121056
|
var missingFilePathsRequestedForRelease; // These paths are held temporarily so that we can remove the entry from source file cache if the file is not tracked by missing files
|
|
121003
121057
|
var hasChangedCompilerOptions = false; // True if the compiler options have changed between compilations
|
|
@@ -121160,14 +121214,21 @@ var ts;
|
|
|
121160
121214
|
var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution || changesAffectResolution);
|
|
121161
121215
|
if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
|
|
121162
121216
|
if (hasChangedConfigFileParsingErrors) {
|
|
121217
|
+
if (reportFileChangeDetectedOnCreateProgram) {
|
|
121218
|
+
reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
|
|
121219
|
+
}
|
|
121163
121220
|
builderProgram = createProgram(/*rootNames*/ undefined, /*options*/ undefined, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
|
|
121164
121221
|
hasChangedConfigFileParsingErrors = false;
|
|
121165
121222
|
}
|
|
121166
121223
|
}
|
|
121167
121224
|
else {
|
|
121225
|
+
if (reportFileChangeDetectedOnCreateProgram) {
|
|
121226
|
+
reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
|
|
121227
|
+
}
|
|
121168
121228
|
createNewProgram(hasInvalidatedResolution);
|
|
121169
121229
|
}
|
|
121170
121230
|
changesAffectResolution = false; // reset for next sync
|
|
121231
|
+
reportFileChangeDetectedOnCreateProgram = false;
|
|
121171
121232
|
if (host.afterProgramCreate && program !== builderProgram) {
|
|
121172
121233
|
host.afterProgramCreate(builderProgram);
|
|
121173
121234
|
}
|
|
@@ -121369,7 +121430,7 @@ var ts;
|
|
|
121369
121430
|
}
|
|
121370
121431
|
function updateProgramWithWatchStatus() {
|
|
121371
121432
|
timerToUpdateProgram = undefined;
|
|
121372
|
-
|
|
121433
|
+
reportFileChangeDetectedOnCreateProgram = true;
|
|
121373
121434
|
updateProgram();
|
|
121374
121435
|
}
|
|
121375
121436
|
function updateProgram() {
|
|
@@ -123893,6 +123954,7 @@ var ts;
|
|
|
123893
123954
|
ScriptElementKind["externalModuleName"] = "external module name";
|
|
123894
123955
|
/**
|
|
123895
123956
|
* <JsxTagName attribute1 attribute2={0} />
|
|
123957
|
+
* @deprecated
|
|
123896
123958
|
*/
|
|
123897
123959
|
ScriptElementKind["jsxAttribute"] = "JSX attribute";
|
|
123898
123960
|
/** String literal */
|
|
@@ -125218,7 +125280,7 @@ var ts;
|
|
|
125218
125280
|
isWhiteSpaceOnlyJsxText(child);
|
|
125219
125281
|
if (lookInPreviousChild) {
|
|
125220
125282
|
// actual start of the node is past the position - previous token should be at the end of previous child
|
|
125221
|
-
var candidate_1 = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i, sourceFile);
|
|
125283
|
+
var candidate_1 = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i, sourceFile, n.kind);
|
|
125222
125284
|
return candidate_1 && findRightmostToken(candidate_1, sourceFile);
|
|
125223
125285
|
}
|
|
125224
125286
|
else {
|
|
@@ -125232,7 +125294,7 @@ var ts;
|
|
|
125232
125294
|
// the only known case is when position is at the end of the file.
|
|
125233
125295
|
// Try to find the rightmost token in the file without filtering.
|
|
125234
125296
|
// Namely we are skipping the check: 'position < node.end'
|
|
125235
|
-
var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile);
|
|
125297
|
+
var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile, n.kind);
|
|
125236
125298
|
return candidate && findRightmostToken(candidate, sourceFile);
|
|
125237
125299
|
}
|
|
125238
125300
|
}
|
|
@@ -125248,17 +125310,19 @@ var ts;
|
|
|
125248
125310
|
if (children.length === 0) {
|
|
125249
125311
|
return n;
|
|
125250
125312
|
}
|
|
125251
|
-
var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile);
|
|
125313
|
+
var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile, n.kind);
|
|
125252
125314
|
return candidate && findRightmostToken(candidate, sourceFile);
|
|
125253
125315
|
}
|
|
125254
125316
|
/**
|
|
125255
125317
|
* Finds the rightmost child to the left of `children[exclusiveStartPosition]` which is a non-all-whitespace token or has constituent tokens.
|
|
125256
125318
|
*/
|
|
125257
|
-
function findRightmostChildNodeWithTokens(children, exclusiveStartPosition, sourceFile) {
|
|
125319
|
+
function findRightmostChildNodeWithTokens(children, exclusiveStartPosition, sourceFile, parentKind) {
|
|
125258
125320
|
for (var i = exclusiveStartPosition - 1; i >= 0; i--) {
|
|
125259
125321
|
var child = children[i];
|
|
125260
125322
|
if (isWhiteSpaceOnlyJsxText(child)) {
|
|
125261
|
-
|
|
125323
|
+
if (i === 0 && (parentKind === 11 /* JsxText */ || parentKind === 278 /* JsxSelfClosingElement */)) {
|
|
125324
|
+
ts.Debug.fail("`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`");
|
|
125325
|
+
}
|
|
125262
125326
|
}
|
|
125263
125327
|
else if (nodeHasTokens(children[i], sourceFile)) {
|
|
125264
125328
|
return children[i];
|
|
@@ -125784,6 +125848,7 @@ var ts;
|
|
|
125784
125848
|
useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames),
|
|
125785
125849
|
getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache) || program.getSymlinkCache,
|
|
125786
125850
|
getModuleSpecifierCache: ts.maybeBind(host, host.getModuleSpecifierCache),
|
|
125851
|
+
getPackageJsonInfoCache: function () { var _a; return (_a = program.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfoCache(); },
|
|
125787
125852
|
getGlobalTypingsCacheLocation: ts.maybeBind(host, host.getGlobalTypingsCacheLocation),
|
|
125788
125853
|
redirectTargetsMap: program.redirectTargetsMap,
|
|
125789
125854
|
getProjectReferenceRedirect: function (fileName) { return program.getProjectReferenceRedirect(fileName); },
|
|
@@ -129528,6 +129593,7 @@ var ts;
|
|
|
129528
129593
|
function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, preferences, isForImportStatementCompletion, cb) {
|
|
129529
129594
|
var _a, _b, _c;
|
|
129530
129595
|
var start = ts.timestamp();
|
|
129596
|
+
var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
129531
129597
|
var resolutionLimitExceeded = false;
|
|
129532
129598
|
var ambientCount = 0;
|
|
129533
129599
|
var resolvedCount = 0;
|
|
@@ -129550,7 +129616,7 @@ var ts;
|
|
|
129550
129616
|
var shouldResolveModuleSpecifier = isForImportStatementCompletion || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
|
|
129551
129617
|
var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit;
|
|
129552
129618
|
var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache)
|
|
129553
|
-
? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences, shouldGetModuleSpecifierFromCache)
|
|
129619
|
+
? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache)
|
|
129554
129620
|
: undefined;
|
|
129555
129621
|
if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) {
|
|
129556
129622
|
resolutionLimitExceeded = true;
|
|
@@ -130948,9 +131014,7 @@ var ts;
|
|
|
130948
131014
|
// GH#39946. Pulling on the type of a node inside of a function with a contextual `this` parameter can result in a circularity
|
|
130949
131015
|
// if the `node` is part of the exprssion of a `yield` or `return`. This circularity doesn't exist at compile time because
|
|
130950
131016
|
// we will check (and cache) the type of `this` *before* checking the type of the node.
|
|
130951
|
-
|
|
130952
|
-
if (!ts.isSourceFile(container) && container.parent)
|
|
130953
|
-
typeChecker.getTypeAtLocation(container);
|
|
131017
|
+
typeChecker.tryGetThisTypeAt(node, /*includeGlobalThis*/ false);
|
|
130954
131018
|
var type = typeChecker.getTypeAtLocation(node).getNonOptionalType();
|
|
130955
131019
|
var insertQuestionDot = false;
|
|
130956
131020
|
if (type.isNullableType()) {
|
|
@@ -133805,7 +133869,7 @@ var ts;
|
|
|
133805
133869
|
ts.Debug.assert(parent.name === node);
|
|
133806
133870
|
return true;
|
|
133807
133871
|
case 202 /* BindingElement */:
|
|
133808
|
-
return ts.isInJSFile(node) && ts.
|
|
133872
|
+
return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent);
|
|
133809
133873
|
default:
|
|
133810
133874
|
return false;
|
|
133811
133875
|
}
|
|
@@ -135205,7 +135269,7 @@ var ts;
|
|
|
135205
135269
|
// Use the parent symbol if the location is commonjs require syntax on javascript files only.
|
|
135206
135270
|
if (ts.isInJSFile(referenceLocation)
|
|
135207
135271
|
&& referenceLocation.parent.kind === 202 /* BindingElement */
|
|
135208
|
-
&& ts.
|
|
135272
|
+
&& ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) {
|
|
135209
135273
|
referenceSymbol = referenceLocation.parent.symbol;
|
|
135210
135274
|
// The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In
|
|
135211
135275
|
// this case, just skip it, since the bound identifiers are not an alias of the import.
|
|
@@ -136916,7 +136980,7 @@ var ts;
|
|
|
136916
136980
|
return declaration.parent.kind === 268 /* NamedImports */;
|
|
136917
136981
|
case 202 /* BindingElement */:
|
|
136918
136982
|
case 253 /* VariableDeclaration */:
|
|
136919
|
-
return ts.isInJSFile(declaration) && ts.
|
|
136983
|
+
return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration);
|
|
136920
136984
|
default:
|
|
136921
136985
|
return false;
|
|
136922
136986
|
}
|
|
@@ -141820,18 +141884,7 @@ var ts;
|
|
|
141820
141884
|
}
|
|
141821
141885
|
return unionPropertyKind;
|
|
141822
141886
|
}
|
|
141823
|
-
|
|
141824
|
-
switch (location.parent && location.parent.kind) {
|
|
141825
|
-
// If we've typed a character of the attribute name, will be 'JsxAttribute', else will be 'JsxOpeningElement'.
|
|
141826
|
-
case 279 /* JsxOpeningElement */:
|
|
141827
|
-
case 277 /* JsxElement */:
|
|
141828
|
-
case 278 /* JsxSelfClosingElement */:
|
|
141829
|
-
return location.kind === 79 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */;
|
|
141830
|
-
case 284 /* JsxAttribute */:
|
|
141831
|
-
return "JSX attribute" /* jsxAttribute */;
|
|
141832
|
-
default:
|
|
141833
|
-
return "property" /* memberVariableElement */;
|
|
141834
|
-
}
|
|
141887
|
+
return "property" /* memberVariableElement */;
|
|
141835
141888
|
}
|
|
141836
141889
|
return "" /* unknown */;
|
|
141837
141890
|
}
|
|
@@ -145849,7 +145902,11 @@ var ts;
|
|
|
145849
145902
|
oldTags[i] = merged;
|
|
145850
145903
|
return !!merged;
|
|
145851
145904
|
}); });
|
|
145852
|
-
var
|
|
145905
|
+
var tags = __spreadArray(__spreadArray([], oldTags, true), unmergedNewTags, true);
|
|
145906
|
+
var jsDoc = ts.singleOrUndefined(parent.jsDoc);
|
|
145907
|
+
var comment = jsDoc && ts.positionsAreOnSameLine(jsDoc.pos, jsDoc.end, sourceFile) && !ts.length(comments) ? undefined :
|
|
145908
|
+
ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n")));
|
|
145909
|
+
var tag = ts.factory.createJSDocComment(comment, ts.factory.createNodeArray(tags));
|
|
145853
145910
|
var host = updateJSDocHost(parent);
|
|
145854
145911
|
this.insertJsdocCommentBefore(sourceFile, host, tag);
|
|
145855
145912
|
};
|
|
@@ -146279,6 +146336,8 @@ var ts;
|
|
|
146279
146336
|
}
|
|
146280
146337
|
case 339 /* JSDocReturnTag */:
|
|
146281
146338
|
return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment);
|
|
146339
|
+
case 341 /* JSDocTypeTag */:
|
|
146340
|
+
return ts.factory.createJSDocTypeTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment);
|
|
146282
146341
|
}
|
|
146283
146342
|
}
|
|
146284
146343
|
// find first non-whitespace position in the leading trivia of the node
|
|
@@ -149817,7 +149876,8 @@ var ts;
|
|
|
149817
149876
|
codefix.getImportCompletionAction = getImportCompletionAction;
|
|
149818
149877
|
function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
|
|
149819
149878
|
ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
|
|
149820
|
-
|
|
149879
|
+
var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
149880
|
+
return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter);
|
|
149821
149881
|
}
|
|
149822
149882
|
function codeFixActionToCodeAction(_a) {
|
|
149823
149883
|
var description = _a.description, changes = _a.changes, commands = _a.commands;
|
|
@@ -149872,12 +149932,12 @@ var ts;
|
|
|
149872
149932
|
return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, preferences, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host));
|
|
149873
149933
|
}
|
|
149874
149934
|
}
|
|
149875
|
-
function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences, fromCacheOnly) {
|
|
149935
|
+
function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) {
|
|
149876
149936
|
var _a = getNewImportFixes(program, importingFile,
|
|
149877
149937
|
/*position*/ undefined,
|
|
149878
149938
|
/*isValidTypeOnlyUseSite*/ false,
|
|
149879
149939
|
/*useRequire*/ false, exportInfo, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
|
|
149880
|
-
var result = getBestFix(fixes, importingFile, program,
|
|
149940
|
+
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host));
|
|
149881
149941
|
return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
|
|
149882
149942
|
}
|
|
149883
149943
|
codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo;
|
|
@@ -150011,7 +150071,7 @@ var ts;
|
|
|
150011
150071
|
var importKind = getImportKind(importingFile, exportKind, compilerOptions);
|
|
150012
150072
|
return ts.mapDefined(importingFile.imports, function (moduleSpecifier) {
|
|
150013
150073
|
var i = ts.importFromModuleSpecifier(moduleSpecifier);
|
|
150014
|
-
if (ts.
|
|
150074
|
+
if (ts.isVariableDeclarationInitializedToRequire(i.parent)) {
|
|
150015
150075
|
return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined;
|
|
150016
150076
|
}
|
|
150017
150077
|
if (i.kind === 265 /* ImportDeclaration */ || i.kind === 264 /* ImportEqualsDeclaration */) {
|
|
@@ -150097,23 +150157,22 @@ var ts;
|
|
|
150097
150157
|
var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code
|
|
150098
150158
|
? getFixesInfoForUMDImport(context, symbolToken)
|
|
150099
150159
|
: ts.isIdentifier(symbolToken) ? getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider) : undefined;
|
|
150100
|
-
|
|
150160
|
+
var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
|
|
150161
|
+
return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter) });
|
|
150101
150162
|
}
|
|
150102
|
-
function sortFixes(fixes, sourceFile, program,
|
|
150103
|
-
|
|
150104
|
-
return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, sourceFile, program, allowsImportingSpecifier); });
|
|
150163
|
+
function sortFixes(fixes, sourceFile, program, packageJsonImportFilter) {
|
|
150164
|
+
return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier); });
|
|
150105
150165
|
}
|
|
150106
|
-
function getBestFix(fixes, sourceFile, program,
|
|
150166
|
+
function getBestFix(fixes, sourceFile, program, packageJsonImportFilter) {
|
|
150107
150167
|
if (!ts.some(fixes))
|
|
150108
150168
|
return;
|
|
150109
150169
|
// These will always be placed first if available, and are better than other kinds
|
|
150110
150170
|
if (fixes[0].kind === 0 /* UseNamespace */ || fixes[0].kind === 2 /* AddToExisting */) {
|
|
150111
150171
|
return fixes[0];
|
|
150112
150172
|
}
|
|
150113
|
-
var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, preferences, host).allowsImportingSpecifier;
|
|
150114
150173
|
return fixes.reduce(function (best, fix) {
|
|
150115
150174
|
// Takes true branch of conditional if `fix` is better than `best`
|
|
150116
|
-
return compareModuleSpecifiers(fix, best, sourceFile, program, allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best;
|
|
150175
|
+
return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best;
|
|
150117
150176
|
});
|
|
150118
150177
|
}
|
|
150119
150178
|
/** @returns `Comparison.LessThan` if `a` is better than `b`. */
|
|
@@ -152965,7 +153024,7 @@ var ts;
|
|
|
152965
153024
|
});
|
|
152966
153025
|
var name = declaration && ts.getNameOfDeclaration(declaration);
|
|
152967
153026
|
return !name || changes.length === 0 ? undefined
|
|
152968
|
-
: [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token),
|
|
153027
|
+
: [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), ts.getTextOfNode(name)], fixId, ts.Diagnostics.Infer_all_types_from_usage)];
|
|
152969
153028
|
},
|
|
152970
153029
|
fixIds: [fixId],
|
|
152971
153030
|
getAllCodeActions: function (context) {
|
|
@@ -153043,7 +153102,7 @@ var ts;
|
|
|
153043
153102
|
case ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code: {
|
|
153044
153103
|
var symbol = program.getTypeChecker().getSymbolAtLocation(token);
|
|
153045
153104
|
if (symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && markSeen(symbol.valueDeclaration)) {
|
|
153046
|
-
annotateVariableDeclaration(changes, importAdder,
|
|
153105
|
+
annotateVariableDeclaration(changes, importAdder, ts.getSourceFileOfNode(symbol.valueDeclaration), symbol.valueDeclaration, program, host, cancellationToken);
|
|
153047
153106
|
importAdder.writeFixes(changes);
|
|
153048
153107
|
return symbol.valueDeclaration;
|
|
153049
153108
|
}
|
|
@@ -154742,35 +154801,34 @@ var ts;
|
|
|
154742
154801
|
codefix.registerCodeFix({
|
|
154743
154802
|
errorCodes: errorCodes,
|
|
154744
154803
|
getCodeActions: function getCodeActionsForStrictClassInitializationErrors(context) {
|
|
154745
|
-
var
|
|
154746
|
-
if (!
|
|
154804
|
+
var info = getInfo(context.sourceFile, context.span.start);
|
|
154805
|
+
if (!info)
|
|
154747
154806
|
return;
|
|
154748
|
-
var result = [
|
|
154749
|
-
|
|
154750
|
-
|
|
154751
|
-
|
|
154752
|
-
ts.append(result, getActionForAddMissingInitializer(context, propertyDeclaration));
|
|
154807
|
+
var result = [];
|
|
154808
|
+
ts.append(result, getActionForAddMissingUndefinedType(context, info));
|
|
154809
|
+
ts.append(result, getActionForAddMissingDefiniteAssignmentAssertion(context, info));
|
|
154810
|
+
ts.append(result, getActionForAddMissingInitializer(context, info));
|
|
154753
154811
|
return result;
|
|
154754
154812
|
},
|
|
154755
154813
|
fixIds: [fixIdAddDefiniteAssignmentAssertions, fixIdAddUndefinedType, fixIdAddInitializer],
|
|
154756
154814
|
getAllCodeActions: function (context) {
|
|
154757
154815
|
return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
|
|
154758
|
-
var
|
|
154759
|
-
if (!
|
|
154816
|
+
var info = getInfo(diag.file, diag.start);
|
|
154817
|
+
if (!info)
|
|
154760
154818
|
return;
|
|
154761
154819
|
switch (context.fixId) {
|
|
154762
154820
|
case fixIdAddDefiniteAssignmentAssertions:
|
|
154763
|
-
addDefiniteAssignmentAssertion(changes, diag.file,
|
|
154821
|
+
addDefiniteAssignmentAssertion(changes, diag.file, info.prop);
|
|
154764
154822
|
break;
|
|
154765
154823
|
case fixIdAddUndefinedType:
|
|
154766
|
-
addUndefinedType(changes, diag.file,
|
|
154824
|
+
addUndefinedType(changes, diag.file, info);
|
|
154767
154825
|
break;
|
|
154768
154826
|
case fixIdAddInitializer:
|
|
154769
154827
|
var checker = context.program.getTypeChecker();
|
|
154770
|
-
var initializer = getInitializer(checker,
|
|
154828
|
+
var initializer = getInitializer(checker, info.prop);
|
|
154771
154829
|
if (!initializer)
|
|
154772
154830
|
return;
|
|
154773
|
-
addInitializer(changes, diag.file,
|
|
154831
|
+
addInitializer(changes, diag.file, info.prop, initializer);
|
|
154774
154832
|
break;
|
|
154775
154833
|
default:
|
|
154776
154834
|
ts.Debug.fail(JSON.stringify(context.fixId));
|
|
@@ -154778,35 +154836,50 @@ var ts;
|
|
|
154778
154836
|
});
|
|
154779
154837
|
},
|
|
154780
154838
|
});
|
|
154781
|
-
function
|
|
154839
|
+
function getInfo(sourceFile, pos) {
|
|
154782
154840
|
var token = ts.getTokenAtPosition(sourceFile, pos);
|
|
154783
|
-
|
|
154841
|
+
if (ts.isIdentifier(token) && ts.isPropertyDeclaration(token.parent)) {
|
|
154842
|
+
var type = ts.getEffectiveTypeAnnotationNode(token.parent);
|
|
154843
|
+
if (type) {
|
|
154844
|
+
return { type: type, prop: token.parent, isJs: ts.isInJSFile(token.parent) };
|
|
154845
|
+
}
|
|
154846
|
+
}
|
|
154847
|
+
return undefined;
|
|
154784
154848
|
}
|
|
154785
|
-
function getActionForAddMissingDefiniteAssignmentAssertion(context,
|
|
154786
|
-
|
|
154787
|
-
|
|
154849
|
+
function getActionForAddMissingDefiniteAssignmentAssertion(context, info) {
|
|
154850
|
+
if (info.isJs)
|
|
154851
|
+
return undefined;
|
|
154852
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addDefiniteAssignmentAssertion(t, context.sourceFile, info.prop); });
|
|
154853
|
+
return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, info.prop.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties);
|
|
154788
154854
|
}
|
|
154789
154855
|
function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) {
|
|
154790
154856
|
var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer);
|
|
154791
154857
|
changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property);
|
|
154792
154858
|
}
|
|
154793
|
-
function getActionForAddMissingUndefinedType(context,
|
|
154794
|
-
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addUndefinedType(t, context.sourceFile,
|
|
154795
|
-
return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0,
|
|
154859
|
+
function getActionForAddMissingUndefinedType(context, info) {
|
|
154860
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addUndefinedType(t, context.sourceFile, info); });
|
|
154861
|
+
return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, info.prop.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties);
|
|
154796
154862
|
}
|
|
154797
|
-
function addUndefinedType(changeTracker,
|
|
154863
|
+
function addUndefinedType(changeTracker, sourceFile, info) {
|
|
154798
154864
|
var undefinedTypeNode = ts.factory.createKeywordTypeNode(152 /* UndefinedKeyword */);
|
|
154799
|
-
var
|
|
154800
|
-
var
|
|
154801
|
-
|
|
154865
|
+
var types = ts.isUnionTypeNode(info.type) ? info.type.types.concat(undefinedTypeNode) : [info.type, undefinedTypeNode];
|
|
154866
|
+
var unionTypeNode = ts.factory.createUnionTypeNode(types);
|
|
154867
|
+
if (info.isJs) {
|
|
154868
|
+
changeTracker.addJSDocTags(sourceFile, info.prop, [ts.factory.createJSDocTypeTag(/*tagName*/ undefined, ts.factory.createJSDocTypeExpression(unionTypeNode))]);
|
|
154869
|
+
}
|
|
154870
|
+
else {
|
|
154871
|
+
changeTracker.replaceNode(sourceFile, info.type, unionTypeNode);
|
|
154872
|
+
}
|
|
154802
154873
|
}
|
|
154803
|
-
function getActionForAddMissingInitializer(context,
|
|
154874
|
+
function getActionForAddMissingInitializer(context, info) {
|
|
154875
|
+
if (info.isJs)
|
|
154876
|
+
return undefined;
|
|
154804
154877
|
var checker = context.program.getTypeChecker();
|
|
154805
|
-
var initializer = getInitializer(checker,
|
|
154878
|
+
var initializer = getInitializer(checker, info.prop);
|
|
154806
154879
|
if (!initializer)
|
|
154807
154880
|
return undefined;
|
|
154808
|
-
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addInitializer(t, context.sourceFile,
|
|
154809
|
-
return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_initializer_to_property_0,
|
|
154881
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addInitializer(t, context.sourceFile, info.prop, initializer); });
|
|
154882
|
+
return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_initializer_to_property_0, info.prop.name.getText()], fixIdAddInitializer, ts.Diagnostics.Add_initializers_to_all_uninitialized_properties);
|
|
154810
154883
|
}
|
|
154811
154884
|
function addInitializer(changeTracker, propertyDeclarationSourceFile, propertyDeclaration, initializer) {
|
|
154812
154885
|
var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, propertyDeclaration.questionToken, propertyDeclaration.type, initializer);
|
|
@@ -161183,6 +161256,7 @@ var ts;
|
|
|
161183
161256
|
], false);
|
|
161184
161257
|
function createLanguageService(host, documentRegistry, syntaxOnlyOrLanguageServiceMode) {
|
|
161185
161258
|
var _a;
|
|
161259
|
+
var _b;
|
|
161186
161260
|
if (documentRegistry === void 0) { documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); }
|
|
161187
161261
|
var languageServiceMode;
|
|
161188
161262
|
if (syntaxOnlyOrLanguageServiceMode === undefined) {
|
|
@@ -161203,10 +161277,8 @@ var ts;
|
|
|
161203
161277
|
? new CancellationTokenObject(host.getCancellationToken())
|
|
161204
161278
|
: NoopCancellationToken;
|
|
161205
161279
|
var currentDirectory = host.getCurrentDirectory();
|
|
161206
|
-
//
|
|
161207
|
-
|
|
161208
|
-
ts.setLocalizedDiagnosticMessages(host.getLocalizedDiagnosticMessages());
|
|
161209
|
-
}
|
|
161280
|
+
// Checks if the localized messages json is set, and if not, query the host for it
|
|
161281
|
+
ts.maybeSetLocalizedDiagnosticMessages((_b = host.getLocalizedDiagnosticMessages) === null || _b === void 0 ? void 0 : _b.bind(host));
|
|
161210
161282
|
function log(message) {
|
|
161211
161283
|
if (host.log) {
|
|
161212
161284
|
host.log(message);
|
|
@@ -161308,6 +161380,7 @@ var ts;
|
|
|
161308
161380
|
hasChangedAutomaticTypeDirectiveNames: hasChangedAutomaticTypeDirectiveNames,
|
|
161309
161381
|
trace: parseConfigHost.trace,
|
|
161310
161382
|
resolveModuleNames: ts.maybeBind(host, host.resolveModuleNames),
|
|
161383
|
+
getModuleResolutionCache: ts.maybeBind(host, host.getModuleResolutionCache),
|
|
161311
161384
|
resolveTypeReferenceDirectives: ts.maybeBind(host, host.resolveTypeReferenceDirectives),
|
|
161312
161385
|
useSourceOfProjectReferenceRedirect: ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect),
|
|
161313
161386
|
getParsedCommandLine: getParsedCommandLine,
|