typescript 4.5.0-dev.20211027 → 4.5.0-dev.20211028
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +82 -42
- package/lib/tsserver.js +86 -43
- package/lib/tsserverlibrary.js +86 -43
- package/lib/typescript.js +86 -43
- package/lib/typescriptServices.js +86 -43
- package/lib/typingsInstaller.js +86 -43
- package/package.json +1 -1
package/lib/tsc.js
CHANGED
|
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
69
69
|
var ts;
|
|
70
70
|
(function (ts) {
|
|
71
71
|
ts.versionMajorMinor = "4.5";
|
|
72
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
72
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20211028";
|
|
73
73
|
var NativeCollections;
|
|
74
74
|
(function (NativeCollections) {
|
|
75
75
|
function tryGetNativeMap() {
|
|
@@ -6565,6 +6565,7 @@ var ts;
|
|
|
6565
6565
|
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."),
|
|
6566
6566
|
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."),
|
|
6567
6567
|
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."),
|
|
6568
|
+
JSON_imports_are_experimental_in_ES_module_mode_imports: diag(7062, ts.DiagnosticCategory.Error, "JSON_imports_are_experimental_in_ES_module_mode_imports_7062", "JSON imports are experimental in ES module mode imports."),
|
|
6568
6569
|
You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
|
|
6569
6570
|
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."),
|
|
6570
6571
|
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."),
|
|
@@ -15532,6 +15533,8 @@ var ts;
|
|
|
15532
15533
|
case ts.ModuleKind.ES2020:
|
|
15533
15534
|
case ts.ModuleKind.ES2022:
|
|
15534
15535
|
case ts.ModuleKind.ESNext:
|
|
15536
|
+
case ts.ModuleKind.Node12:
|
|
15537
|
+
case ts.ModuleKind.NodeNext:
|
|
15535
15538
|
return true;
|
|
15536
15539
|
default:
|
|
15537
15540
|
return false;
|
|
@@ -40055,6 +40058,10 @@ var ts;
|
|
|
40055
40058
|
function isESMFormatImportImportingCommonjsFormatFile(usageMode, targetMode) {
|
|
40056
40059
|
return usageMode === ts.ModuleKind.ESNext && targetMode === ts.ModuleKind.CommonJS;
|
|
40057
40060
|
}
|
|
40061
|
+
function isOnlyImportedAsDefault(usage) {
|
|
40062
|
+
var usageMode = getUsageModeForExpression(usage);
|
|
40063
|
+
return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json");
|
|
40064
|
+
}
|
|
40058
40065
|
function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) {
|
|
40059
40066
|
var usageMode = file && getUsageModeForExpression(usage);
|
|
40060
40067
|
if (file && usageMode !== undefined) {
|
|
@@ -40093,8 +40100,9 @@ var ts;
|
|
|
40093
40100
|
exportDefaultSymbol = resolveExportByName(moduleSymbol, "default", node, dontResolveAlias);
|
|
40094
40101
|
}
|
|
40095
40102
|
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
40103
|
+
var hasDefaultOnly = isOnlyImportedAsDefault(node.parent.moduleSpecifier);
|
|
40096
40104
|
var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, node.parent.moduleSpecifier);
|
|
40097
|
-
if (!exportDefaultSymbol && !hasSyntheticDefault) {
|
|
40105
|
+
if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
|
|
40098
40106
|
if (hasExportAssignmentSymbol(moduleSymbol)) {
|
|
40099
40107
|
var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop";
|
|
40100
40108
|
var exportEqualsSymbol = moduleSymbol.exports.get("export=");
|
|
@@ -40108,7 +40116,7 @@ var ts;
|
|
|
40108
40116
|
reportNonDefaultExport(moduleSymbol, node);
|
|
40109
40117
|
}
|
|
40110
40118
|
}
|
|
40111
|
-
else if (hasSyntheticDefault) {
|
|
40119
|
+
else if (hasSyntheticDefault || hasDefaultOnly) {
|
|
40112
40120
|
var resolved = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
|
40113
40121
|
markSymbolOfAliasDeclarationIfTypeOnly(node, moduleSymbol, resolved, false);
|
|
40114
40122
|
return resolved;
|
|
@@ -40212,7 +40220,7 @@ var ts;
|
|
|
40212
40220
|
var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
|
|
40213
40221
|
if (symbolFromModule === undefined && name.escapedText === "default") {
|
|
40214
40222
|
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
40215
|
-
if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
|
|
40223
|
+
if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
|
|
40216
40224
|
symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
|
40217
40225
|
}
|
|
40218
40226
|
}
|
|
@@ -40700,6 +40708,9 @@ var ts;
|
|
|
40700
40708
|
if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
|
|
40701
40709
|
error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead, moduleReference);
|
|
40702
40710
|
}
|
|
40711
|
+
if (mode === ts.ModuleKind.ESNext && compilerOptions.resolveJsonModule && resolvedModule.extension === ".json") {
|
|
40712
|
+
error(errorNode, ts.Diagnostics.JSON_imports_are_experimental_in_ES_module_mode_imports);
|
|
40713
|
+
}
|
|
40703
40714
|
}
|
|
40704
40715
|
return getMergedSymbol(sourceFile.symbol);
|
|
40705
40716
|
}
|
|
@@ -40819,39 +40830,47 @@ var ts;
|
|
|
40819
40830
|
error(referencingLocation, ts.Diagnostics.This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_referencing_its_default_export, compilerOptionName);
|
|
40820
40831
|
return symbol;
|
|
40821
40832
|
}
|
|
40822
|
-
|
|
40823
|
-
|
|
40824
|
-
|
|
40825
|
-
|
|
40826
|
-
|
|
40833
|
+
var referenceParent = referencingLocation.parent;
|
|
40834
|
+
if ((ts.isImportDeclaration(referenceParent) && ts.getNamespaceDeclarationNode(referenceParent)) ||
|
|
40835
|
+
ts.isImportCall(referenceParent)) {
|
|
40836
|
+
var reference = ts.isImportCall(referenceParent) ? referenceParent.arguments[0] : referenceParent.moduleSpecifier;
|
|
40837
|
+
var type = getTypeOfSymbol(symbol);
|
|
40838
|
+
var defaultOnlyType = getTypeWithSyntheticDefaultOnly(type, symbol, moduleSymbol, reference);
|
|
40839
|
+
if (defaultOnlyType) {
|
|
40840
|
+
return cloneTypeAsModuleType(symbol, defaultOnlyType, referenceParent);
|
|
40841
|
+
}
|
|
40842
|
+
if (ts.getESModuleInterop(compilerOptions)) {
|
|
40827
40843
|
var sigs = getSignaturesOfStructuredType(type, 0);
|
|
40828
40844
|
if (!sigs || !sigs.length) {
|
|
40829
40845
|
sigs = getSignaturesOfStructuredType(type, 1);
|
|
40830
40846
|
}
|
|
40831
|
-
if (sigs && sigs.length) {
|
|
40832
|
-
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol,
|
|
40833
|
-
|
|
40834
|
-
result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
|
|
40835
|
-
result.parent = symbol.parent;
|
|
40836
|
-
result.target = symbol;
|
|
40837
|
-
result.originatingImport = referenceParent;
|
|
40838
|
-
if (symbol.valueDeclaration)
|
|
40839
|
-
result.valueDeclaration = symbol.valueDeclaration;
|
|
40840
|
-
if (symbol.constEnumOnlyModule)
|
|
40841
|
-
result.constEnumOnlyModule = true;
|
|
40842
|
-
if (symbol.members)
|
|
40843
|
-
result.members = new ts.Map(symbol.members);
|
|
40844
|
-
if (symbol.exports)
|
|
40845
|
-
result.exports = new ts.Map(symbol.exports);
|
|
40846
|
-
var resolvedModuleType = resolveStructuredTypeMembers(moduleType);
|
|
40847
|
-
result.type = createAnonymousType(result, resolvedModuleType.members, ts.emptyArray, ts.emptyArray, resolvedModuleType.indexInfos);
|
|
40848
|
-
return result;
|
|
40847
|
+
if ((sigs && sigs.length) || getPropertyOfType(type, "default")) {
|
|
40848
|
+
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference);
|
|
40849
|
+
return cloneTypeAsModuleType(symbol, moduleType, referenceParent);
|
|
40849
40850
|
}
|
|
40850
40851
|
}
|
|
40851
40852
|
}
|
|
40852
40853
|
}
|
|
40853
40854
|
return symbol;
|
|
40854
40855
|
}
|
|
40856
|
+
function cloneTypeAsModuleType(symbol, moduleType, referenceParent) {
|
|
40857
|
+
var result = createSymbol(symbol.flags, symbol.escapedName);
|
|
40858
|
+
result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
|
|
40859
|
+
result.parent = symbol.parent;
|
|
40860
|
+
result.target = symbol;
|
|
40861
|
+
result.originatingImport = referenceParent;
|
|
40862
|
+
if (symbol.valueDeclaration)
|
|
40863
|
+
result.valueDeclaration = symbol.valueDeclaration;
|
|
40864
|
+
if (symbol.constEnumOnlyModule)
|
|
40865
|
+
result.constEnumOnlyModule = true;
|
|
40866
|
+
if (symbol.members)
|
|
40867
|
+
result.members = new ts.Map(symbol.members);
|
|
40868
|
+
if (symbol.exports)
|
|
40869
|
+
result.exports = new ts.Map(symbol.exports);
|
|
40870
|
+
var resolvedModuleType = resolveStructuredTypeMembers(moduleType);
|
|
40871
|
+
result.type = createAnonymousType(result, resolvedModuleType.members, ts.emptyArray, ts.emptyArray, resolvedModuleType.indexInfos);
|
|
40872
|
+
return result;
|
|
40873
|
+
}
|
|
40855
40874
|
function hasExportAssignmentSymbol(moduleSymbol) {
|
|
40856
40875
|
return moduleSymbol.exports.get("export=") !== undefined;
|
|
40857
40876
|
}
|
|
@@ -51185,7 +51204,8 @@ var ts;
|
|
|
51185
51204
|
return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) {
|
|
51186
51205
|
if (t.flags & (3 | 58982400 | 524288 | 2097152) && t !== wildcardType && !isErrorType(t)) {
|
|
51187
51206
|
if (!type.declaration.nameType) {
|
|
51188
|
-
|
|
51207
|
+
var constraint = void 0;
|
|
51208
|
+
if (isArrayType(t) || (t.flags & 1) && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
|
|
51189
51209
|
return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
|
|
51190
51210
|
}
|
|
51191
51211
|
if (isGenericTupleType(t)) {
|
|
@@ -56045,8 +56065,10 @@ var ts;
|
|
|
56045
56065
|
function getFlowCacheKey(node, declaredType, initialType, flowContainer) {
|
|
56046
56066
|
switch (node.kind) {
|
|
56047
56067
|
case 79:
|
|
56048
|
-
|
|
56049
|
-
|
|
56068
|
+
if (!ts.isThisInTypeQuery(node)) {
|
|
56069
|
+
var symbol = getResolvedSymbol(node);
|
|
56070
|
+
return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined;
|
|
56071
|
+
}
|
|
56050
56072
|
case 108:
|
|
56051
56073
|
return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType);
|
|
56052
56074
|
case 229:
|
|
@@ -62632,11 +62654,33 @@ var ts;
|
|
|
62632
62654
|
if (moduleSymbol) {
|
|
62633
62655
|
var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, true, false);
|
|
62634
62656
|
if (esModuleSymbol) {
|
|
62635
|
-
return createPromiseReturnType(node,
|
|
62657
|
+
return createPromiseReturnType(node, getTypeWithSyntheticDefaultOnly(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier) ||
|
|
62658
|
+
getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier));
|
|
62636
62659
|
}
|
|
62637
62660
|
}
|
|
62638
62661
|
return createPromiseReturnType(node, anyType);
|
|
62639
62662
|
}
|
|
62663
|
+
function createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol) {
|
|
62664
|
+
var memberTable = ts.createSymbolTable();
|
|
62665
|
+
var newSymbol = createSymbol(2097152, "default");
|
|
62666
|
+
newSymbol.parent = originalSymbol;
|
|
62667
|
+
newSymbol.nameType = getStringLiteralType("default");
|
|
62668
|
+
newSymbol.target = resolveSymbol(symbol);
|
|
62669
|
+
memberTable.set("default", newSymbol);
|
|
62670
|
+
return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
62671
|
+
}
|
|
62672
|
+
function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) {
|
|
62673
|
+
var hasDefaultOnly = isOnlyImportedAsDefault(moduleSpecifier);
|
|
62674
|
+
if (hasDefaultOnly && type && !isErrorType(type)) {
|
|
62675
|
+
var synthType = type;
|
|
62676
|
+
if (!synthType.defaultOnlyType) {
|
|
62677
|
+
var type_4 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
|
|
62678
|
+
synthType.defaultOnlyType = type_4;
|
|
62679
|
+
}
|
|
62680
|
+
return synthType.defaultOnlyType;
|
|
62681
|
+
}
|
|
62682
|
+
return undefined;
|
|
62683
|
+
}
|
|
62640
62684
|
function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol, moduleSpecifier) {
|
|
62641
62685
|
var _a;
|
|
62642
62686
|
if (allowSyntheticDefaultImports && type && !isErrorType(type)) {
|
|
@@ -62645,14 +62689,8 @@ var ts;
|
|
|
62645
62689
|
var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
62646
62690
|
var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, false, moduleSpecifier);
|
|
62647
62691
|
if (hasSyntheticDefault) {
|
|
62648
|
-
var memberTable = ts.createSymbolTable();
|
|
62649
|
-
var newSymbol = createSymbol(2097152, "default");
|
|
62650
|
-
newSymbol.parent = originalSymbol;
|
|
62651
|
-
newSymbol.nameType = getStringLiteralType("default");
|
|
62652
|
-
newSymbol.target = resolveSymbol(symbol);
|
|
62653
|
-
memberTable.set("default", newSymbol);
|
|
62654
62692
|
var anonymousSymbol = createSymbol(2048, "__type");
|
|
62655
|
-
var defaultContainingObject =
|
|
62693
|
+
var defaultContainingObject = createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol);
|
|
62656
62694
|
anonymousSymbol.type = defaultContainingObject;
|
|
62657
62695
|
synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, 0, false) : defaultContainingObject;
|
|
62658
62696
|
}
|
|
@@ -63299,11 +63337,11 @@ var ts;
|
|
|
63299
63337
|
var operandType = getTypeOfExpression(node.expression.expression);
|
|
63300
63338
|
var witnesses = getSwitchClauseTypeOfWitnesses(node, false);
|
|
63301
63339
|
var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, true);
|
|
63302
|
-
var
|
|
63303
|
-
if (
|
|
63340
|
+
var type_5 = getBaseConstraintOfType(operandType) || operandType;
|
|
63341
|
+
if (type_5.flags & 3) {
|
|
63304
63342
|
return (556800 & notEqualFacts_1) === 556800;
|
|
63305
63343
|
}
|
|
63306
|
-
return !!(filterType(
|
|
63344
|
+
return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072);
|
|
63307
63345
|
}
|
|
63308
63346
|
var type = getTypeOfExpression(node.expression);
|
|
63309
63347
|
if (!isLiteralType(type)) {
|
|
@@ -95319,7 +95357,9 @@ var ts;
|
|
|
95319
95357
|
}
|
|
95320
95358
|
}
|
|
95321
95359
|
if (options.resolveJsonModule) {
|
|
95322
|
-
if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs
|
|
95360
|
+
if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs &&
|
|
95361
|
+
ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 &&
|
|
95362
|
+
ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
|
|
95323
95363
|
createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule");
|
|
95324
95364
|
}
|
|
95325
95365
|
else if (!ts.hasJsonModuleEmitEnabled(options)) {
|
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-dev.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20211028";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -9343,6 +9343,7 @@ var ts;
|
|
|
9343
9343
|
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."),
|
|
9344
9344
|
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."),
|
|
9345
9345
|
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."),
|
|
9346
|
+
JSON_imports_are_experimental_in_ES_module_mode_imports: diag(7062, ts.DiagnosticCategory.Error, "JSON_imports_are_experimental_in_ES_module_mode_imports_7062", "JSON imports are experimental in ES module mode imports."),
|
|
9346
9347
|
You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
|
|
9347
9348
|
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."),
|
|
9348
9349
|
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."),
|
|
@@ -19639,6 +19640,8 @@ var ts;
|
|
|
19639
19640
|
case ts.ModuleKind.ES2020:
|
|
19640
19641
|
case ts.ModuleKind.ES2022:
|
|
19641
19642
|
case ts.ModuleKind.ESNext:
|
|
19643
|
+
case ts.ModuleKind.Node12:
|
|
19644
|
+
case ts.ModuleKind.NodeNext:
|
|
19642
19645
|
return true;
|
|
19643
19646
|
default:
|
|
19644
19647
|
return false;
|
|
@@ -48824,6 +48827,10 @@ var ts;
|
|
|
48824
48827
|
function isESMFormatImportImportingCommonjsFormatFile(usageMode, targetMode) {
|
|
48825
48828
|
return usageMode === ts.ModuleKind.ESNext && targetMode === ts.ModuleKind.CommonJS;
|
|
48826
48829
|
}
|
|
48830
|
+
function isOnlyImportedAsDefault(usage) {
|
|
48831
|
+
var usageMode = getUsageModeForExpression(usage);
|
|
48832
|
+
return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Json */);
|
|
48833
|
+
}
|
|
48827
48834
|
function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) {
|
|
48828
48835
|
var usageMode = file && getUsageModeForExpression(usage);
|
|
48829
48836
|
if (file && usageMode !== undefined) {
|
|
@@ -48874,8 +48881,9 @@ var ts;
|
|
|
48874
48881
|
exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias);
|
|
48875
48882
|
}
|
|
48876
48883
|
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
48884
|
+
var hasDefaultOnly = isOnlyImportedAsDefault(node.parent.moduleSpecifier);
|
|
48877
48885
|
var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, node.parent.moduleSpecifier);
|
|
48878
|
-
if (!exportDefaultSymbol && !hasSyntheticDefault) {
|
|
48886
|
+
if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
|
|
48879
48887
|
if (hasExportAssignmentSymbol(moduleSymbol)) {
|
|
48880
48888
|
var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop";
|
|
48881
48889
|
var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */);
|
|
@@ -48889,7 +48897,7 @@ var ts;
|
|
|
48889
48897
|
reportNonDefaultExport(moduleSymbol, node);
|
|
48890
48898
|
}
|
|
48891
48899
|
}
|
|
48892
|
-
else if (hasSyntheticDefault) {
|
|
48900
|
+
else if (hasSyntheticDefault || hasDefaultOnly) {
|
|
48893
48901
|
// per emit behavior, a synthetic default overrides a "real" .default member if `__esModule` is not present
|
|
48894
48902
|
var resolved = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
|
48895
48903
|
markSymbolOfAliasDeclarationIfTypeOnly(node, moduleSymbol, resolved, /*overwriteTypeOnly*/ false);
|
|
@@ -49014,7 +49022,7 @@ var ts;
|
|
|
49014
49022
|
var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
|
|
49015
49023
|
if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) {
|
|
49016
49024
|
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
49017
|
-
if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
|
|
49025
|
+
if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
|
|
49018
49026
|
symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
|
49019
49027
|
}
|
|
49020
49028
|
}
|
|
@@ -49565,6 +49573,9 @@ var ts;
|
|
|
49565
49573
|
if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
|
|
49566
49574
|
error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead, moduleReference);
|
|
49567
49575
|
}
|
|
49576
|
+
if (mode === ts.ModuleKind.ESNext && compilerOptions.resolveJsonModule && resolvedModule.extension === ".json" /* Json */) {
|
|
49577
|
+
error(errorNode, ts.Diagnostics.JSON_imports_are_experimental_in_ES_module_mode_imports);
|
|
49578
|
+
}
|
|
49568
49579
|
}
|
|
49569
49580
|
// merged symbol is module declaration symbol combined with all augmentations
|
|
49570
49581
|
return getMergedSymbol(sourceFile.symbol);
|
|
@@ -49703,40 +49714,50 @@ var ts;
|
|
|
49703
49714
|
error(referencingLocation, ts.Diagnostics.This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_referencing_its_default_export, compilerOptionName);
|
|
49704
49715
|
return symbol;
|
|
49705
49716
|
}
|
|
49706
|
-
|
|
49707
|
-
|
|
49708
|
-
|
|
49709
|
-
|
|
49710
|
-
|
|
49717
|
+
var referenceParent = referencingLocation.parent;
|
|
49718
|
+
if ((ts.isImportDeclaration(referenceParent) && ts.getNamespaceDeclarationNode(referenceParent)) ||
|
|
49719
|
+
ts.isImportCall(referenceParent)) {
|
|
49720
|
+
var reference = ts.isImportCall(referenceParent) ? referenceParent.arguments[0] : referenceParent.moduleSpecifier;
|
|
49721
|
+
var type = getTypeOfSymbol(symbol);
|
|
49722
|
+
var defaultOnlyType = getTypeWithSyntheticDefaultOnly(type, symbol, moduleSymbol, reference);
|
|
49723
|
+
if (defaultOnlyType) {
|
|
49724
|
+
return cloneTypeAsModuleType(symbol, defaultOnlyType, referenceParent);
|
|
49725
|
+
}
|
|
49726
|
+
if (ts.getESModuleInterop(compilerOptions)) {
|
|
49711
49727
|
var sigs = getSignaturesOfStructuredType(type, 0 /* Call */);
|
|
49712
49728
|
if (!sigs || !sigs.length) {
|
|
49713
49729
|
sigs = getSignaturesOfStructuredType(type, 1 /* Construct */);
|
|
49714
49730
|
}
|
|
49715
|
-
if (sigs && sigs.length) {
|
|
49716
|
-
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol,
|
|
49717
|
-
|
|
49718
|
-
var result = createSymbol(symbol.flags, symbol.escapedName);
|
|
49719
|
-
result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
|
|
49720
|
-
result.parent = symbol.parent;
|
|
49721
|
-
result.target = symbol;
|
|
49722
|
-
result.originatingImport = referenceParent;
|
|
49723
|
-
if (symbol.valueDeclaration)
|
|
49724
|
-
result.valueDeclaration = symbol.valueDeclaration;
|
|
49725
|
-
if (symbol.constEnumOnlyModule)
|
|
49726
|
-
result.constEnumOnlyModule = true;
|
|
49727
|
-
if (symbol.members)
|
|
49728
|
-
result.members = new ts.Map(symbol.members);
|
|
49729
|
-
if (symbol.exports)
|
|
49730
|
-
result.exports = new ts.Map(symbol.exports);
|
|
49731
|
-
var resolvedModuleType = resolveStructuredTypeMembers(moduleType); // Should already be resolved from the signature checks above
|
|
49732
|
-
result.type = createAnonymousType(result, resolvedModuleType.members, ts.emptyArray, ts.emptyArray, resolvedModuleType.indexInfos);
|
|
49733
|
-
return result;
|
|
49731
|
+
if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */)) {
|
|
49732
|
+
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference);
|
|
49733
|
+
return cloneTypeAsModuleType(symbol, moduleType, referenceParent);
|
|
49734
49734
|
}
|
|
49735
49735
|
}
|
|
49736
49736
|
}
|
|
49737
49737
|
}
|
|
49738
49738
|
return symbol;
|
|
49739
49739
|
}
|
|
49740
|
+
/**
|
|
49741
|
+
* Create a new symbol which has the module's type less the call and construct signatures
|
|
49742
|
+
*/
|
|
49743
|
+
function cloneTypeAsModuleType(symbol, moduleType, referenceParent) {
|
|
49744
|
+
var result = createSymbol(symbol.flags, symbol.escapedName);
|
|
49745
|
+
result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
|
|
49746
|
+
result.parent = symbol.parent;
|
|
49747
|
+
result.target = symbol;
|
|
49748
|
+
result.originatingImport = referenceParent;
|
|
49749
|
+
if (symbol.valueDeclaration)
|
|
49750
|
+
result.valueDeclaration = symbol.valueDeclaration;
|
|
49751
|
+
if (symbol.constEnumOnlyModule)
|
|
49752
|
+
result.constEnumOnlyModule = true;
|
|
49753
|
+
if (symbol.members)
|
|
49754
|
+
result.members = new ts.Map(symbol.members);
|
|
49755
|
+
if (symbol.exports)
|
|
49756
|
+
result.exports = new ts.Map(symbol.exports);
|
|
49757
|
+
var resolvedModuleType = resolveStructuredTypeMembers(moduleType); // Should already be resolved from the signature checks above
|
|
49758
|
+
result.type = createAnonymousType(result, resolvedModuleType.members, ts.emptyArray, ts.emptyArray, resolvedModuleType.indexInfos);
|
|
49759
|
+
return result;
|
|
49760
|
+
}
|
|
49740
49761
|
function hasExportAssignmentSymbol(moduleSymbol) {
|
|
49741
49762
|
return moduleSymbol.exports.get("export=" /* ExportEquals */) !== undefined;
|
|
49742
49763
|
}
|
|
@@ -61535,7 +61556,8 @@ var ts;
|
|
|
61535
61556
|
return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) {
|
|
61536
61557
|
if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
|
|
61537
61558
|
if (!type.declaration.nameType) {
|
|
61538
|
-
|
|
61559
|
+
var constraint = void 0;
|
|
61560
|
+
if (isArrayType(t) || (t.flags & 1 /* Any */) && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
|
|
61539
61561
|
return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
|
|
61540
61562
|
}
|
|
61541
61563
|
if (isGenericTupleType(t)) {
|
|
@@ -67182,8 +67204,11 @@ var ts;
|
|
|
67182
67204
|
function getFlowCacheKey(node, declaredType, initialType, flowContainer) {
|
|
67183
67205
|
switch (node.kind) {
|
|
67184
67206
|
case 79 /* Identifier */:
|
|
67185
|
-
|
|
67186
|
-
|
|
67207
|
+
if (!ts.isThisInTypeQuery(node)) {
|
|
67208
|
+
var symbol = getResolvedSymbol(node);
|
|
67209
|
+
return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined;
|
|
67210
|
+
}
|
|
67211
|
+
// falls through
|
|
67187
67212
|
case 108 /* ThisKeyword */:
|
|
67188
67213
|
return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType);
|
|
67189
67214
|
case 229 /* NonNullExpression */:
|
|
@@ -74912,11 +74937,33 @@ var ts;
|
|
|
74912
74937
|
if (moduleSymbol) {
|
|
74913
74938
|
var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false);
|
|
74914
74939
|
if (esModuleSymbol) {
|
|
74915
|
-
return createPromiseReturnType(node,
|
|
74940
|
+
return createPromiseReturnType(node, getTypeWithSyntheticDefaultOnly(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier) ||
|
|
74941
|
+
getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier));
|
|
74916
74942
|
}
|
|
74917
74943
|
}
|
|
74918
74944
|
return createPromiseReturnType(node, anyType);
|
|
74919
74945
|
}
|
|
74946
|
+
function createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol) {
|
|
74947
|
+
var memberTable = ts.createSymbolTable();
|
|
74948
|
+
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
|
|
74949
|
+
newSymbol.parent = originalSymbol;
|
|
74950
|
+
newSymbol.nameType = getStringLiteralType("default");
|
|
74951
|
+
newSymbol.target = resolveSymbol(symbol);
|
|
74952
|
+
memberTable.set("default" /* Default */, newSymbol);
|
|
74953
|
+
return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
74954
|
+
}
|
|
74955
|
+
function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) {
|
|
74956
|
+
var hasDefaultOnly = isOnlyImportedAsDefault(moduleSpecifier);
|
|
74957
|
+
if (hasDefaultOnly && type && !isErrorType(type)) {
|
|
74958
|
+
var synthType = type;
|
|
74959
|
+
if (!synthType.defaultOnlyType) {
|
|
74960
|
+
var type_4 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
|
|
74961
|
+
synthType.defaultOnlyType = type_4;
|
|
74962
|
+
}
|
|
74963
|
+
return synthType.defaultOnlyType;
|
|
74964
|
+
}
|
|
74965
|
+
return undefined;
|
|
74966
|
+
}
|
|
74920
74967
|
function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol, moduleSpecifier) {
|
|
74921
74968
|
var _a;
|
|
74922
74969
|
if (allowSyntheticDefaultImports && type && !isErrorType(type)) {
|
|
@@ -74925,14 +74972,8 @@ var ts;
|
|
|
74925
74972
|
var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
74926
74973
|
var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier);
|
|
74927
74974
|
if (hasSyntheticDefault) {
|
|
74928
|
-
var memberTable = ts.createSymbolTable();
|
|
74929
|
-
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
|
|
74930
|
-
newSymbol.parent = originalSymbol;
|
|
74931
|
-
newSymbol.nameType = getStringLiteralType("default");
|
|
74932
|
-
newSymbol.target = resolveSymbol(symbol);
|
|
74933
|
-
memberTable.set("default" /* Default */, newSymbol);
|
|
74934
74975
|
var anonymousSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */);
|
|
74935
|
-
var defaultContainingObject =
|
|
74976
|
+
var defaultContainingObject = createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol);
|
|
74936
74977
|
anonymousSymbol.type = defaultContainingObject;
|
|
74937
74978
|
synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, /*objectFlags*/ 0, /*readonly*/ false) : defaultContainingObject;
|
|
74938
74979
|
}
|
|
@@ -75640,12 +75681,12 @@ var ts;
|
|
|
75640
75681
|
var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false);
|
|
75641
75682
|
// notEqualFacts states that the type of the switched value is not equal to every type in the switch.
|
|
75642
75683
|
var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true);
|
|
75643
|
-
var
|
|
75684
|
+
var type_5 = getBaseConstraintOfType(operandType) || operandType;
|
|
75644
75685
|
// Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types.
|
|
75645
|
-
if (
|
|
75686
|
+
if (type_5.flags & 3 /* AnyOrUnknown */) {
|
|
75646
75687
|
return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */;
|
|
75647
75688
|
}
|
|
75648
|
-
return !!(filterType(
|
|
75689
|
+
return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
|
|
75649
75690
|
}
|
|
75650
75691
|
var type = getTypeOfExpression(node.expression);
|
|
75651
75692
|
if (!isLiteralType(type)) {
|
|
@@ -115457,7 +115498,9 @@ var ts;
|
|
|
115457
115498
|
}
|
|
115458
115499
|
}
|
|
115459
115500
|
if (options.resolveJsonModule) {
|
|
115460
|
-
if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs
|
|
115501
|
+
if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs &&
|
|
115502
|
+
ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 &&
|
|
115503
|
+
ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
|
|
115461
115504
|
createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule");
|
|
115462
115505
|
}
|
|
115463
115506
|
// Any emit other than common js, amd, es2015 or esnext is error
|