@typescript-deploys/pr-build 4.5.0-pr-46250-2 → 4.5.0-pr-46464-7
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/cs/diagnosticMessages.generated.json +3 -2
- package/lib/de/diagnosticMessages.generated.json +3 -2
- package/lib/es/diagnosticMessages.generated.json +4 -2
- package/lib/fr/diagnosticMessages.generated.json +4 -2
- package/lib/it/diagnosticMessages.generated.json +3 -2
- package/lib/ja/diagnosticMessages.generated.json +4 -2
- package/lib/ko/diagnosticMessages.generated.json +3 -2
- package/lib/lib.es5.d.ts +2 -2
- package/lib/pl/diagnosticMessages.generated.json +4 -2
- package/lib/pt-br/diagnosticMessages.generated.json +3 -2
- package/lib/ru/diagnosticMessages.generated.json +3 -2
- package/lib/tr/diagnosticMessages.generated.json +4 -2
- package/lib/tsc.js +241 -219
- package/lib/tsserver.js +426 -385
- package/lib/tsserverlibrary.d.ts +21 -14
- package/lib/tsserverlibrary.js +425 -384
- package/lib/typescript.d.ts +21 -14
- package/lib/typescript.js +425 -384
- package/lib/typescriptServices.d.ts +21 -14
- package/lib/typescriptServices.js +425 -384
- package/lib/typingsInstaller.js +269 -298
- package/lib/zh-cn/diagnosticMessages.generated.json +4 -2
- package/lib/zh-tw/diagnosticMessages.generated.json +3 -2
- package/package.json +1 -1
package/lib/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-insiders.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-insiders.20211022";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -129,21 +129,24 @@ var ts;
|
|
|
129
129
|
return typeof Set !== "undefined" && "entries" in Set.prototype && new Set([0]).size === 1 ? Set : undefined;
|
|
130
130
|
}
|
|
131
131
|
NativeCollections.tryGetNativeSet = tryGetNativeSet;
|
|
132
|
-
})(NativeCollections
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
(
|
|
132
|
+
})(NativeCollections || (NativeCollections = {}));
|
|
133
|
+
/* @internal */
|
|
134
|
+
ts.Map = getCollectionImplementation("Map", "tryGetNativeMap", "createMapShim");
|
|
135
|
+
/* @internal */
|
|
136
|
+
ts.Set = getCollectionImplementation("Set", "tryGetNativeSet", "createSetShim");
|
|
137
|
+
/* @internal */
|
|
137
138
|
function getCollectionImplementation(name, nativeFactory, shimFactory) {
|
|
138
139
|
var _a;
|
|
139
140
|
// NOTE: ts.ShimCollections will be defined for typescriptServices.js but not for tsc.js, so we must test for it.
|
|
140
|
-
var constructor = (_a =
|
|
141
|
+
var constructor = (_a = NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](ts.getIterator);
|
|
141
142
|
if (constructor)
|
|
142
143
|
return constructor;
|
|
143
144
|
throw new Error("TypeScript requires an environment that provides a compatible native " + name + " implementation.");
|
|
144
145
|
}
|
|
145
|
-
|
|
146
|
-
|
|
146
|
+
})(ts || (ts = {}));
|
|
147
|
+
/* @internal */
|
|
148
|
+
var ts;
|
|
149
|
+
(function (ts) {
|
|
147
150
|
function getIterator(iterable) {
|
|
148
151
|
if (iterable) {
|
|
149
152
|
if (isArray(iterable))
|
|
@@ -7823,6 +7826,11 @@ var ts;
|
|
|
7823
7826
|
}
|
|
7824
7827
|
return sys;
|
|
7825
7828
|
})();
|
|
7829
|
+
/*@internal*/
|
|
7830
|
+
function setSys(s) {
|
|
7831
|
+
ts.sys = s;
|
|
7832
|
+
}
|
|
7833
|
+
ts.setSys = setSys;
|
|
7826
7834
|
if (ts.sys && ts.sys.getEnvironmentVariable) {
|
|
7827
7835
|
setCustomPollingValues(ts.sys);
|
|
7828
7836
|
ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))
|
|
@@ -9333,6 +9341,7 @@ var ts;
|
|
|
9333
9341
|
If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_declare_module_1: diag(7058, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_decl_7058", "If the '{0}' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module '{1}';`"),
|
|
9334
9342
|
This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead: diag(7059, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead_7059", "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead."),
|
|
9335
9343
|
This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint: diag(7060, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_cons_7060", "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint."),
|
|
9344
|
+
A_mapped_type_may_not_declare_properties_or_methods: diag(7061, ts.DiagnosticCategory.Error, "A_mapped_type_may_not_declare_properties_or_methods_7061", "A mapped type may not declare properties or methods."),
|
|
9336
9345
|
You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
|
|
9337
9346
|
You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."),
|
|
9338
9347
|
import_can_only_be_used_in_TypeScript_files: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_TypeScript_files_8002", "'import ... =' can only be used in TypeScript files."),
|
|
@@ -9388,7 +9397,7 @@ var ts;
|
|
|
9388
9397
|
Circularity_detected_while_resolving_configuration_Colon_0: diag(18000, ts.DiagnosticCategory.Error, "Circularity_detected_while_resolving_configuration_Colon_0_18000", "Circularity detected while resolving configuration: {0}"),
|
|
9389
9398
|
The_files_list_in_config_file_0_is_empty: diag(18002, ts.DiagnosticCategory.Error, "The_files_list_in_config_file_0_is_empty_18002", "The 'files' list in config file '{0}' is empty."),
|
|
9390
9399
|
No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: diag(18003, ts.DiagnosticCategory.Error, "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'."),
|
|
9391
|
-
|
|
9400
|
+
File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module: diag(80001, ts.DiagnosticCategory.Suggestion, "File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001", "File is a CommonJS module; it may be converted to an ES module."),
|
|
9392
9401
|
This_constructor_function_may_be_converted_to_a_class_declaration: diag(80002, ts.DiagnosticCategory.Suggestion, "This_constructor_function_may_be_converted_to_a_class_declaration_80002", "This constructor function may be converted to a class declaration."),
|
|
9393
9402
|
Import_may_be_converted_to_a_default_import: diag(80003, ts.DiagnosticCategory.Suggestion, "Import_may_be_converted_to_a_default_import_80003", "Import may be converted to a default import."),
|
|
9394
9403
|
JSDoc_types_may_be_moved_to_TypeScript_types: diag(80004, ts.DiagnosticCategory.Suggestion, "JSDoc_types_may_be_moved_to_TypeScript_types_80004", "JSDoc types may be moved to TypeScript types."),
|
|
@@ -9450,7 +9459,7 @@ var ts;
|
|
|
9450
9459
|
Install_0: diag(95014, ts.DiagnosticCategory.Message, "Install_0_95014", "Install '{0}'"),
|
|
9451
9460
|
Replace_import_with_0: diag(95015, ts.DiagnosticCategory.Message, "Replace_import_with_0_95015", "Replace import with '{0}'."),
|
|
9452
9461
|
Use_synthetic_default_member: diag(95016, ts.DiagnosticCategory.Message, "Use_synthetic_default_member_95016", "Use synthetic 'default' member."),
|
|
9453
|
-
|
|
9462
|
+
Convert_to_ES_module: diag(95017, ts.DiagnosticCategory.Message, "Convert_to_ES_module_95017", "Convert to ES module"),
|
|
9454
9463
|
Add_undefined_type_to_property_0: diag(95018, ts.DiagnosticCategory.Message, "Add_undefined_type_to_property_0_95018", "Add 'undefined' type to property '{0}'"),
|
|
9455
9464
|
Add_initializer_to_property_0: diag(95019, ts.DiagnosticCategory.Message, "Add_initializer_to_property_0_95019", "Add initializer to property '{0}'"),
|
|
9456
9465
|
Add_definite_assignment_assertion_to_property_0: diag(95020, ts.DiagnosticCategory.Message, "Add_definite_assignment_assertion_to_property_0_95020", "Add definite assignment assertion to property '{0}'"),
|
|
@@ -19984,7 +19993,7 @@ var ts;
|
|
|
19984
19993
|
includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"),
|
|
19985
19994
|
includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"),
|
|
19986
19995
|
excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"),
|
|
19987
|
-
basePaths: getBasePaths(
|
|
19996
|
+
basePaths: getBasePaths(absolutePath, includes, useCaseSensitiveFileNames)
|
|
19988
19997
|
};
|
|
19989
19998
|
}
|
|
19990
19999
|
ts.getFileMatcherPatterns = getFileMatcherPatterns;
|
|
@@ -20006,20 +20015,20 @@ var ts;
|
|
|
20006
20015
|
var visited = new ts.Map();
|
|
20007
20016
|
var toCanonical = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
|
|
20008
20017
|
for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) {
|
|
20009
|
-
var
|
|
20010
|
-
if (directoryExists(
|
|
20011
|
-
visitDirectory(
|
|
20018
|
+
var absoluteBasePath = _a[_i];
|
|
20019
|
+
if (directoryExists(absoluteBasePath)) {
|
|
20020
|
+
visitDirectory(absoluteBasePath, depth);
|
|
20012
20021
|
}
|
|
20013
20022
|
}
|
|
20014
20023
|
return ts.flatten(results);
|
|
20015
|
-
function visitDirectory(
|
|
20024
|
+
function visitDirectory(absolutePath, depth) {
|
|
20016
20025
|
var canonicalPath = toCanonical(realpath(absolutePath));
|
|
20017
20026
|
if (visited.has(canonicalPath))
|
|
20018
20027
|
return;
|
|
20019
20028
|
visited.set(canonicalPath, true);
|
|
20020
|
-
var _a = getFileSystemEntries(
|
|
20029
|
+
var _a = getFileSystemEntries(absolutePath), files = _a.files, directories = _a.directories;
|
|
20021
20030
|
var _loop_1 = function (current) {
|
|
20022
|
-
var name = ts.combinePaths(
|
|
20031
|
+
var name = ts.combinePaths(absolutePath, current);
|
|
20023
20032
|
var absoluteName = ts.combinePaths(absolutePath, current);
|
|
20024
20033
|
if (extensions && !ts.fileExtensionIsOneOf(name, extensions))
|
|
20025
20034
|
return "continue";
|
|
@@ -20047,11 +20056,10 @@ var ts;
|
|
|
20047
20056
|
}
|
|
20048
20057
|
for (var _c = 0, _d = ts.sort(directories, ts.compareStringsCaseSensitive); _c < _d.length; _c++) {
|
|
20049
20058
|
var current = _d[_c];
|
|
20050
|
-
var name = ts.combinePaths(path, current);
|
|
20051
20059
|
var absoluteName = ts.combinePaths(absolutePath, current);
|
|
20052
20060
|
if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) &&
|
|
20053
20061
|
(!excludeRegex || !excludeRegex.test(absoluteName))) {
|
|
20054
|
-
visitDirectory(
|
|
20062
|
+
visitDirectory(absoluteName, depth);
|
|
20055
20063
|
}
|
|
20056
20064
|
}
|
|
20057
20065
|
}
|
|
@@ -20059,10 +20067,11 @@ var ts;
|
|
|
20059
20067
|
ts.matchFiles = matchFiles;
|
|
20060
20068
|
/**
|
|
20061
20069
|
* Computes the unique non-wildcard base paths amongst the provided include patterns.
|
|
20070
|
+
* @returns Absolute directory paths
|
|
20062
20071
|
*/
|
|
20063
|
-
function getBasePaths(
|
|
20072
|
+
function getBasePaths(absoluteTsconfigPath, includes, useCaseSensitiveFileNames) {
|
|
20064
20073
|
// Storage for our results in the form of literal paths (e.g. the paths as written by the user).
|
|
20065
|
-
var basePaths = [
|
|
20074
|
+
var basePaths = [absoluteTsconfigPath];
|
|
20066
20075
|
if (includes) {
|
|
20067
20076
|
// Storage for literal base paths amongst the include patterns.
|
|
20068
20077
|
var includeBasePaths = [];
|
|
@@ -20070,14 +20079,14 @@ var ts;
|
|
|
20070
20079
|
var include = includes_1[_i];
|
|
20071
20080
|
// We also need to check the relative paths by converting them to absolute and normalizing
|
|
20072
20081
|
// in case they escape the base path (e.g "..\somedirectory")
|
|
20073
|
-
var
|
|
20082
|
+
var absoluteIncludePath = ts.isRootedDiskPath(include) ? include : ts.normalizePath(ts.combinePaths(absoluteTsconfigPath, include));
|
|
20074
20083
|
// Append the literal and canonical candidate base paths.
|
|
20075
|
-
includeBasePaths.push(getIncludeBasePath(
|
|
20084
|
+
includeBasePaths.push(getIncludeBasePath(absoluteIncludePath));
|
|
20076
20085
|
}
|
|
20077
20086
|
// Sort the offsets array using either the literal or canonical path representations.
|
|
20078
20087
|
includeBasePaths.sort(ts.getStringComparer(!useCaseSensitiveFileNames));
|
|
20079
20088
|
var _loop_2 = function (includeBasePath) {
|
|
20080
|
-
if (ts.every(basePaths, function (basePath) { return !ts.containsPath(basePath, includeBasePath,
|
|
20089
|
+
if (ts.every(basePaths, function (basePath) { return !ts.containsPath(basePath, includeBasePath, absoluteTsconfigPath, !useCaseSensitiveFileNames); })) {
|
|
20081
20090
|
basePaths.push(includeBasePath);
|
|
20082
20091
|
}
|
|
20083
20092
|
};
|
|
@@ -22897,24 +22906,26 @@ var ts;
|
|
|
22897
22906
|
: node;
|
|
22898
22907
|
}
|
|
22899
22908
|
// @api
|
|
22900
|
-
function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type) {
|
|
22909
|
+
function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members) {
|
|
22901
22910
|
var node = createBaseNode(194 /* MappedType */);
|
|
22902
22911
|
node.readonlyToken = readonlyToken;
|
|
22903
22912
|
node.typeParameter = typeParameter;
|
|
22904
22913
|
node.nameType = nameType;
|
|
22905
22914
|
node.questionToken = questionToken;
|
|
22906
22915
|
node.type = type;
|
|
22916
|
+
node.members = members && createNodeArray(members);
|
|
22907
22917
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
22908
22918
|
return node;
|
|
22909
22919
|
}
|
|
22910
22920
|
// @api
|
|
22911
|
-
function updateMappedTypeNode(node, readonlyToken, typeParameter, nameType, questionToken, type) {
|
|
22921
|
+
function updateMappedTypeNode(node, readonlyToken, typeParameter, nameType, questionToken, type, members) {
|
|
22912
22922
|
return node.readonlyToken !== readonlyToken
|
|
22913
22923
|
|| node.typeParameter !== typeParameter
|
|
22914
22924
|
|| node.nameType !== nameType
|
|
22915
22925
|
|| node.questionToken !== questionToken
|
|
22916
22926
|
|| node.type !== type
|
|
22917
|
-
|
|
22927
|
+
|| node.members !== members
|
|
22928
|
+
? update(createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members), node)
|
|
22918
22929
|
: node;
|
|
22919
22930
|
}
|
|
22920
22931
|
// @api
|
|
@@ -29787,7 +29798,8 @@ var ts;
|
|
|
29787
29798
|
visitNode(cbNode, node.typeParameter) ||
|
|
29788
29799
|
visitNode(cbNode, node.nameType) ||
|
|
29789
29800
|
visitNode(cbNode, node.questionToken) ||
|
|
29790
|
-
visitNode(cbNode, node.type)
|
|
29801
|
+
visitNode(cbNode, node.type) ||
|
|
29802
|
+
visitNodes(cbNode, cbNodes, node.members);
|
|
29791
29803
|
case 195 /* LiteralType */:
|
|
29792
29804
|
return visitNode(cbNode, node.literal);
|
|
29793
29805
|
case 196 /* NamedTupleMember */:
|
|
@@ -32677,8 +32689,9 @@ var ts;
|
|
|
32677
32689
|
}
|
|
32678
32690
|
var type = parseTypeAnnotation();
|
|
32679
32691
|
parseSemicolon();
|
|
32692
|
+
var members = parseList(4 /* TypeMembers */, parseTypeMember);
|
|
32680
32693
|
parseExpected(19 /* CloseBraceToken */);
|
|
32681
|
-
return finishNode(factory.createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type), pos);
|
|
32694
|
+
return finishNode(factory.createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members), pos);
|
|
32682
32695
|
}
|
|
32683
32696
|
function parseTupleElementType() {
|
|
32684
32697
|
var pos = getNodePos();
|
|
@@ -35965,16 +35978,21 @@ var ts;
|
|
|
35965
35978
|
var pos = getNodePos();
|
|
35966
35979
|
parseExpected(129 /* AssertKeyword */);
|
|
35967
35980
|
var openBracePosition = scanner.getTokenPos();
|
|
35968
|
-
parseExpected(18 /* OpenBraceToken */)
|
|
35969
|
-
|
|
35970
|
-
|
|
35971
|
-
|
|
35972
|
-
|
|
35973
|
-
|
|
35974
|
-
|
|
35981
|
+
if (parseExpected(18 /* OpenBraceToken */)) {
|
|
35982
|
+
var multiLine = scanner.hasPrecedingLineBreak();
|
|
35983
|
+
var elements = parseDelimitedList(24 /* AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true);
|
|
35984
|
+
if (!parseExpected(19 /* CloseBraceToken */)) {
|
|
35985
|
+
var lastError = ts.lastOrUndefined(parseDiagnostics);
|
|
35986
|
+
if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
|
|
35987
|
+
ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
|
|
35988
|
+
}
|
|
35975
35989
|
}
|
|
35990
|
+
return finishNode(factory.createAssertClause(elements, multiLine), pos);
|
|
35991
|
+
}
|
|
35992
|
+
else {
|
|
35993
|
+
var elements = createNodeArray([], getNodePos(), /*end*/ undefined, /*hasTrailingComma*/ false);
|
|
35994
|
+
return finishNode(factory.createAssertClause(elements, /*multiLine*/ false), pos);
|
|
35976
35995
|
}
|
|
35977
|
-
return finishNode(factory.createAssertClause(elements, multiLine), pos);
|
|
35978
35996
|
}
|
|
35979
35997
|
function tokenAfterImportDefinitelyProducesImportDeclaration() {
|
|
35980
35998
|
return token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */;
|
|
@@ -36869,8 +36887,9 @@ var ts;
|
|
|
36869
36887
|
return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start);
|
|
36870
36888
|
}
|
|
36871
36889
|
function parseSeeTag(start, tagName, indent, indentText) {
|
|
36872
|
-
var
|
|
36873
|
-
|
|
36890
|
+
var isMarkdownOrJSDocLink = token() === 22 /* OpenBracketToken */
|
|
36891
|
+
|| lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue() === "link"; });
|
|
36892
|
+
var nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference();
|
|
36874
36893
|
var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined;
|
|
36875
36894
|
return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start);
|
|
36876
36895
|
}
|
|
@@ -37959,7 +37978,7 @@ var ts;
|
|
|
37959
37978
|
var ts;
|
|
37960
37979
|
(function (ts) {
|
|
37961
37980
|
/* @internal */
|
|
37962
|
-
ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" };
|
|
37981
|
+
ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean", defaultValueDescription: "false" };
|
|
37963
37982
|
var jsxOptionMap = new ts.Map(ts.getEntries({
|
|
37964
37983
|
"preserve": 1 /* Preserve */,
|
|
37965
37984
|
"react-native": 3 /* ReactNative */,
|
|
@@ -38096,6 +38115,7 @@ var ts;
|
|
|
38096
38115
|
type: "boolean",
|
|
38097
38116
|
category: ts.Diagnostics.Watch_and_Build_Modes,
|
|
38098
38117
|
description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively,
|
|
38118
|
+
defaultValueDescription: "false",
|
|
38099
38119
|
},
|
|
38100
38120
|
{
|
|
38101
38121
|
name: "excludeDirectories",
|
|
@@ -38131,11 +38151,13 @@ var ts;
|
|
|
38131
38151
|
showInSimplifiedHelpView: true,
|
|
38132
38152
|
category: ts.Diagnostics.Command_line_Options,
|
|
38133
38153
|
description: ts.Diagnostics.Print_this_message,
|
|
38154
|
+
defaultValueDescription: "false",
|
|
38134
38155
|
},
|
|
38135
38156
|
{
|
|
38136
38157
|
name: "help",
|
|
38137
38158
|
shortName: "?",
|
|
38138
|
-
type: "boolean"
|
|
38159
|
+
type: "boolean",
|
|
38160
|
+
defaultValueDescription: "false",
|
|
38139
38161
|
},
|
|
38140
38162
|
{
|
|
38141
38163
|
name: "watch",
|
|
@@ -38145,6 +38167,7 @@ var ts;
|
|
|
38145
38167
|
isCommandLineOnly: true,
|
|
38146
38168
|
category: ts.Diagnostics.Command_line_Options,
|
|
38147
38169
|
description: ts.Diagnostics.Watch_input_files,
|
|
38170
|
+
defaultValueDescription: "false",
|
|
38148
38171
|
},
|
|
38149
38172
|
{
|
|
38150
38173
|
name: "preserveWatchOutput",
|
|
@@ -38152,7 +38175,7 @@ var ts;
|
|
|
38152
38175
|
showInSimplifiedHelpView: false,
|
|
38153
38176
|
category: ts.Diagnostics.Output_Formatting,
|
|
38154
38177
|
description: ts.Diagnostics.Disable_wiping_the_console_in_watch_mode,
|
|
38155
|
-
defaultValueDescription: "
|
|
38178
|
+
defaultValueDescription: "false",
|
|
38156
38179
|
},
|
|
38157
38180
|
{
|
|
38158
38181
|
name: "listFiles",
|
|
@@ -38165,7 +38188,8 @@ var ts;
|
|
|
38165
38188
|
name: "explainFiles",
|
|
38166
38189
|
type: "boolean",
|
|
38167
38190
|
category: ts.Diagnostics.Compiler_Diagnostics,
|
|
38168
|
-
description: ts.Diagnostics.Print_files_read_during_the_compilation_including_why_it_was_included
|
|
38191
|
+
description: ts.Diagnostics.Print_files_read_during_the_compilation_including_why_it_was_included,
|
|
38192
|
+
defaultValueDescription: "false",
|
|
38169
38193
|
},
|
|
38170
38194
|
{
|
|
38171
38195
|
name: "listEmittedFiles",
|
|
@@ -38236,7 +38260,8 @@ var ts;
|
|
|
38236
38260
|
affectsSemanticDiagnostics: true,
|
|
38237
38261
|
affectsEmit: true,
|
|
38238
38262
|
category: ts.Diagnostics.Watch_and_Build_Modes,
|
|
38239
|
-
description: ts.Diagnostics.Have_recompiles_in_projects_that_use_incremental_and_watch_mode_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it
|
|
38263
|
+
description: ts.Diagnostics.Have_recompiles_in_projects_that_use_incremental_and_watch_mode_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it,
|
|
38264
|
+
defaultValueDescription: "false",
|
|
38240
38265
|
},
|
|
38241
38266
|
{
|
|
38242
38267
|
name: "locale",
|
|
@@ -38281,6 +38306,7 @@ var ts;
|
|
|
38281
38306
|
showInSimplifiedHelpView: true,
|
|
38282
38307
|
category: ts.Diagnostics.Command_line_Options,
|
|
38283
38308
|
description: ts.Diagnostics.Show_all_compiler_options,
|
|
38309
|
+
defaultValueDescription: "false",
|
|
38284
38310
|
},
|
|
38285
38311
|
{
|
|
38286
38312
|
name: "version",
|
|
@@ -38289,6 +38315,7 @@ var ts;
|
|
|
38289
38315
|
showInSimplifiedHelpView: true,
|
|
38290
38316
|
category: ts.Diagnostics.Command_line_Options,
|
|
38291
38317
|
description: ts.Diagnostics.Print_the_compiler_s_version,
|
|
38318
|
+
defaultValueDescription: "false",
|
|
38292
38319
|
},
|
|
38293
38320
|
{
|
|
38294
38321
|
name: "init",
|
|
@@ -38296,6 +38323,7 @@ var ts;
|
|
|
38296
38323
|
showInSimplifiedHelpView: true,
|
|
38297
38324
|
category: ts.Diagnostics.Command_line_Options,
|
|
38298
38325
|
description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file,
|
|
38326
|
+
defaultValueDescription: "false",
|
|
38299
38327
|
},
|
|
38300
38328
|
{
|
|
38301
38329
|
name: "project",
|
|
@@ -38313,7 +38341,8 @@ var ts;
|
|
|
38313
38341
|
shortName: "b",
|
|
38314
38342
|
showInSimplifiedHelpView: true,
|
|
38315
38343
|
category: ts.Diagnostics.Command_line_Options,
|
|
38316
|
-
description: ts.Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date
|
|
38344
|
+
description: ts.Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date,
|
|
38345
|
+
defaultValueDescription: "false",
|
|
38317
38346
|
},
|
|
38318
38347
|
{
|
|
38319
38348
|
name: "showConfig",
|
|
@@ -38321,7 +38350,8 @@ var ts;
|
|
|
38321
38350
|
showInSimplifiedHelpView: true,
|
|
38322
38351
|
category: ts.Diagnostics.Command_line_Options,
|
|
38323
38352
|
isCommandLineOnly: true,
|
|
38324
|
-
description: ts.Diagnostics.Print_the_final_configuration_instead_of_building
|
|
38353
|
+
description: ts.Diagnostics.Print_the_final_configuration_instead_of_building,
|
|
38354
|
+
defaultValueDescription: "false",
|
|
38325
38355
|
},
|
|
38326
38356
|
{
|
|
38327
38357
|
name: "listFilesOnly",
|
|
@@ -38330,7 +38360,8 @@ var ts;
|
|
|
38330
38360
|
affectsSemanticDiagnostics: true,
|
|
38331
38361
|
affectsEmit: true,
|
|
38332
38362
|
isCommandLineOnly: true,
|
|
38333
|
-
description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing
|
|
38363
|
+
description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing,
|
|
38364
|
+
defaultValueDescription: "false",
|
|
38334
38365
|
},
|
|
38335
38366
|
// Basic
|
|
38336
38367
|
ts.targetOptionDeclaration,
|
|
@@ -38450,7 +38481,6 @@ var ts;
|
|
|
38450
38481
|
category: ts.Diagnostics.Emit,
|
|
38451
38482
|
description: ts.Diagnostics.Specify_a_file_that_bundles_all_outputs_into_one_JavaScript_file_If_declaration_is_true_also_designates_a_file_that_bundles_all_d_ts_output,
|
|
38452
38483
|
transpileOptionValue: undefined,
|
|
38453
|
-
defaultValueDescription: "n/a"
|
|
38454
38484
|
},
|
|
38455
38485
|
{
|
|
38456
38486
|
name: "outDir",
|
|
@@ -38461,7 +38491,6 @@ var ts;
|
|
|
38461
38491
|
showInSimplifiedHelpView: true,
|
|
38462
38492
|
category: ts.Diagnostics.Emit,
|
|
38463
38493
|
description: ts.Diagnostics.Specify_an_output_folder_for_all_emitted_files,
|
|
38464
|
-
defaultValueDescription: "n/a"
|
|
38465
38494
|
},
|
|
38466
38495
|
{
|
|
38467
38496
|
name: "rootDir",
|
|
@@ -38618,6 +38647,7 @@ var ts;
|
|
|
38618
38647
|
strictFlag: true,
|
|
38619
38648
|
category: ts.Diagnostics.Type_Checking,
|
|
38620
38649
|
description: ts.Diagnostics.Type_catch_clause_variables_as_unknown_instead_of_any,
|
|
38650
|
+
defaultValueDescription: "false",
|
|
38621
38651
|
},
|
|
38622
38652
|
{
|
|
38623
38653
|
name: "alwaysStrict",
|
|
@@ -38650,7 +38680,8 @@ var ts;
|
|
|
38650
38680
|
type: "boolean",
|
|
38651
38681
|
affectsSemanticDiagnostics: true,
|
|
38652
38682
|
category: ts.Diagnostics.Type_Checking,
|
|
38653
|
-
description: ts.Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined
|
|
38683
|
+
description: ts.Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined,
|
|
38684
|
+
defaultValueDescription: "false",
|
|
38654
38685
|
},
|
|
38655
38686
|
{
|
|
38656
38687
|
name: "noImplicitReturns",
|
|
@@ -38666,21 +38697,24 @@ var ts;
|
|
|
38666
38697
|
affectsBindDiagnostics: true,
|
|
38667
38698
|
affectsSemanticDiagnostics: true,
|
|
38668
38699
|
category: ts.Diagnostics.Type_Checking,
|
|
38669
|
-
description: ts.Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements
|
|
38700
|
+
description: ts.Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements,
|
|
38701
|
+
defaultValueDescription: "false",
|
|
38670
38702
|
},
|
|
38671
38703
|
{
|
|
38672
38704
|
name: "noUncheckedIndexedAccess",
|
|
38673
38705
|
type: "boolean",
|
|
38674
38706
|
affectsSemanticDiagnostics: true,
|
|
38675
38707
|
category: ts.Diagnostics.Type_Checking,
|
|
38676
|
-
description: ts.Diagnostics.Include_undefined_in_index_signature_results
|
|
38708
|
+
description: ts.Diagnostics.Include_undefined_in_index_signature_results,
|
|
38709
|
+
defaultValueDescription: "false",
|
|
38677
38710
|
},
|
|
38678
38711
|
{
|
|
38679
38712
|
name: "noImplicitOverride",
|
|
38680
38713
|
type: "boolean",
|
|
38681
38714
|
affectsSemanticDiagnostics: true,
|
|
38682
38715
|
category: ts.Diagnostics.Type_Checking,
|
|
38683
|
-
description: ts.Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier
|
|
38716
|
+
description: ts.Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier,
|
|
38717
|
+
defaultValueDescription: "false",
|
|
38684
38718
|
},
|
|
38685
38719
|
{
|
|
38686
38720
|
name: "noPropertyAccessFromIndexSignature",
|
|
@@ -38789,7 +38823,7 @@ var ts;
|
|
|
38789
38823
|
type: "boolean",
|
|
38790
38824
|
category: ts.Diagnostics.Interop_Constraints,
|
|
38791
38825
|
description: ts.Diagnostics.Disable_resolving_symlinks_to_their_realpath_This_correlates_to_the_same_flag_in_node,
|
|
38792
|
-
defaultValueDescription: "
|
|
38826
|
+
defaultValueDescription: "false",
|
|
38793
38827
|
},
|
|
38794
38828
|
{
|
|
38795
38829
|
name: "allowUmdGlobalAccess",
|
|
@@ -38838,7 +38872,8 @@ var ts;
|
|
|
38838
38872
|
type: "boolean",
|
|
38839
38873
|
affectsSemanticDiagnostics: true,
|
|
38840
38874
|
category: ts.Diagnostics.Language_and_Environment,
|
|
38841
|
-
description: ts.Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators
|
|
38875
|
+
description: ts.Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators,
|
|
38876
|
+
defaultValueDescription: "false",
|
|
38842
38877
|
},
|
|
38843
38878
|
{
|
|
38844
38879
|
name: "emitDecoratorMetadata",
|
|
@@ -38846,7 +38881,8 @@ var ts;
|
|
|
38846
38881
|
affectsSemanticDiagnostics: true,
|
|
38847
38882
|
affectsEmit: true,
|
|
38848
38883
|
category: ts.Diagnostics.Language_and_Environment,
|
|
38849
|
-
description: ts.Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files
|
|
38884
|
+
description: ts.Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files,
|
|
38885
|
+
defaultValueDescription: "false",
|
|
38850
38886
|
},
|
|
38851
38887
|
// Advanced
|
|
38852
38888
|
{
|
|
@@ -38889,7 +38925,6 @@ var ts;
|
|
|
38889
38925
|
category: ts.Diagnostics.Backwards_Compatibility,
|
|
38890
38926
|
paramType: ts.Diagnostics.FILE,
|
|
38891
38927
|
transpileOptionValue: undefined,
|
|
38892
|
-
defaultValueDescription: "n/a",
|
|
38893
38928
|
description: ts.Diagnostics.Deprecated_setting_Use_outFile_instead,
|
|
38894
38929
|
},
|
|
38895
38930
|
{
|
|
@@ -38970,6 +39005,7 @@ var ts;
|
|
|
38970
39005
|
affectsEmit: true,
|
|
38971
39006
|
category: ts.Diagnostics.Emit,
|
|
38972
39007
|
description: ts.Diagnostics.Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments,
|
|
39008
|
+
defaultValueDescription: "false",
|
|
38973
39009
|
},
|
|
38974
39010
|
{
|
|
38975
39011
|
name: "disableSizeLimit",
|
|
@@ -38984,21 +39020,24 @@ var ts;
|
|
|
38984
39020
|
type: "boolean",
|
|
38985
39021
|
isTSConfigOnly: true,
|
|
38986
39022
|
category: ts.Diagnostics.Projects,
|
|
38987
|
-
description: ts.Diagnostics.Disable_preferring_source_files_instead_of_declaration_files_when_referencing_composite_projects
|
|
39023
|
+
description: ts.Diagnostics.Disable_preferring_source_files_instead_of_declaration_files_when_referencing_composite_projects,
|
|
39024
|
+
defaultValueDescription: "false",
|
|
38988
39025
|
},
|
|
38989
39026
|
{
|
|
38990
39027
|
name: "disableSolutionSearching",
|
|
38991
39028
|
type: "boolean",
|
|
38992
39029
|
isTSConfigOnly: true,
|
|
38993
39030
|
category: ts.Diagnostics.Projects,
|
|
38994
|
-
description: ts.Diagnostics.Opt_a_project_out_of_multi_project_reference_checking_when_editing
|
|
39031
|
+
description: ts.Diagnostics.Opt_a_project_out_of_multi_project_reference_checking_when_editing,
|
|
39032
|
+
defaultValueDescription: "false",
|
|
38995
39033
|
},
|
|
38996
39034
|
{
|
|
38997
39035
|
name: "disableReferencedProjectLoad",
|
|
38998
39036
|
type: "boolean",
|
|
38999
39037
|
isTSConfigOnly: true,
|
|
39000
39038
|
category: ts.Diagnostics.Projects,
|
|
39001
|
-
description: ts.Diagnostics.Reduce_the_number_of_projects_loaded_automatically_by_TypeScript
|
|
39039
|
+
description: ts.Diagnostics.Reduce_the_number_of_projects_loaded_automatically_by_TypeScript,
|
|
39040
|
+
defaultValueDescription: "false",
|
|
39002
39041
|
},
|
|
39003
39042
|
{
|
|
39004
39043
|
name: "noImplicitUseStrict",
|
|
@@ -39031,7 +39070,7 @@ var ts;
|
|
|
39031
39070
|
affectsEmit: true,
|
|
39032
39071
|
category: ts.Diagnostics.Emit,
|
|
39033
39072
|
description: ts.Diagnostics.Disable_erasing_const_enum_declarations_in_generated_code,
|
|
39034
|
-
defaultValueDescription: "
|
|
39073
|
+
defaultValueDescription: "false",
|
|
39035
39074
|
},
|
|
39036
39075
|
{
|
|
39037
39076
|
name: "declarationDir",
|
|
@@ -39042,7 +39081,6 @@ var ts;
|
|
|
39042
39081
|
category: ts.Diagnostics.Emit,
|
|
39043
39082
|
transpileOptionValue: undefined,
|
|
39044
39083
|
description: ts.Diagnostics.Specify_the_output_directory_for_generated_declaration_files,
|
|
39045
|
-
defaultValueDescription: "n/a"
|
|
39046
39084
|
},
|
|
39047
39085
|
{
|
|
39048
39086
|
name: "skipLibCheck",
|
|
@@ -39124,6 +39162,7 @@ var ts;
|
|
|
39124
39162
|
affectsEmit: true,
|
|
39125
39163
|
category: ts.Diagnostics.Emit,
|
|
39126
39164
|
description: ts.Diagnostics.Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed,
|
|
39165
|
+
defaultValueDescription: "false",
|
|
39127
39166
|
},
|
|
39128
39167
|
{
|
|
39129
39168
|
name: "keyofStringsOnly",
|
|
@@ -39171,27 +39210,31 @@ var ts;
|
|
|
39171
39210
|
shortName: "v",
|
|
39172
39211
|
category: ts.Diagnostics.Command_line_Options,
|
|
39173
39212
|
description: ts.Diagnostics.Enable_verbose_logging,
|
|
39174
|
-
type: "boolean"
|
|
39213
|
+
type: "boolean",
|
|
39214
|
+
defaultValueDescription: "false",
|
|
39175
39215
|
},
|
|
39176
39216
|
{
|
|
39177
39217
|
name: "dry",
|
|
39178
39218
|
shortName: "d",
|
|
39179
39219
|
category: ts.Diagnostics.Command_line_Options,
|
|
39180
39220
|
description: ts.Diagnostics.Show_what_would_be_built_or_deleted_if_specified_with_clean,
|
|
39181
|
-
type: "boolean"
|
|
39221
|
+
type: "boolean",
|
|
39222
|
+
defaultValueDescription: "false",
|
|
39182
39223
|
},
|
|
39183
39224
|
{
|
|
39184
39225
|
name: "force",
|
|
39185
39226
|
shortName: "f",
|
|
39186
39227
|
category: ts.Diagnostics.Command_line_Options,
|
|
39187
39228
|
description: ts.Diagnostics.Build_all_projects_including_those_that_appear_to_be_up_to_date,
|
|
39188
|
-
type: "boolean"
|
|
39229
|
+
type: "boolean",
|
|
39230
|
+
defaultValueDescription: "false",
|
|
39189
39231
|
},
|
|
39190
39232
|
{
|
|
39191
39233
|
name: "clean",
|
|
39192
39234
|
category: ts.Diagnostics.Command_line_Options,
|
|
39193
39235
|
description: ts.Diagnostics.Delete_the_outputs_of_all_projects,
|
|
39194
|
-
type: "boolean"
|
|
39236
|
+
type: "boolean",
|
|
39237
|
+
defaultValueDescription: "false",
|
|
39195
39238
|
}
|
|
39196
39239
|
];
|
|
39197
39240
|
/* @internal */
|
|
@@ -39204,10 +39247,12 @@ var ts;
|
|
|
39204
39247
|
*/
|
|
39205
39248
|
name: "enableAutoDiscovery",
|
|
39206
39249
|
type: "boolean",
|
|
39250
|
+
defaultValueDescription: "false",
|
|
39207
39251
|
},
|
|
39208
39252
|
{
|
|
39209
39253
|
name: "enable",
|
|
39210
39254
|
type: "boolean",
|
|
39255
|
+
defaultValueDescription: "false",
|
|
39211
39256
|
},
|
|
39212
39257
|
{
|
|
39213
39258
|
name: "include",
|
|
@@ -39228,6 +39273,7 @@ var ts;
|
|
|
39228
39273
|
{
|
|
39229
39274
|
name: "disableFilenameBasedTypeAcquisition",
|
|
39230
39275
|
type: "boolean",
|
|
39276
|
+
defaultValueDescription: "false",
|
|
39231
39277
|
},
|
|
39232
39278
|
];
|
|
39233
39279
|
/*@internal*/
|
|
@@ -49493,7 +49539,8 @@ var ts;
|
|
|
49493
49539
|
((_d = ts.findAncestor(location, ts.isExportDeclaration)) === null || _d === void 0 ? void 0 : _d.moduleSpecifier) ||
|
|
49494
49540
|
((_e = (ts.isModuleDeclaration(location) ? location : location.parent && ts.isModuleDeclaration(location.parent) && location.parent.name === location ? location.parent : undefined)) === null || _e === void 0 ? void 0 : _e.name) ||
|
|
49495
49541
|
((_f = (ts.isLiteralImportTypeNode(location) ? location : undefined)) === null || _f === void 0 ? void 0 : _f.argument.literal);
|
|
49496
|
-
var
|
|
49542
|
+
var mode = contextSpecifier && ts.isStringLiteralLike(contextSpecifier) ? ts.getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
|
|
49543
|
+
var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference, mode); // TODO: GH#18217
|
|
49497
49544
|
var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule);
|
|
49498
49545
|
var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
|
|
49499
49546
|
if (sourceFile) {
|
|
@@ -50919,7 +50966,7 @@ var ts;
|
|
|
50919
50966
|
var typeParameterNode = typeParameterToDeclarationWithConstraint(getTypeParameterFromMappedType(type), context, appropriateConstraintTypeNode);
|
|
50920
50967
|
var nameTypeNode = type.declaration.nameType ? typeToTypeNodeHelper(getNameTypeFromMappedType(type), context) : undefined;
|
|
50921
50968
|
var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), context);
|
|
50922
|
-
var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode);
|
|
50969
|
+
var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined);
|
|
50923
50970
|
context.approximateLength += 10;
|
|
50924
50971
|
return ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */);
|
|
50925
50972
|
}
|
|
@@ -57813,7 +57860,7 @@ var ts;
|
|
|
57813
57860
|
return false;
|
|
57814
57861
|
switch (node.kind) {
|
|
57815
57862
|
case 79 /* Identifier */:
|
|
57816
|
-
return node.escapedText === argumentsSymbol.escapedName &&
|
|
57863
|
+
return node.escapedText === argumentsSymbol.escapedName && getReferencedValueSymbol(node) === argumentsSymbol;
|
|
57817
57864
|
case 166 /* PropertyDeclaration */:
|
|
57818
57865
|
case 168 /* MethodDeclaration */:
|
|
57819
57866
|
case 171 /* GetAccessor */:
|
|
@@ -60352,12 +60399,6 @@ var ts;
|
|
|
60352
60399
|
}
|
|
60353
60400
|
return type[cache] = type;
|
|
60354
60401
|
}
|
|
60355
|
-
function isConditionalTypeAlwaysTrueDisregardingInferTypes(type) {
|
|
60356
|
-
var extendsInferParamMapper = type.root.inferTypeParameters && createTypeMapper(type.root.inferTypeParameters, ts.map(type.root.inferTypeParameters, function () { return wildcardType; }));
|
|
60357
|
-
var checkType = type.checkType;
|
|
60358
|
-
var extendsType = type.extendsType;
|
|
60359
|
-
return isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(instantiateType(extendsType, extendsInferParamMapper)));
|
|
60360
|
-
}
|
|
60361
60402
|
function getSimplifiedConditionalType(type, writing) {
|
|
60362
60403
|
var checkType = type.checkType;
|
|
60363
60404
|
var extendsType = type.extendsType;
|
|
@@ -60666,6 +60707,10 @@ var ts;
|
|
|
60666
60707
|
}
|
|
60667
60708
|
return result;
|
|
60668
60709
|
}
|
|
60710
|
+
function isDistributionDependent(root) {
|
|
60711
|
+
return root.isDistributive && (isTypeParameterPossiblyReferenced(root.checkType, root.node.trueType) ||
|
|
60712
|
+
isTypeParameterPossiblyReferenced(root.checkType, root.node.falseType));
|
|
60713
|
+
}
|
|
60669
60714
|
function getTypeFromConditionalTypeNode(node) {
|
|
60670
60715
|
var links = getNodeLinks(node);
|
|
60671
60716
|
if (!links.resolvedType) {
|
|
@@ -63815,32 +63860,28 @@ var ts;
|
|
|
63815
63860
|
}
|
|
63816
63861
|
}
|
|
63817
63862
|
else if (target.flags & 16777216 /* Conditional */) {
|
|
63818
|
-
|
|
63819
|
-
//
|
|
63820
|
-
|
|
63821
|
-
var skipFalse = !skipTrue && isConditionalTypeAlwaysTrueDisregardingInferTypes(c);
|
|
63822
|
-
// Instantiate with a replacement mapper if the conditional is distributive, replacing the check type with a clone of itself,
|
|
63823
|
-
// this way {x: string | number, y: string | number} -> (T extends T ? { x: T, y: T } : never) appropriately _fails_ when
|
|
63824
|
-
// T = string | number (since that will end up distributing and producing `{x: string, y: string} | {x: number, y: number}`,
|
|
63825
|
-
// to which `{x: string | number, y: string | number}` isn't assignable)
|
|
63826
|
-
var distributionMapper = void 0;
|
|
63827
|
-
var checkVar = getActualTypeVariable(c.root.checkType);
|
|
63828
|
-
if (c.root.isDistributive && checkVar.flags & 262144 /* TypeParameter */) {
|
|
63829
|
-
var newParam = cloneTypeParameter(checkVar);
|
|
63830
|
-
distributionMapper = prependTypeMapping(checkVar, newParam, c.mapper);
|
|
63831
|
-
newParam.mapper = distributionMapper;
|
|
63832
|
-
}
|
|
63833
|
-
// TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't)
|
|
63834
|
-
var expanding = isDeeplyNestedType(target, targetStack, targetDepth);
|
|
63835
|
-
var localResult = expanding ? 3 /* Maybe */ : undefined;
|
|
63836
|
-
if (skipTrue || expanding || (localResult = isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.trueType), distributionMapper) : getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false))) {
|
|
63837
|
-
if (!skipFalse && !expanding) {
|
|
63838
|
-
localResult = (localResult || 3 /* Maybe */) & isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.falseType), distributionMapper) : getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false);
|
|
63839
|
-
}
|
|
63840
|
-
}
|
|
63841
|
-
if (localResult) {
|
|
63863
|
+
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
63864
|
+
// conditional type and bail out with a Ternary.Maybe result.
|
|
63865
|
+
if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) {
|
|
63842
63866
|
resetErrorInfo(saveErrorInfo);
|
|
63843
|
-
return
|
|
63867
|
+
return 3 /* Maybe */;
|
|
63868
|
+
}
|
|
63869
|
+
var c = target;
|
|
63870
|
+
// We check for a relationship to a conditional type target only when the conditional type has no
|
|
63871
|
+
// 'infer' positions and is not distributive or is distributive but doesn't reference the check type
|
|
63872
|
+
// parameter in either of the result types.
|
|
63873
|
+
if (!c.root.inferTypeParameters && !isDistributionDependent(c.root)) {
|
|
63874
|
+
// Check if the conditional is always true or always false but still deferred for distribution purposes.
|
|
63875
|
+
var skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType));
|
|
63876
|
+
var skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType));
|
|
63877
|
+
// TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't)
|
|
63878
|
+
if (result = skipTrue ? -1 /* True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false)) {
|
|
63879
|
+
result &= skipFalse ? -1 /* True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false);
|
|
63880
|
+
if (result) {
|
|
63881
|
+
resetErrorInfo(saveErrorInfo);
|
|
63882
|
+
return result;
|
|
63883
|
+
}
|
|
63884
|
+
}
|
|
63844
63885
|
}
|
|
63845
63886
|
}
|
|
63846
63887
|
else if (target.flags & 134217728 /* TemplateLiteral */) {
|
|
@@ -63911,33 +63952,34 @@ var ts;
|
|
|
63911
63952
|
}
|
|
63912
63953
|
}
|
|
63913
63954
|
else if (source.flags & 16777216 /* Conditional */) {
|
|
63955
|
+
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
63956
|
+
// conditional type and bail out with a Ternary.Maybe result.
|
|
63957
|
+
if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) {
|
|
63958
|
+
resetErrorInfo(saveErrorInfo);
|
|
63959
|
+
return 3 /* Maybe */;
|
|
63960
|
+
}
|
|
63914
63961
|
if (target.flags & 16777216 /* Conditional */) {
|
|
63915
|
-
//
|
|
63916
|
-
//
|
|
63917
|
-
//
|
|
63918
|
-
|
|
63919
|
-
|
|
63920
|
-
|
|
63921
|
-
|
|
63922
|
-
|
|
63923
|
-
var
|
|
63924
|
-
|
|
63925
|
-
|
|
63926
|
-
|
|
63927
|
-
|
|
63928
|
-
|
|
63929
|
-
|
|
63930
|
-
|
|
63931
|
-
|
|
63932
|
-
|
|
63933
|
-
|
|
63934
|
-
|
|
63935
|
-
|
|
63936
|
-
}
|
|
63937
|
-
if (result) {
|
|
63938
|
-
resetErrorInfo(saveErrorInfo);
|
|
63939
|
-
return result;
|
|
63940
|
-
}
|
|
63962
|
+
// Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if
|
|
63963
|
+
// one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2,
|
|
63964
|
+
// and Y1 is related to Y2.
|
|
63965
|
+
var sourceParams = source.root.inferTypeParameters;
|
|
63966
|
+
var sourceExtends = source.extendsType;
|
|
63967
|
+
var mapper = void 0;
|
|
63968
|
+
if (sourceParams) {
|
|
63969
|
+
// If the source has infer type parameters, we instantiate them in the context of the target
|
|
63970
|
+
var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedToWorker);
|
|
63971
|
+
inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
|
|
63972
|
+
sourceExtends = instantiateType(sourceExtends, ctx.mapper);
|
|
63973
|
+
mapper = ctx.mapper;
|
|
63974
|
+
}
|
|
63975
|
+
if (isTypeIdenticalTo(sourceExtends, target.extendsType) &&
|
|
63976
|
+
(isRelatedTo(source.checkType, target.checkType, 3 /* Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* Both */))) {
|
|
63977
|
+
if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* Both */, reportErrors)) {
|
|
63978
|
+
result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors);
|
|
63979
|
+
}
|
|
63980
|
+
if (result) {
|
|
63981
|
+
resetErrorInfo(saveErrorInfo);
|
|
63982
|
+
return result;
|
|
63941
63983
|
}
|
|
63942
63984
|
}
|
|
63943
63985
|
}
|
|
@@ -63952,17 +63994,13 @@ var ts;
|
|
|
63952
63994
|
}
|
|
63953
63995
|
}
|
|
63954
63996
|
}
|
|
63955
|
-
//
|
|
63956
|
-
//
|
|
63957
|
-
|
|
63958
|
-
|
|
63959
|
-
|
|
63960
|
-
|
|
63961
|
-
|
|
63962
|
-
if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) {
|
|
63963
|
-
resetErrorInfo(saveErrorInfo);
|
|
63964
|
-
return result;
|
|
63965
|
-
}
|
|
63997
|
+
// conditionals _can_ be related to one another via normal constraint, as, eg, `A extends B ? O : never` should be assignable to `O`
|
|
63998
|
+
// when `O` is a conditional (`never` is trivially assignable to `O`, as is `O`!).
|
|
63999
|
+
var defaultConstraint = getDefaultConstraintOfConditionalType(source);
|
|
64000
|
+
if (defaultConstraint) {
|
|
64001
|
+
if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) {
|
|
64002
|
+
resetErrorInfo(saveErrorInfo);
|
|
64003
|
+
return result;
|
|
63966
64004
|
}
|
|
63967
64005
|
}
|
|
63968
64006
|
}
|
|
@@ -65071,14 +65109,15 @@ var ts;
|
|
|
65071
65109
|
// `type A<T> = null extends T ? [A<NonNullable<T>>] : [T]`
|
|
65072
65110
|
// has expanded into `[A<NonNullable<NonNullable<NonNullable<NonNullable<NonNullable<T>>>>>>]`
|
|
65073
65111
|
// in such cases we need to terminate the expansion, and we do so here.
|
|
65074
|
-
function isDeeplyNestedType(type, stack, depth) {
|
|
65075
|
-
if (
|
|
65112
|
+
function isDeeplyNestedType(type, stack, depth, maxDepth) {
|
|
65113
|
+
if (maxDepth === void 0) { maxDepth = 5; }
|
|
65114
|
+
if (depth >= maxDepth) {
|
|
65076
65115
|
var identity_1 = getRecursionIdentity(type);
|
|
65077
65116
|
var count = 0;
|
|
65078
65117
|
for (var i = 0; i < depth; i++) {
|
|
65079
65118
|
if (getRecursionIdentity(stack[i]) === identity_1) {
|
|
65080
65119
|
count++;
|
|
65081
|
-
if (count >=
|
|
65120
|
+
if (count >= maxDepth) {
|
|
65082
65121
|
return true;
|
|
65083
65122
|
}
|
|
65084
65123
|
}
|
|
@@ -66989,17 +67028,16 @@ var ts;
|
|
|
66989
67028
|
var inferredType = void 0;
|
|
66990
67029
|
var signature = context.signature;
|
|
66991
67030
|
if (signature) {
|
|
66992
|
-
var
|
|
67031
|
+
var inferredCovariantType_1 = inference.candidates ? getCovariantInference(inference, signature) : undefined;
|
|
66993
67032
|
if (inference.contraCandidates) {
|
|
66994
|
-
var inferredContravariantType = getContravariantInference(inference);
|
|
66995
67033
|
// If we have both co- and contra-variant inferences, we prefer the contra-variant inference
|
|
66996
|
-
// unless the co-variant inference is a subtype and not 'never'.
|
|
66997
|
-
inferredType =
|
|
66998
|
-
isTypeSubtypeOf(
|
|
66999
|
-
|
|
67034
|
+
// unless the co-variant inference is a subtype of some contra-variant inference and not 'never'.
|
|
67035
|
+
inferredType = inferredCovariantType_1 && !(inferredCovariantType_1.flags & 131072 /* Never */) &&
|
|
67036
|
+
ts.some(inference.contraCandidates, function (t) { return isTypeSubtypeOf(inferredCovariantType_1, t); }) ?
|
|
67037
|
+
inferredCovariantType_1 : getContravariantInference(inference);
|
|
67000
67038
|
}
|
|
67001
|
-
else if (
|
|
67002
|
-
inferredType =
|
|
67039
|
+
else if (inferredCovariantType_1) {
|
|
67040
|
+
inferredType = inferredCovariantType_1;
|
|
67003
67041
|
}
|
|
67004
67042
|
else if (context.flags & 1 /* NoDefault */) {
|
|
67005
67043
|
// We use silentNeverType as the wildcard that signals no inferences.
|
|
@@ -67298,8 +67336,9 @@ var ts;
|
|
|
67298
67336
|
// constituent types keyed by the literal types of the property by that name in each constituent type.
|
|
67299
67337
|
function getKeyPropertyName(unionType) {
|
|
67300
67338
|
var types = unionType.types;
|
|
67301
|
-
// We only construct maps for
|
|
67302
|
-
if (types.length < 10 || ts.getObjectFlags(unionType) & 65536 /* PrimitiveUnion */
|
|
67339
|
+
// We only construct maps for unions with many non-primitive constituents.
|
|
67340
|
+
if (types.length < 10 || ts.getObjectFlags(unionType) & 65536 /* PrimitiveUnion */ ||
|
|
67341
|
+
ts.countWhere(types, function (t) { return !!(t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */)); }) < 10) {
|
|
67303
67342
|
return undefined;
|
|
67304
67343
|
}
|
|
67305
67344
|
if (unionType.keyPropertyName === undefined) {
|
|
@@ -67332,7 +67371,7 @@ var ts;
|
|
|
67332
67371
|
var keyPropertyName = getKeyPropertyName(unionType);
|
|
67333
67372
|
var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 294 /* PropertyAssignment */ &&
|
|
67334
67373
|
p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer); });
|
|
67335
|
-
var propType = propNode &&
|
|
67374
|
+
var propType = propNode && getContextFreeTypeOfExpression(propNode.initializer);
|
|
67336
67375
|
return propType && getConstituentTypeForKeyType(unionType, propType);
|
|
67337
67376
|
}
|
|
67338
67377
|
function isOrContainsMatchingReference(source, target) {
|
|
@@ -70567,7 +70606,7 @@ var ts;
|
|
|
70567
70606
|
return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 294 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType);
|
|
70568
70607
|
}
|
|
70569
70608
|
function discriminateContextualTypeByJSXAttributes(node, contextualType) {
|
|
70570
|
-
return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 284 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return
|
|
70609
|
+
return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 284 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType);
|
|
70571
70610
|
}
|
|
70572
70611
|
// Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily
|
|
70573
70612
|
// be "pushed" onto a node using the contextualType property.
|
|
@@ -71122,6 +71161,10 @@ var ts;
|
|
|
71122
71161
|
function checkComputedPropertyName(node) {
|
|
71123
71162
|
var links = getNodeLinks(node.expression);
|
|
71124
71163
|
if (!links.resolvedType) {
|
|
71164
|
+
if ((ts.isTypeLiteralNode(node.parent.parent) || ts.isClassLike(node.parent.parent) || ts.isInterfaceDeclaration(node.parent.parent))
|
|
71165
|
+
&& ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */) {
|
|
71166
|
+
return links.resolvedType = errorType;
|
|
71167
|
+
}
|
|
71125
71168
|
links.resolvedType = checkExpression(node.expression);
|
|
71126
71169
|
// The computed property name of a non-static class field within a loop must be stored in a block-scoped binding.
|
|
71127
71170
|
// (It needs to be bound at class evaluation time.)
|
|
@@ -72591,7 +72634,7 @@ var ts;
|
|
|
72591
72634
|
if (relatedInfo) {
|
|
72592
72635
|
ts.addRelatedInfo(resultDiagnostic, relatedInfo);
|
|
72593
72636
|
}
|
|
72594
|
-
addErrorOrSuggestion(!isUncheckedJS, resultDiagnostic);
|
|
72637
|
+
addErrorOrSuggestion(!isUncheckedJS || errorInfo.code !== ts.Diagnostics.Property_0_may_not_exist_on_type_1_Did_you_mean_2.code, resultDiagnostic);
|
|
72595
72638
|
}
|
|
72596
72639
|
function containerSeemsToBeEmptyDomElement(containingType) {
|
|
72597
72640
|
return (compilerOptions.lib && !compilerOptions.lib.includes("dom")) &&
|
|
@@ -77121,6 +77164,7 @@ var ts;
|
|
|
77121
77164
|
var parent = node.parent;
|
|
77122
77165
|
return ts.isAssertionExpression(parent) && ts.isConstTypeReference(parent.type) ||
|
|
77123
77166
|
ts.isJSDocTypeAssertion(parent) && ts.isConstTypeReference(ts.getJSDocTypeAssertionType(parent)) ||
|
|
77167
|
+
ts.isComputedPropertyName(parent) ||
|
|
77124
77168
|
(ts.isParenthesizedExpression(parent) || ts.isArrayLiteralExpression(parent) || ts.isSpreadElement(parent)) && isConstContext(parent) ||
|
|
77125
77169
|
(ts.isPropertyAssignment(parent) || ts.isShorthandPropertyAssignment(parent) || ts.isTemplateSpan(parent)) && isConstContext(parent.parent);
|
|
77126
77170
|
}
|
|
@@ -78176,7 +78220,7 @@ var ts;
|
|
|
78176
78220
|
ts.forEach(node.members, checkSourceElement);
|
|
78177
78221
|
if (produceDiagnostics) {
|
|
78178
78222
|
var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
|
|
78179
|
-
checkIndexConstraints(type);
|
|
78223
|
+
checkIndexConstraints(type, type.symbol);
|
|
78180
78224
|
checkTypeForDuplicateIndexSignatures(node);
|
|
78181
78225
|
checkObjectTypeForDuplicateDeclarations(node);
|
|
78182
78226
|
}
|
|
@@ -78271,6 +78315,7 @@ var ts;
|
|
|
78271
78315
|
checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node);
|
|
78272
78316
|
}
|
|
78273
78317
|
function checkMappedType(node) {
|
|
78318
|
+
checkGrammarMappedType(node);
|
|
78274
78319
|
checkSourceElement(node.typeParameter);
|
|
78275
78320
|
checkSourceElement(node.nameType);
|
|
78276
78321
|
checkSourceElement(node.type);
|
|
@@ -78287,6 +78332,12 @@ var ts;
|
|
|
78287
78332
|
checkTypeAssignableTo(constraintType, keyofConstraintType, ts.getEffectiveConstraintOfTypeParameter(node.typeParameter));
|
|
78288
78333
|
}
|
|
78289
78334
|
}
|
|
78335
|
+
function checkGrammarMappedType(node) {
|
|
78336
|
+
var _a;
|
|
78337
|
+
if ((_a = node.members) === null || _a === void 0 ? void 0 : _a.length) {
|
|
78338
|
+
return grammarErrorOnNode(node.members[0], ts.Diagnostics.A_mapped_type_may_not_declare_properties_or_methods);
|
|
78339
|
+
}
|
|
78340
|
+
}
|
|
78290
78341
|
function checkThisType(node) {
|
|
78291
78342
|
getTypeFromThisTypeNode(node);
|
|
78292
78343
|
}
|
|
@@ -81232,7 +81283,7 @@ var ts;
|
|
|
81232
81283
|
checkBlock(node.finallyBlock);
|
|
81233
81284
|
}
|
|
81234
81285
|
}
|
|
81235
|
-
function checkIndexConstraints(type, isStaticIndex) {
|
|
81286
|
+
function checkIndexConstraints(type, symbol, isStaticIndex) {
|
|
81236
81287
|
var indexInfos = getIndexInfosOfType(type);
|
|
81237
81288
|
if (indexInfos.length === 0) {
|
|
81238
81289
|
return;
|
|
@@ -81243,15 +81294,15 @@ var ts;
|
|
|
81243
81294
|
checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop));
|
|
81244
81295
|
}
|
|
81245
81296
|
}
|
|
81246
|
-
var typeDeclaration =
|
|
81297
|
+
var typeDeclaration = symbol.valueDeclaration;
|
|
81247
81298
|
if (typeDeclaration && ts.isClassLike(typeDeclaration)) {
|
|
81248
81299
|
for (var _b = 0, _c = typeDeclaration.members; _b < _c.length; _b++) {
|
|
81249
81300
|
var member = _c[_b];
|
|
81250
81301
|
// Only process instance properties with computed names here. Static properties cannot be in conflict with indexers,
|
|
81251
81302
|
// and properties with literal names were already checked.
|
|
81252
81303
|
if (!ts.isStatic(member) && !hasBindableName(member)) {
|
|
81253
|
-
var
|
|
81254
|
-
checkIndexConstraintForProperty(type,
|
|
81304
|
+
var symbol_3 = getSymbolOfNode(member);
|
|
81305
|
+
checkIndexConstraintForProperty(type, symbol_3, getTypeOfExpression(member.name.expression), getNonMissingTypeOfSymbol(symbol_3));
|
|
81255
81306
|
}
|
|
81256
81307
|
}
|
|
81257
81308
|
}
|
|
@@ -81567,8 +81618,8 @@ var ts;
|
|
|
81567
81618
|
}
|
|
81568
81619
|
}
|
|
81569
81620
|
if (produceDiagnostics) {
|
|
81570
|
-
checkIndexConstraints(type);
|
|
81571
|
-
checkIndexConstraints(staticType, /*isStaticIndex*/ true);
|
|
81621
|
+
checkIndexConstraints(type, symbol);
|
|
81622
|
+
checkIndexConstraints(staticType, symbol, /*isStaticIndex*/ true);
|
|
81572
81623
|
checkTypeForDuplicateIndexSignatures(node);
|
|
81573
81624
|
checkPropertyInitialization(node);
|
|
81574
81625
|
}
|
|
@@ -81959,7 +82010,7 @@ var ts;
|
|
|
81959
82010
|
var baseType = _a[_i];
|
|
81960
82011
|
checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1);
|
|
81961
82012
|
}
|
|
81962
|
-
checkIndexConstraints(type);
|
|
82013
|
+
checkIndexConstraints(type, symbol);
|
|
81963
82014
|
}
|
|
81964
82015
|
}
|
|
81965
82016
|
checkObjectTypeForDuplicateDeclarations(node);
|
|
@@ -86150,6 +86201,9 @@ var ts;
|
|
|
86150
86201
|
}
|
|
86151
86202
|
}
|
|
86152
86203
|
function checkGrammarProperty(node) {
|
|
86204
|
+
if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* InKeyword */) {
|
|
86205
|
+
return grammarErrorOnNode(node.parent.members[0], ts.Diagnostics.A_mapped_type_may_not_declare_properties_or_methods);
|
|
86206
|
+
}
|
|
86153
86207
|
if (ts.isClassLike(node.parent)) {
|
|
86154
86208
|
if (ts.isStringLiteral(node.name) && node.name.text === "constructor") {
|
|
86155
86209
|
return grammarErrorOnNode(node.name, ts.Diagnostics.Classes_may_not_have_a_field_named_constructor);
|
|
@@ -86169,7 +86223,7 @@ var ts;
|
|
|
86169
86223
|
return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer);
|
|
86170
86224
|
}
|
|
86171
86225
|
}
|
|
86172
|
-
else if (node.parent
|
|
86226
|
+
else if (ts.isTypeLiteralNode(node.parent)) {
|
|
86173
86227
|
if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) {
|
|
86174
86228
|
return true;
|
|
86175
86229
|
}
|
|
@@ -86846,7 +86900,7 @@ var ts;
|
|
|
86846
86900
|
return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode));
|
|
86847
86901
|
case 194 /* MappedType */:
|
|
86848
86902
|
ts.Debug.type(node);
|
|
86849
|
-
return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isReadonlyKeywordOrPlusOrMinusToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionOrPlusOrMinusToken), nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
86903
|
+
return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isReadonlyKeywordOrPlusOrMinusToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionOrPlusOrMinusToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodesVisitor(node.members, visitor, ts.isTypeElement));
|
|
86850
86904
|
case 195 /* LiteralType */:
|
|
86851
86905
|
ts.Debug.type(node);
|
|
86852
86906
|
return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression));
|
|
@@ -94833,51 +94887,25 @@ var ts;
|
|
|
94833
94887
|
return tagTransform(node.openingFragment, node.children, isChild, /*location*/ node);
|
|
94834
94888
|
}
|
|
94835
94889
|
function convertJsxChildrenToChildrenPropObject(children) {
|
|
94890
|
+
var prop = convertJsxChildrenToChildrenPropAssignment(children);
|
|
94891
|
+
return prop && factory.createObjectLiteralExpression([prop]);
|
|
94892
|
+
}
|
|
94893
|
+
function convertJsxChildrenToChildrenPropAssignment(children) {
|
|
94836
94894
|
var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
|
|
94837
94895
|
if (ts.length(nonWhitespaceChildren) === 1) {
|
|
94838
94896
|
var result_13 = transformJsxChildToExpression(nonWhitespaceChildren[0]);
|
|
94839
|
-
return result_13 && factory.
|
|
94840
|
-
factory.createPropertyAssignment("children", result_13)
|
|
94841
|
-
]);
|
|
94897
|
+
return result_13 && factory.createPropertyAssignment("children", result_13);
|
|
94842
94898
|
}
|
|
94843
94899
|
var result = ts.mapDefined(children, transformJsxChildToExpression);
|
|
94844
|
-
return
|
|
94845
|
-
factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result))
|
|
94846
|
-
]);
|
|
94900
|
+
return ts.length(result) ? factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result)) : undefined;
|
|
94847
94901
|
}
|
|
94848
94902
|
function visitJsxOpeningLikeElementJSX(node, children, isChild, location) {
|
|
94849
94903
|
var tagName = getTagName(node);
|
|
94850
|
-
var
|
|
94904
|
+
var childrenProp = children && children.length ? convertJsxChildrenToChildrenPropAssignment(children) : undefined;
|
|
94851
94905
|
var keyAttr = ts.find(node.attributes.properties, function (p) { return !!p.name && ts.isIdentifier(p.name) && p.name.escapedText === "key"; });
|
|
94852
94906
|
var attrs = keyAttr ? ts.filter(node.attributes.properties, function (p) { return p !== keyAttr; }) : node.attributes.properties;
|
|
94853
|
-
var
|
|
94854
|
-
|
|
94855
|
-
// Map spans of JsxAttribute nodes into object literals and spans
|
|
94856
|
-
// of JsxSpreadAttribute nodes into expressions.
|
|
94857
|
-
segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread
|
|
94858
|
-
? ts.map(attrs, transformJsxSpreadAttributeToExpression)
|
|
94859
|
-
: factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); }));
|
|
94860
|
-
if (ts.isJsxSpreadAttribute(attrs[0])) {
|
|
94861
|
-
// We must always emit at least one object literal before a spread
|
|
94862
|
-
// argument.factory.createObjectLiteral
|
|
94863
|
-
segments.unshift(factory.createObjectLiteralExpression());
|
|
94864
|
-
}
|
|
94865
|
-
}
|
|
94866
|
-
if (children && children.length) {
|
|
94867
|
-
var result = convertJsxChildrenToChildrenPropObject(children);
|
|
94868
|
-
if (result) {
|
|
94869
|
-
segments.push(result);
|
|
94870
|
-
}
|
|
94871
|
-
}
|
|
94872
|
-
if (segments.length === 0) {
|
|
94873
|
-
objectProperties = factory.createObjectLiteralExpression([]);
|
|
94874
|
-
// When there are no attributes, React wants {}
|
|
94875
|
-
}
|
|
94876
|
-
else {
|
|
94877
|
-
// Either emit one big object literal (no spread attribs), or
|
|
94878
|
-
// a call to the __assign helper.
|
|
94879
|
-
objectProperties = ts.singleOrUndefined(segments) || emitHelpers().createAssignHelper(segments);
|
|
94880
|
-
}
|
|
94907
|
+
var objectProperties = ts.length(attrs) ? transformJsxAttributesToObjectProps(attrs, childrenProp) :
|
|
94908
|
+
factory.createObjectLiteralExpression(childrenProp ? [childrenProp] : ts.emptyArray); // When there are no attributes, React wants {}
|
|
94881
94909
|
return visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, ts.length(ts.getSemanticJsxChildren(children || ts.emptyArray)), isChild, location);
|
|
94882
94910
|
}
|
|
94883
94911
|
function visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, childrenLength, isChild, location) {
|
|
@@ -94906,38 +94934,9 @@ var ts;
|
|
|
94906
94934
|
}
|
|
94907
94935
|
function visitJsxOpeningLikeElementCreateElement(node, children, isChild, location) {
|
|
94908
94936
|
var tagName = getTagName(node);
|
|
94909
|
-
var objectProperties;
|
|
94910
94937
|
var attrs = node.attributes.properties;
|
|
94911
|
-
|
|
94912
|
-
|
|
94913
|
-
// When there are no attributes, React wants "null"
|
|
94914
|
-
}
|
|
94915
|
-
else {
|
|
94916
|
-
var target = ts.getEmitScriptTarget(compilerOptions);
|
|
94917
|
-
if (target && target >= 5 /* ES2018 */) {
|
|
94918
|
-
objectProperties = factory.createObjectLiteralExpression(ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) {
|
|
94919
|
-
return isSpread ? ts.map(attrs, transformJsxSpreadAttributeToSpreadAssignment) : ts.map(attrs, transformJsxAttributeToObjectLiteralElement);
|
|
94920
|
-
})));
|
|
94921
|
-
}
|
|
94922
|
-
else {
|
|
94923
|
-
// Map spans of JsxAttribute nodes into object literals and spans
|
|
94924
|
-
// of JsxSpreadAttribute nodes into expressions.
|
|
94925
|
-
var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread
|
|
94926
|
-
? ts.map(attrs, transformJsxSpreadAttributeToExpression)
|
|
94927
|
-
: factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); }));
|
|
94928
|
-
if (ts.isJsxSpreadAttribute(attrs[0])) {
|
|
94929
|
-
// We must always emit at least one object literal before a spread
|
|
94930
|
-
// argument.factory.createObjectLiteral
|
|
94931
|
-
segments.unshift(factory.createObjectLiteralExpression());
|
|
94932
|
-
}
|
|
94933
|
-
// Either emit one big object literal (no spread attribs), or
|
|
94934
|
-
// a call to the __assign helper.
|
|
94935
|
-
objectProperties = ts.singleOrUndefined(segments);
|
|
94936
|
-
if (!objectProperties) {
|
|
94937
|
-
objectProperties = emitHelpers().createAssignHelper(segments);
|
|
94938
|
-
}
|
|
94939
|
-
}
|
|
94940
|
-
}
|
|
94938
|
+
var objectProperties = ts.length(attrs) ? transformJsxAttributesToObjectProps(attrs) :
|
|
94939
|
+
factory.createNull(); // When there are no attributes, React wants "null"
|
|
94941
94940
|
var callee = currentFileState.importSpecifier === undefined
|
|
94942
94941
|
? ts.createJsxFactoryExpression(factory, context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, // TODO: GH#18217
|
|
94943
94942
|
node)
|
|
@@ -94970,6 +94969,36 @@ var ts;
|
|
|
94970
94969
|
function transformJsxSpreadAttributeToSpreadAssignment(node) {
|
|
94971
94970
|
return factory.createSpreadAssignment(ts.visitNode(node.expression, visitor, ts.isExpression));
|
|
94972
94971
|
}
|
|
94972
|
+
function transformJsxAttributesToObjectProps(attrs, children) {
|
|
94973
|
+
var target = ts.getEmitScriptTarget(compilerOptions);
|
|
94974
|
+
return target && target >= 5 /* ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) :
|
|
94975
|
+
transformJsxAttributesToExpression(attrs, children);
|
|
94976
|
+
}
|
|
94977
|
+
function transformJsxAttributesToProps(attrs, children) {
|
|
94978
|
+
var props = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) {
|
|
94979
|
+
return ts.map(attrs, function (attr) { return isSpread ? transformJsxSpreadAttributeToSpreadAssignment(attr) : transformJsxAttributeToObjectLiteralElement(attr); });
|
|
94980
|
+
}));
|
|
94981
|
+
if (children) {
|
|
94982
|
+
props.push(children);
|
|
94983
|
+
}
|
|
94984
|
+
return props;
|
|
94985
|
+
}
|
|
94986
|
+
function transformJsxAttributesToExpression(attrs, children) {
|
|
94987
|
+
// Map spans of JsxAttribute nodes into object literals and spans
|
|
94988
|
+
// of JsxSpreadAttribute nodes into expressions.
|
|
94989
|
+
var expressions = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread
|
|
94990
|
+
? ts.map(attrs, transformJsxSpreadAttributeToExpression)
|
|
94991
|
+
: factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); }));
|
|
94992
|
+
if (ts.isJsxSpreadAttribute(attrs[0])) {
|
|
94993
|
+
// We must always emit at least one object literal before a spread
|
|
94994
|
+
// argument.factory.createObjectLiteral
|
|
94995
|
+
expressions.unshift(factory.createObjectLiteralExpression());
|
|
94996
|
+
}
|
|
94997
|
+
if (children) {
|
|
94998
|
+
expressions.push(factory.createObjectLiteralExpression([children]));
|
|
94999
|
+
}
|
|
95000
|
+
return ts.singleOrUndefined(expressions) || emitHelpers().createAssignHelper(expressions);
|
|
95001
|
+
}
|
|
94973
95002
|
function transformJsxSpreadAttributeToExpression(node) {
|
|
94974
95003
|
return ts.visitNode(node.expression, visitor, ts.isExpression);
|
|
94975
95004
|
}
|
|
@@ -98385,78 +98414,17 @@ var ts;
|
|
|
98385
98414
|
* @param node A TemplateExpression node.
|
|
98386
98415
|
*/
|
|
98387
98416
|
function visitTemplateExpression(node) {
|
|
98388
|
-
var
|
|
98389
|
-
addTemplateHead(expressions, node);
|
|
98390
|
-
addTemplateSpans(expressions, node);
|
|
98391
|
-
// createAdd will check if each expression binds less closely than binary '+'.
|
|
98392
|
-
// If it does, it wraps the expression in parentheses. Otherwise, something like
|
|
98393
|
-
// `abc${ 1 << 2 }`
|
|
98394
|
-
// becomes
|
|
98395
|
-
// "abc" + 1 << 2 + ""
|
|
98396
|
-
// which is really
|
|
98397
|
-
// ("abc" + 1) << (2 + "")
|
|
98398
|
-
// rather than
|
|
98399
|
-
// "abc" + (1 << 2) + ""
|
|
98400
|
-
var expression = ts.reduceLeft(expressions, factory.createAdd);
|
|
98401
|
-
if (ts.nodeIsSynthesized(expression)) {
|
|
98402
|
-
ts.setTextRange(expression, node);
|
|
98403
|
-
}
|
|
98404
|
-
return expression;
|
|
98405
|
-
}
|
|
98406
|
-
/**
|
|
98407
|
-
* Gets a value indicating whether we need to include the head of a TemplateExpression.
|
|
98408
|
-
*
|
|
98409
|
-
* @param node A TemplateExpression node.
|
|
98410
|
-
*/
|
|
98411
|
-
function shouldAddTemplateHead(node) {
|
|
98412
|
-
// If this expression has an empty head literal and the first template span has a non-empty
|
|
98413
|
-
// literal, then emitting the empty head literal is not necessary.
|
|
98414
|
-
// `${ foo } and ${ bar }`
|
|
98415
|
-
// can be emitted as
|
|
98416
|
-
// foo + " and " + bar
|
|
98417
|
-
// This is because it is only required that one of the first two operands in the emit
|
|
98418
|
-
// output must be a string literal, so that the other operand and all following operands
|
|
98419
|
-
// are forced into strings.
|
|
98420
|
-
//
|
|
98421
|
-
// If the first template span has an empty literal, then the head must still be emitted.
|
|
98422
|
-
// `${ foo }${ bar }`
|
|
98423
|
-
// must still be emitted as
|
|
98424
|
-
// "" + foo + bar
|
|
98425
|
-
// There is always atleast one templateSpan in this code path, since
|
|
98426
|
-
// NoSubstitutionTemplateLiterals are directly emitted via emitLiteral()
|
|
98427
|
-
ts.Debug.assert(node.templateSpans.length !== 0);
|
|
98428
|
-
return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0;
|
|
98429
|
-
}
|
|
98430
|
-
/**
|
|
98431
|
-
* Adds the head of a TemplateExpression to an array of expressions.
|
|
98432
|
-
*
|
|
98433
|
-
* @param expressions An array of expressions.
|
|
98434
|
-
* @param node A TemplateExpression node.
|
|
98435
|
-
*/
|
|
98436
|
-
function addTemplateHead(expressions, node) {
|
|
98437
|
-
if (!shouldAddTemplateHead(node)) {
|
|
98438
|
-
return;
|
|
98439
|
-
}
|
|
98440
|
-
expressions.push(factory.createStringLiteral(node.head.text));
|
|
98441
|
-
}
|
|
98442
|
-
/**
|
|
98443
|
-
* Visits and adds the template spans of a TemplateExpression to an array of expressions.
|
|
98444
|
-
*
|
|
98445
|
-
* @param expressions An array of expressions.
|
|
98446
|
-
* @param node A TemplateExpression node.
|
|
98447
|
-
*/
|
|
98448
|
-
function addTemplateSpans(expressions, node) {
|
|
98417
|
+
var expression = factory.createStringLiteral(node.head.text);
|
|
98449
98418
|
for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) {
|
|
98450
98419
|
var span = _a[_i];
|
|
98451
|
-
|
|
98452
|
-
|
|
98453
|
-
|
|
98454
|
-
// with the head will force the result up to this point to be a string.
|
|
98455
|
-
// Emitting a '+ ""' has no semantic effect for middles and tails.
|
|
98456
|
-
if (span.literal.text.length !== 0) {
|
|
98457
|
-
expressions.push(factory.createStringLiteral(span.literal.text));
|
|
98420
|
+
var args = [ts.visitNode(span.expression, visitor, ts.isExpression)];
|
|
98421
|
+
if (span.literal.text.length > 0) {
|
|
98422
|
+
args.push(factory.createStringLiteral(span.literal.text));
|
|
98458
98423
|
}
|
|
98424
|
+
expression = factory.createCallExpression(factory.createPropertyAccessExpression(expression, "concat"),
|
|
98425
|
+
/*typeArguments*/ undefined, args);
|
|
98459
98426
|
}
|
|
98427
|
+
return ts.setTextRange(expression, node);
|
|
98460
98428
|
}
|
|
98461
98429
|
/**
|
|
98462
98430
|
* Visits the `super` keyword
|
|
@@ -113164,7 +113132,7 @@ var ts;
|
|
|
113164
113132
|
break;
|
|
113165
113133
|
case ts.FileIncludeKind.TypeReferenceDirective:
|
|
113166
113134
|
(_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
|
|
113167
|
-
packageId = (_g = (_f = file.resolvedTypeReferenceDirectiveNames) === null || _f === void 0 ? void 0 : _f.get(ts.toFileNameLowerCase(file.typeReferenceDirectives[index].fileName),
|
|
113135
|
+
packageId = (_g = (_f = file.resolvedTypeReferenceDirectiveNames) === null || _f === void 0 ? void 0 : _f.get(ts.toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), file.impliedNodeFormat)) === null || _g === void 0 ? void 0 : _g.packageId;
|
|
113168
113136
|
break;
|
|
113169
113137
|
case ts.FileIncludeKind.LibReferenceDirective:
|
|
113170
113138
|
(_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
|
|
@@ -120162,6 +120130,9 @@ var ts;
|
|
|
120162
120130
|
sourceFilesCache.set(path, false);
|
|
120163
120131
|
}
|
|
120164
120132
|
}
|
|
120133
|
+
if (sourceFile) {
|
|
120134
|
+
sourceFile.impliedNodeFormat = ts.getImpliedNodeFormatForFile(path, resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache(), compilerHost, compilerHost.getCompilationSettings());
|
|
120135
|
+
}
|
|
120165
120136
|
return sourceFile;
|
|
120166
120137
|
}
|
|
120167
120138
|
return hostSourceFile.sourceFile;
|
|
@@ -124235,14 +124206,14 @@ var ts;
|
|
|
124235
124206
|
return program.getSourceFiles().some(function (s) { return !s.isDeclarationFile && !program.isSourceFileFromExternalLibrary(s) && !!(s.externalModuleIndicator || s.commonJsModuleIndicator); });
|
|
124236
124207
|
}
|
|
124237
124208
|
ts.programContainsModules = programContainsModules;
|
|
124238
|
-
function
|
|
124209
|
+
function programContainsEsModules(program) {
|
|
124239
124210
|
return program.getSourceFiles().some(function (s) { return !s.isDeclarationFile && !program.isSourceFileFromExternalLibrary(s) && !!s.externalModuleIndicator; });
|
|
124240
124211
|
}
|
|
124241
|
-
ts.
|
|
124242
|
-
function
|
|
124212
|
+
ts.programContainsEsModules = programContainsEsModules;
|
|
124213
|
+
function compilerOptionsIndicateEsModules(compilerOptions) {
|
|
124243
124214
|
return !!compilerOptions.module || ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ || !!compilerOptions.noEmit;
|
|
124244
124215
|
}
|
|
124245
|
-
ts.
|
|
124216
|
+
ts.compilerOptionsIndicateEsModules = compilerOptionsIndicateEsModules;
|
|
124246
124217
|
function createModuleSpecifierResolutionHost(program, host) {
|
|
124247
124218
|
// Mix in `getSymlinkCache` from Program when host doesn't have it
|
|
124248
124219
|
// in order for non-Project hosts to have a symlinks cache.
|
|
@@ -124629,9 +124600,9 @@ var ts;
|
|
|
124629
124600
|
return displayPart(text, ts.SymbolDisplayPartKind.linkText);
|
|
124630
124601
|
}
|
|
124631
124602
|
ts.linkTextPart = linkTextPart;
|
|
124632
|
-
function linkNamePart(
|
|
124603
|
+
function linkNamePart(text, target) {
|
|
124633
124604
|
return {
|
|
124634
|
-
text:
|
|
124605
|
+
text: text,
|
|
124635
124606
|
kind: ts.SymbolDisplayPartKind[ts.SymbolDisplayPartKind.linkName],
|
|
124636
124607
|
target: {
|
|
124637
124608
|
fileName: ts.getSourceFileOfNode(target).fileName,
|
|
@@ -124656,20 +124627,41 @@ var ts;
|
|
|
124656
124627
|
}
|
|
124657
124628
|
else {
|
|
124658
124629
|
var symbol = checker === null || checker === void 0 ? void 0 : checker.getSymbolAtLocation(link.name);
|
|
124630
|
+
var suffix = findLinkNameEnd(link.text);
|
|
124631
|
+
var name = ts.getTextOfNode(link.name) + link.text.slice(0, suffix);
|
|
124632
|
+
var text = link.text.slice(suffix);
|
|
124659
124633
|
var decl = (symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) || ((_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]);
|
|
124660
124634
|
if (decl) {
|
|
124661
|
-
parts.push(linkNamePart(
|
|
124662
|
-
if (
|
|
124663
|
-
parts.push(linkTextPart(
|
|
124635
|
+
parts.push(linkNamePart(name, decl));
|
|
124636
|
+
if (text)
|
|
124637
|
+
parts.push(linkTextPart(text));
|
|
124664
124638
|
}
|
|
124665
124639
|
else {
|
|
124666
|
-
parts.push(linkTextPart(
|
|
124640
|
+
parts.push(linkTextPart(name + (suffix ? "" : " ") + text));
|
|
124667
124641
|
}
|
|
124668
124642
|
}
|
|
124669
124643
|
parts.push(linkPart("}"));
|
|
124670
124644
|
return parts;
|
|
124671
124645
|
}
|
|
124672
124646
|
ts.buildLinkParts = buildLinkParts;
|
|
124647
|
+
function findLinkNameEnd(text) {
|
|
124648
|
+
if (text.indexOf("()") === 0)
|
|
124649
|
+
return 2;
|
|
124650
|
+
if (text[0] !== "<")
|
|
124651
|
+
return 0;
|
|
124652
|
+
var brackets = 0;
|
|
124653
|
+
var i = 0;
|
|
124654
|
+
while (i < text.length) {
|
|
124655
|
+
if (text[i] === "<")
|
|
124656
|
+
brackets++;
|
|
124657
|
+
if (text[i] === ">")
|
|
124658
|
+
brackets--;
|
|
124659
|
+
i++;
|
|
124660
|
+
if (!brackets)
|
|
124661
|
+
return i;
|
|
124662
|
+
}
|
|
124663
|
+
return 0;
|
|
124664
|
+
}
|
|
124673
124665
|
var carriageReturnLineFeed = "\r\n";
|
|
124674
124666
|
/**
|
|
124675
124667
|
* The default is CRLF.
|
|
@@ -125581,11 +125573,12 @@ var ts;
|
|
|
125581
125573
|
: ts.getNameForExportedSymbol(namedSymbol, scriptTarget);
|
|
125582
125574
|
var moduleName = ts.stripQuotes(moduleSymbol.name);
|
|
125583
125575
|
var id = exportInfoId++;
|
|
125576
|
+
var target = ts.skipAlias(symbol, checker);
|
|
125584
125577
|
var storedSymbol = symbol.flags & 33554432 /* Transient */ ? undefined : symbol;
|
|
125585
125578
|
var storedModuleSymbol = moduleSymbol.flags & 33554432 /* Transient */ ? undefined : moduleSymbol;
|
|
125586
125579
|
if (!storedSymbol || !storedModuleSymbol)
|
|
125587
125580
|
symbols.set(id, [symbol, moduleSymbol]);
|
|
125588
|
-
exportInfo.add(key(importedName, symbol, moduleName, checker), {
|
|
125581
|
+
exportInfo.add(key(importedName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), {
|
|
125589
125582
|
id: id,
|
|
125590
125583
|
symbolTableKey: symbolTableKey,
|
|
125591
125584
|
symbolName: importedName,
|
|
@@ -125593,16 +125586,16 @@ var ts;
|
|
|
125593
125586
|
moduleFile: moduleFile,
|
|
125594
125587
|
moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName,
|
|
125595
125588
|
exportKind: exportKind,
|
|
125596
|
-
targetFlags:
|
|
125589
|
+
targetFlags: target.flags,
|
|
125597
125590
|
isFromPackageJson: isFromPackageJson,
|
|
125598
125591
|
symbol: storedSymbol,
|
|
125599
125592
|
moduleSymbol: storedModuleSymbol,
|
|
125600
125593
|
});
|
|
125601
125594
|
},
|
|
125602
|
-
get: function (importingFile,
|
|
125595
|
+
get: function (importingFile, key) {
|
|
125603
125596
|
if (importingFile !== usableByFileName)
|
|
125604
125597
|
return;
|
|
125605
|
-
var result = exportInfo.get(key
|
|
125598
|
+
var result = exportInfo.get(key);
|
|
125606
125599
|
return result === null || result === void 0 ? void 0 : result.map(rehydrateCachedInfo);
|
|
125607
125600
|
},
|
|
125608
125601
|
forEach: function (importingFile, action) {
|
|
@@ -125610,7 +125603,7 @@ var ts;
|
|
|
125610
125603
|
return;
|
|
125611
125604
|
exportInfo.forEach(function (info, key) {
|
|
125612
125605
|
var _a = parseKey(key), symbolName = _a.symbolName, ambientModuleName = _a.ambientModuleName;
|
|
125613
|
-
action(info.map(rehydrateCachedInfo), symbolName, !!ambientModuleName);
|
|
125606
|
+
action(info.map(rehydrateCachedInfo), symbolName, !!ambientModuleName, key);
|
|
125614
125607
|
});
|
|
125615
125608
|
},
|
|
125616
125609
|
releaseSymbols: function () {
|
|
@@ -125675,26 +125668,16 @@ var ts;
|
|
|
125675
125668
|
isFromPackageJson: isFromPackageJson,
|
|
125676
125669
|
};
|
|
125677
125670
|
}
|
|
125678
|
-
function key(importedName, symbol,
|
|
125679
|
-
var
|
|
125680
|
-
|
|
125681
|
-
var target = ts.skipAlias(symbol, checker);
|
|
125682
|
-
return importedName + "|" + createSymbolKey(target) + "|" + moduleKey;
|
|
125671
|
+
function key(importedName, symbol, ambientModuleName, checker) {
|
|
125672
|
+
var moduleKey = ambientModuleName || "";
|
|
125673
|
+
return importedName + "|" + ts.getSymbolId(ts.skipAlias(symbol, checker)) + "|" + moduleKey;
|
|
125683
125674
|
}
|
|
125684
125675
|
function parseKey(key) {
|
|
125685
125676
|
var symbolName = key.substring(0, key.indexOf("|"));
|
|
125686
125677
|
var moduleKey = key.substring(key.lastIndexOf("|") + 1);
|
|
125687
|
-
var ambientModuleName = moduleKey === "
|
|
125678
|
+
var ambientModuleName = moduleKey === "" ? undefined : moduleKey;
|
|
125688
125679
|
return { symbolName: symbolName, ambientModuleName: ambientModuleName };
|
|
125689
125680
|
}
|
|
125690
|
-
function createSymbolKey(symbol) {
|
|
125691
|
-
var key = symbol.name;
|
|
125692
|
-
while (symbol.parent) {
|
|
125693
|
-
key += "," + symbol.parent.name;
|
|
125694
|
-
symbol = symbol.parent;
|
|
125695
|
-
}
|
|
125696
|
-
return key;
|
|
125697
|
-
}
|
|
125698
125681
|
function fileIsGlobalOnly(file) {
|
|
125699
125682
|
return !file.commonJsModuleIndicator && !file.externalModuleIndicator && !file.moduleAugmentations && !file.ambientModuleNames;
|
|
125700
125683
|
}
|
|
@@ -128039,20 +128022,19 @@ var ts;
|
|
|
128039
128022
|
}
|
|
128040
128023
|
}
|
|
128041
128024
|
Completions.getCompletionsAtPosition = getCompletionsAtPosition;
|
|
128025
|
+
function completionEntryDataIsResolved(data) {
|
|
128026
|
+
return !!(data === null || data === void 0 ? void 0 : data.moduleSpecifier);
|
|
128027
|
+
}
|
|
128042
128028
|
function continuePreviousIncompleteResponse(cache, file, location, program, host, preferences, cancellationToken) {
|
|
128043
|
-
var _a;
|
|
128044
128029
|
var previousResponse = cache.get();
|
|
128045
128030
|
if (!previousResponse)
|
|
128046
128031
|
return undefined;
|
|
128047
128032
|
var lowerCaseTokenText = location.text.toLowerCase();
|
|
128048
128033
|
var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken);
|
|
128049
|
-
var checker = program.getTypeChecker();
|
|
128050
|
-
var autoImportProvider = (_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host);
|
|
128051
|
-
var autoImportProviderChecker = autoImportProvider === null || autoImportProvider === void 0 ? void 0 : autoImportProvider.getTypeChecker();
|
|
128052
128034
|
var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, preferences,
|
|
128053
128035
|
/*isForImportStatementCompletion*/ false, function (context) {
|
|
128054
128036
|
var entries = ts.mapDefined(previousResponse.entries, function (entry) {
|
|
128055
|
-
if (!entry.hasAction || !entry.source || !entry.data || entry.data
|
|
128037
|
+
if (!entry.hasAction || !entry.source || !entry.data || completionEntryDataIsResolved(entry.data)) {
|
|
128056
128038
|
// Not an auto import or already resolved; keep as is
|
|
128057
128039
|
return entry;
|
|
128058
128040
|
}
|
|
@@ -128060,8 +128042,8 @@ var ts;
|
|
|
128060
128042
|
// No longer matches typed characters; filter out
|
|
128061
128043
|
return undefined;
|
|
128062
128044
|
}
|
|
128063
|
-
var
|
|
128064
|
-
var info = exportMap.get(file.path, entry.
|
|
128045
|
+
var origin = ts.Debug.checkDefined(getAutoImportSymbolFromCompletionEntryData(entry.name, entry.data, program, host)).origin;
|
|
128046
|
+
var info = exportMap.get(file.path, entry.data.exportMapKey);
|
|
128065
128047
|
var result = info && context.tryResolve(info, !ts.isExternalModuleNameRelative(ts.stripQuotes(origin.moduleSymbol.name)));
|
|
128066
128048
|
if (!result)
|
|
128067
128049
|
return entry;
|
|
@@ -128362,13 +128344,54 @@ var ts;
|
|
|
128362
128344
|
return text.replace(/\$/gm, "\\$");
|
|
128363
128345
|
}
|
|
128364
128346
|
function originToCompletionEntryData(origin) {
|
|
128365
|
-
|
|
128347
|
+
var ambientModuleName = origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name);
|
|
128348
|
+
var isPackageJsonImport = origin.isFromPackageJson ? true : undefined;
|
|
128349
|
+
if (originIsResolvedExport(origin)) {
|
|
128350
|
+
var resolvedData = {
|
|
128351
|
+
exportName: origin.exportName,
|
|
128352
|
+
moduleSpecifier: origin.moduleSpecifier,
|
|
128353
|
+
ambientModuleName: ambientModuleName,
|
|
128354
|
+
fileName: origin.fileName,
|
|
128355
|
+
isPackageJsonImport: isPackageJsonImport,
|
|
128356
|
+
};
|
|
128357
|
+
return resolvedData;
|
|
128358
|
+
}
|
|
128359
|
+
var unresolvedData = {
|
|
128366
128360
|
exportName: origin.exportName,
|
|
128361
|
+
exportMapKey: origin.exportMapKey,
|
|
128367
128362
|
fileName: origin.fileName,
|
|
128368
128363
|
ambientModuleName: origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name),
|
|
128369
128364
|
isPackageJsonImport: origin.isFromPackageJson ? true : undefined,
|
|
128370
|
-
moduleSpecifier: originIsResolvedExport(origin) ? origin.moduleSpecifier : undefined,
|
|
128371
128365
|
};
|
|
128366
|
+
return unresolvedData;
|
|
128367
|
+
}
|
|
128368
|
+
function completionEntryDataToSymbolOriginInfo(data, completionName, moduleSymbol) {
|
|
128369
|
+
var isDefaultExport = data.exportName === "default" /* Default */;
|
|
128370
|
+
var isFromPackageJson = !!data.isPackageJsonImport;
|
|
128371
|
+
if (completionEntryDataIsResolved(data)) {
|
|
128372
|
+
var resolvedOrigin = {
|
|
128373
|
+
kind: 32 /* ResolvedExport */,
|
|
128374
|
+
exportName: data.exportName,
|
|
128375
|
+
moduleSpecifier: data.moduleSpecifier,
|
|
128376
|
+
symbolName: completionName,
|
|
128377
|
+
fileName: data.fileName,
|
|
128378
|
+
moduleSymbol: moduleSymbol,
|
|
128379
|
+
isDefaultExport: isDefaultExport,
|
|
128380
|
+
isFromPackageJson: isFromPackageJson,
|
|
128381
|
+
};
|
|
128382
|
+
return resolvedOrigin;
|
|
128383
|
+
}
|
|
128384
|
+
var unresolvedOrigin = {
|
|
128385
|
+
kind: 4 /* Export */,
|
|
128386
|
+
exportName: data.exportName,
|
|
128387
|
+
exportMapKey: data.exportMapKey,
|
|
128388
|
+
symbolName: completionName,
|
|
128389
|
+
fileName: data.fileName,
|
|
128390
|
+
moduleSymbol: moduleSymbol,
|
|
128391
|
+
isDefaultExport: isDefaultExport,
|
|
128392
|
+
isFromPackageJson: isFromPackageJson,
|
|
128393
|
+
};
|
|
128394
|
+
return unresolvedOrigin;
|
|
128372
128395
|
}
|
|
128373
128396
|
function getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, contextToken, origin, useSemicolons, options, preferences) {
|
|
128374
128397
|
var _a, _b, _c;
|
|
@@ -129144,6 +129167,7 @@ var ts;
|
|
|
129144
129167
|
}
|
|
129145
129168
|
}
|
|
129146
129169
|
function addPropertySymbol(symbol, insertAwait, insertQuestionDot) {
|
|
129170
|
+
var _a;
|
|
129147
129171
|
// For a computed property with an accessible name like `Symbol.iterator`,
|
|
129148
129172
|
// we'll add a completion for the *name* `Symbol` instead of for the property.
|
|
129149
129173
|
// If this is e.g. [Symbol.iterator], add a completion for `Symbol`.
|
|
@@ -129157,19 +129181,33 @@ var ts;
|
|
|
129157
129181
|
var index = symbols.length;
|
|
129158
129182
|
symbols.push(firstAccessibleSymbol);
|
|
129159
129183
|
var moduleSymbol = firstAccessibleSymbol.parent;
|
|
129160
|
-
if (!moduleSymbol ||
|
|
129184
|
+
if (!moduleSymbol ||
|
|
129185
|
+
!ts.isExternalModuleSymbol(moduleSymbol) ||
|
|
129186
|
+
typeChecker.tryGetMemberInModuleExportsAndProperties(firstAccessibleSymbol.name, moduleSymbol) !== firstAccessibleSymbol) {
|
|
129161
129187
|
symbolToOriginInfoMap[index] = { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) };
|
|
129162
129188
|
}
|
|
129163
129189
|
else {
|
|
129164
|
-
var
|
|
129165
|
-
|
|
129166
|
-
|
|
129167
|
-
|
|
129168
|
-
|
|
129169
|
-
|
|
129170
|
-
|
|
129171
|
-
|
|
129172
|
-
|
|
129190
|
+
var fileName = ts.isExternalModuleNameRelative(ts.stripQuotes(moduleSymbol.name)) ? (_a = ts.getSourceFileOfModule(moduleSymbol)) === null || _a === void 0 ? void 0 : _a.fileName : undefined;
|
|
129191
|
+
var moduleSpecifier = (ts.codefix.getModuleSpecifierForBestExportInfo([{
|
|
129192
|
+
exportKind: 0 /* Named */,
|
|
129193
|
+
moduleFileName: fileName,
|
|
129194
|
+
isFromPackageJson: false,
|
|
129195
|
+
moduleSymbol: moduleSymbol,
|
|
129196
|
+
symbol: firstAccessibleSymbol,
|
|
129197
|
+
targetFlags: ts.skipAlias(firstAccessibleSymbol, typeChecker).flags,
|
|
129198
|
+
}], sourceFile, program, host, preferences) || {}).moduleSpecifier;
|
|
129199
|
+
if (moduleSpecifier) {
|
|
129200
|
+
var origin = {
|
|
129201
|
+
kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */),
|
|
129202
|
+
moduleSymbol: moduleSymbol,
|
|
129203
|
+
isDefaultExport: false,
|
|
129204
|
+
symbolName: firstAccessibleSymbol.name,
|
|
129205
|
+
exportName: firstAccessibleSymbol.name,
|
|
129206
|
+
fileName: fileName,
|
|
129207
|
+
moduleSpecifier: moduleSpecifier,
|
|
129208
|
+
};
|
|
129209
|
+
symbolToOriginInfoMap[index] = origin;
|
|
129210
|
+
}
|
|
129173
129211
|
}
|
|
129174
129212
|
}
|
|
129175
129213
|
else if (preferences.includeCompletionsWithInsertText) {
|
|
@@ -129326,11 +129364,11 @@ var ts;
|
|
|
129326
129364
|
// If not already a module, must have modules enabled.
|
|
129327
129365
|
if (!preferences.includeCompletionsForModuleExports)
|
|
129328
129366
|
return false;
|
|
129329
|
-
// If already using
|
|
129367
|
+
// If already using ES modules, OK to continue using them.
|
|
129330
129368
|
if (sourceFile.externalModuleIndicator || sourceFile.commonJsModuleIndicator)
|
|
129331
129369
|
return true;
|
|
129332
129370
|
// If module transpilation is enabled or we're targeting es6 or above, or not emitting, OK.
|
|
129333
|
-
if (ts.
|
|
129371
|
+
if (ts.compilerOptionsIndicateEsModules(program.getCompilerOptions()))
|
|
129334
129372
|
return true;
|
|
129335
129373
|
// If some file is using ES6 modules, assume that it's OK to add more.
|
|
129336
129374
|
return ts.programContainsModules(program);
|
|
@@ -129405,7 +129443,7 @@ var ts;
|
|
|
129405
129443
|
var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
|
|
129406
129444
|
var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
129407
129445
|
resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) {
|
|
129408
|
-
exportInfo.forEach(sourceFile.path, function (info, symbolName, isFromAmbientModule) {
|
|
129446
|
+
exportInfo.forEach(sourceFile.path, function (info, symbolName, isFromAmbientModule, exportMapKey) {
|
|
129409
129447
|
if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
|
|
129410
129448
|
return;
|
|
129411
129449
|
if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName))
|
|
@@ -129430,6 +129468,7 @@ var ts;
|
|
|
129430
129468
|
kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
|
|
129431
129469
|
moduleSpecifier: moduleSpecifier,
|
|
129432
129470
|
symbolName: symbolName,
|
|
129471
|
+
exportMapKey: exportMapKey,
|
|
129433
129472
|
exportName: exportInfo_1.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo_1.symbol.name,
|
|
129434
129473
|
fileName: exportInfo_1.moduleFileName,
|
|
129435
129474
|
isDefaultExport: isDefaultExport,
|
|
@@ -130253,18 +130292,7 @@ var ts;
|
|
|
130253
130292
|
return undefined;
|
|
130254
130293
|
var isDefaultExport = data.exportName === "default" /* Default */;
|
|
130255
130294
|
symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(symbol) || symbol;
|
|
130256
|
-
return {
|
|
130257
|
-
symbol: symbol,
|
|
130258
|
-
origin: {
|
|
130259
|
-
kind: data.moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
|
|
130260
|
-
moduleSymbol: moduleSymbol,
|
|
130261
|
-
symbolName: name,
|
|
130262
|
-
isDefaultExport: isDefaultExport,
|
|
130263
|
-
exportName: data.exportName,
|
|
130264
|
-
fileName: data.fileName,
|
|
130265
|
-
isFromPackageJson: !!data.isPackageJsonImport,
|
|
130266
|
-
}
|
|
130267
|
-
};
|
|
130295
|
+
return { symbol: symbol, origin: completionEntryDataToSymbolOriginInfo(data, name, moduleSymbol) };
|
|
130268
130296
|
}
|
|
130269
130297
|
function getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, jsxIdentifierExpected) {
|
|
130270
130298
|
var name = originIncludesSymbolName(origin) ? origin.symbolName : symbol.name;
|
|
@@ -139631,10 +139659,12 @@ var ts;
|
|
|
139631
139659
|
program.getSemanticDiagnostics(sourceFile, cancellationToken);
|
|
139632
139660
|
var diags = [];
|
|
139633
139661
|
var checker = program.getTypeChecker();
|
|
139634
|
-
|
|
139635
|
-
|
|
139662
|
+
var isCommonJSFile = sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS || ts.fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]);
|
|
139663
|
+
if (!isCommonJSFile &&
|
|
139664
|
+
sourceFile.commonJsModuleIndicator &&
|
|
139665
|
+
(ts.programContainsEsModules(program) || ts.compilerOptionsIndicateEsModules(program.getCompilerOptions())) &&
|
|
139636
139666
|
containsTopLevelCommonjs(sourceFile)) {
|
|
139637
|
-
diags.push(ts.createDiagnosticForNode(getErrorNodeFromCommonJsIndicator(sourceFile.commonJsModuleIndicator), ts.Diagnostics.
|
|
139667
|
+
diags.push(ts.createDiagnosticForNode(getErrorNodeFromCommonJsIndicator(sourceFile.commonJsModuleIndicator), ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module));
|
|
139638
139668
|
}
|
|
139639
139669
|
var isJsFile = ts.isSourceFileJS(sourceFile);
|
|
139640
139670
|
visitedNestedConvertibleFunctions.clear();
|
|
@@ -139683,7 +139713,7 @@ var ts;
|
|
|
139683
139713
|
}
|
|
139684
139714
|
}
|
|
139685
139715
|
ts.computeSuggestionDiagnostics = computeSuggestionDiagnostics;
|
|
139686
|
-
//
|
|
139716
|
+
// convertToEsModule only works on top-level, so don't trigger it if commonjs code only appears in nested scopes.
|
|
139687
139717
|
function containsTopLevelCommonjs(sourceFile) {
|
|
139688
139718
|
return sourceFile.statements.some(function (statement) {
|
|
139689
139719
|
switch (statement.kind) {
|
|
@@ -146877,11 +146907,11 @@ var ts;
|
|
|
146877
146907
|
var codefix;
|
|
146878
146908
|
(function (codefix) {
|
|
146879
146909
|
codefix.registerCodeFix({
|
|
146880
|
-
errorCodes: [ts.Diagnostics.
|
|
146910
|
+
errorCodes: [ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module.code],
|
|
146881
146911
|
getCodeActions: function (context) {
|
|
146882
146912
|
var sourceFile = context.sourceFile, program = context.program, preferences = context.preferences;
|
|
146883
146913
|
var changes = ts.textChanges.ChangeTracker.with(context, function (changes) {
|
|
146884
|
-
var moduleExportsChangedToDefault =
|
|
146914
|
+
var moduleExportsChangedToDefault = convertFileToEsModule(sourceFile, program.getTypeChecker(), changes, ts.getEmitScriptTarget(program.getCompilerOptions()), ts.getQuotePreference(sourceFile, preferences));
|
|
146885
146915
|
if (moduleExportsChangedToDefault) {
|
|
146886
146916
|
for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
|
|
146887
146917
|
var importingFile = _a[_i];
|
|
@@ -146890,7 +146920,7 @@ var ts;
|
|
|
146890
146920
|
}
|
|
146891
146921
|
});
|
|
146892
146922
|
// No support for fix-all since this applies to the whole file at once anyway.
|
|
146893
|
-
return [codefix.createCodeFixActionWithoutFixAll("
|
|
146923
|
+
return [codefix.createCodeFixActionWithoutFixAll("convertToEsModule", changes, ts.Diagnostics.Convert_to_ES_module)];
|
|
146894
146924
|
},
|
|
146895
146925
|
});
|
|
146896
146926
|
function fixImportOfModuleExports(importingFile, exportingFile, changes, quotePreference) {
|
|
@@ -146914,7 +146944,7 @@ var ts;
|
|
|
146914
146944
|
}
|
|
146915
146945
|
}
|
|
146916
146946
|
/** @returns Whether we converted a `module.exports =` to a default export. */
|
|
146917
|
-
function
|
|
146947
|
+
function convertFileToEsModule(sourceFile, checker, changes, target, quotePreference) {
|
|
146918
146948
|
var identifiers = { original: collectFreeIdentifiers(sourceFile), additional: new ts.Set() };
|
|
146919
146949
|
var exports = collectExportRenames(sourceFile, checker, identifiers);
|
|
146920
146950
|
convertExportsAccesses(sourceFile, exports, changes);
|
|
@@ -147047,7 +147077,7 @@ var ts;
|
|
|
147047
147077
|
// `const a = require("b").c` --> `import { c as a } from "./b";
|
|
147048
147078
|
return convertedImports([makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]);
|
|
147049
147079
|
default:
|
|
147050
|
-
return ts.Debug.assertNever(name, "Convert to
|
|
147080
|
+
return ts.Debug.assertNever(name, "Convert to ES module got invalid syntax form " + name.kind);
|
|
147051
147081
|
}
|
|
147052
147082
|
}
|
|
147053
147083
|
function convertAssignment(sourceFile, checker, assignment, changes, exports, useSitesToUnqualify) {
|
|
@@ -147232,7 +147262,7 @@ var ts;
|
|
|
147232
147262
|
case 79 /* Identifier */:
|
|
147233
147263
|
return convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference);
|
|
147234
147264
|
default:
|
|
147235
|
-
return ts.Debug.assertNever(name, "Convert to
|
|
147265
|
+
return ts.Debug.assertNever(name, "Convert to ES module got invalid name kind " + name.kind);
|
|
147236
147266
|
}
|
|
147237
147267
|
}
|
|
147238
147268
|
/**
|
|
@@ -147552,7 +147582,11 @@ var ts;
|
|
|
147552
147582
|
}
|
|
147553
147583
|
function doChange(changes, sourceFile, _a) {
|
|
147554
147584
|
var container = _a.container, typeNode = _a.typeNode, constraint = _a.constraint, name = _a.name;
|
|
147555
|
-
changes.replaceNode(sourceFile, container, ts.factory.createMappedTypeNode(
|
|
147585
|
+
changes.replaceNode(sourceFile, container, ts.factory.createMappedTypeNode(
|
|
147586
|
+
/*readonlyToken*/ undefined, ts.factory.createTypeParameterDeclaration(name, ts.factory.createTypeReferenceNode(constraint)),
|
|
147587
|
+
/*nameType*/ undefined,
|
|
147588
|
+
/*questionToken*/ undefined, typeNode,
|
|
147589
|
+
/*members*/ undefined));
|
|
147556
147590
|
}
|
|
147557
147591
|
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
147558
147592
|
})(ts || (ts = {}));
|
|
@@ -148171,12 +148205,14 @@ var ts;
|
|
|
148171
148205
|
}
|
|
148172
148206
|
var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, preferences, host).allowsImportingSpecifier;
|
|
148173
148207
|
return fixes.reduce(function (best, fix) {
|
|
148208
|
+
// Takes true branch of conditional if `fix` is better than `best`
|
|
148174
148209
|
return compareModuleSpecifiers(fix, best, sourceFile, program, allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best;
|
|
148175
148210
|
});
|
|
148176
148211
|
}
|
|
148212
|
+
/** @returns `Comparison.LessThan` if `a` is better than `b`. */
|
|
148177
148213
|
function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier) {
|
|
148178
148214
|
if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) {
|
|
148179
|
-
return ts.compareBooleans(allowsImportingSpecifier(
|
|
148215
|
+
return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier))
|
|
148180
148216
|
|| compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program)
|
|
148181
148217
|
|| ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier);
|
|
148182
148218
|
}
|
|
@@ -148273,9 +148309,12 @@ var ts;
|
|
|
148273
148309
|
}));
|
|
148274
148310
|
return { fixes: fixes, symbolName: symbolName };
|
|
148275
148311
|
}
|
|
148312
|
+
function jsxModeNeedsExplicitImport(jsx) {
|
|
148313
|
+
return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
|
|
148314
|
+
}
|
|
148276
148315
|
function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) {
|
|
148277
148316
|
var parent = symbolToken.parent;
|
|
148278
|
-
if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && compilerOptions.jsx
|
|
148317
|
+
if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
|
|
148279
148318
|
var jsxNamespace = checker.getJsxNamespace(sourceFile);
|
|
148280
148319
|
if (ts.isIntrinsicJsxName(symbolToken.text) || !checker.resolveName(jsxNamespace, parent, 111551 /* Value */, /*excludeGlobals*/ true)) {
|
|
148281
148320
|
return jsxNamespace;
|
|
@@ -150825,7 +150864,8 @@ var ts;
|
|
|
150825
150864
|
insertBefore = ts.findChildOfKind(containingFunction, 98 /* FunctionKeyword */, sourceFile);
|
|
150826
150865
|
break;
|
|
150827
150866
|
case 213 /* ArrowFunction */:
|
|
150828
|
-
|
|
150867
|
+
var kind = containingFunction.typeParameters ? 29 /* LessThanToken */ : 20 /* OpenParenToken */;
|
|
150868
|
+
insertBefore = ts.findChildOfKind(containingFunction, kind, sourceFile) || ts.first(containingFunction.parameters);
|
|
150829
150869
|
break;
|
|
150830
150870
|
default:
|
|
150831
150871
|
return;
|
|
@@ -153147,7 +153187,8 @@ var ts;
|
|
|
153147
153187
|
var parameter = ts.first(indexSignature.parameters);
|
|
153148
153188
|
var mappedTypeParameter = ts.factory.createTypeParameterDeclaration(ts.cast(parameter.name, ts.isIdentifier), parameter.type);
|
|
153149
153189
|
var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(144 /* ReadonlyKeyword */) : undefined, mappedTypeParameter,
|
|
153150
|
-
/*nameType*/ undefined, indexSignature.questionToken, indexSignature.type
|
|
153190
|
+
/*nameType*/ undefined, indexSignature.questionToken, indexSignature.type,
|
|
153191
|
+
/*members*/ undefined);
|
|
153151
153192
|
var intersectionType = ts.factory.createIntersectionTypeNode(__spreadArray(__spreadArray(__spreadArray([], ts.getAllSuperTypeNodes(container), true), [
|
|
153152
153193
|
mappedIntersectionType
|
|
153153
153194
|
], false), (otherMembers.length ? [ts.factory.createTypeLiteralNode(otherMembers)] : ts.emptyArray), true));
|
|
@@ -156390,17 +156431,17 @@ var ts;
|
|
|
156390
156431
|
deleteMovedStatements(oldFile, toMove.ranges, changes);
|
|
156391
156432
|
return __spreadArray(__spreadArray([], prologueDirectives, true), toMove.all, true);
|
|
156392
156433
|
}
|
|
156393
|
-
var
|
|
156434
|
+
var useEsModuleSyntax = !!oldFile.externalModuleIndicator;
|
|
156394
156435
|
var quotePreference = ts.getQuotePreference(oldFile, preferences);
|
|
156395
|
-
var importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName,
|
|
156436
|
+
var importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEsModuleSyntax, quotePreference);
|
|
156396
156437
|
if (importsFromNewFile) {
|
|
156397
156438
|
ts.insertImports(changes, oldFile, importsFromNewFile, /*blankLineBetween*/ true);
|
|
156398
156439
|
}
|
|
156399
156440
|
deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker);
|
|
156400
156441
|
deleteMovedStatements(oldFile, toMove.ranges, changes);
|
|
156401
156442
|
updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols, newModuleName);
|
|
156402
|
-
var imports = getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker,
|
|
156403
|
-
var body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile,
|
|
156443
|
+
var imports = getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEsModuleSyntax, quotePreference);
|
|
156444
|
+
var body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEsModuleSyntax);
|
|
156404
156445
|
if (imports.length && body.length) {
|
|
156405
156446
|
return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], prologueDirectives, true), imports, true), [
|
|
156406
156447
|
4 /* NewLineTrivia */
|
|
@@ -156647,7 +156688,7 @@ var ts;
|
|
|
156647
156688
|
break;
|
|
156648
156689
|
}
|
|
156649
156690
|
}
|
|
156650
|
-
function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileImportsFromOldFile, changes, checker,
|
|
156691
|
+
function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileImportsFromOldFile, changes, checker, useEsModuleSyntax, quotePreference) {
|
|
156651
156692
|
var copiedOldImports = [];
|
|
156652
156693
|
for (var _i = 0, _a = oldFile.statements; _i < _a.length; _i++) {
|
|
156653
156694
|
var oldStatement = _a[_i];
|
|
@@ -156672,7 +156713,7 @@ var ts;
|
|
|
156672
156713
|
continue;
|
|
156673
156714
|
var top = getTopLevelDeclarationStatement(decl);
|
|
156674
156715
|
if (markSeenTop(top)) {
|
|
156675
|
-
addExportToChanges(oldFile, top, name, changes,
|
|
156716
|
+
addExportToChanges(oldFile, top, name, changes, useEsModuleSyntax);
|
|
156676
156717
|
}
|
|
156677
156718
|
if (ts.hasSyntacticModifier(decl, 512 /* Default */)) {
|
|
156678
156719
|
oldFileDefault = name;
|
|
@@ -156682,7 +156723,7 @@ var ts;
|
|
|
156682
156723
|
}
|
|
156683
156724
|
}
|
|
156684
156725
|
});
|
|
156685
|
-
ts.append(copiedOldImports, makeImportOrRequire(oldFileDefault, oldFileNamedImports, ts.removeFileExtension(ts.getBaseFileName(oldFile.fileName)),
|
|
156726
|
+
ts.append(copiedOldImports, makeImportOrRequire(oldFileDefault, oldFileNamedImports, ts.removeFileExtension(ts.getBaseFileName(oldFile.fileName)), useEsModuleSyntax, quotePreference));
|
|
156686
156727
|
return copiedOldImports;
|
|
156687
156728
|
}
|
|
156688
156729
|
function makeUniqueModuleName(moduleName, extension, inDirectory, host) {
|
|
@@ -174393,7 +174434,7 @@ var ts;
|
|
|
174393
174434
|
};
|
|
174394
174435
|
// Do this after sys has been set as findArguments is going to work only then
|
|
174395
174436
|
var sys = server.createWebSystem(webHost, args, function () { return server.findArgument("--executingFilePath") || location + ""; });
|
|
174396
|
-
ts.sys
|
|
174437
|
+
ts.setSys(sys);
|
|
174397
174438
|
var localeStr = server.findArgument("--locale");
|
|
174398
174439
|
if (localeStr) {
|
|
174399
174440
|
ts.validateLocaleAndSetLanguage(localeStr, sys);
|