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
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20211028";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -9537,6 +9537,7 @@ var ts;
|
|
|
9537
9537
|
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."),
|
|
9538
9538
|
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."),
|
|
9539
9539
|
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."),
|
|
9540
|
+
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."),
|
|
9540
9541
|
You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
|
|
9541
9542
|
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."),
|
|
9542
9543
|
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."),
|
|
@@ -19833,6 +19834,8 @@ var ts;
|
|
|
19833
19834
|
case ts.ModuleKind.ES2020:
|
|
19834
19835
|
case ts.ModuleKind.ES2022:
|
|
19835
19836
|
case ts.ModuleKind.ESNext:
|
|
19837
|
+
case ts.ModuleKind.Node12:
|
|
19838
|
+
case ts.ModuleKind.NodeNext:
|
|
19836
19839
|
return true;
|
|
19837
19840
|
default:
|
|
19838
19841
|
return false;
|
|
@@ -49018,6 +49021,10 @@ var ts;
|
|
|
49018
49021
|
function isESMFormatImportImportingCommonjsFormatFile(usageMode, targetMode) {
|
|
49019
49022
|
return usageMode === ts.ModuleKind.ESNext && targetMode === ts.ModuleKind.CommonJS;
|
|
49020
49023
|
}
|
|
49024
|
+
function isOnlyImportedAsDefault(usage) {
|
|
49025
|
+
var usageMode = getUsageModeForExpression(usage);
|
|
49026
|
+
return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Json */);
|
|
49027
|
+
}
|
|
49021
49028
|
function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) {
|
|
49022
49029
|
var usageMode = file && getUsageModeForExpression(usage);
|
|
49023
49030
|
if (file && usageMode !== undefined) {
|
|
@@ -49068,8 +49075,9 @@ var ts;
|
|
|
49068
49075
|
exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias);
|
|
49069
49076
|
}
|
|
49070
49077
|
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
49078
|
+
var hasDefaultOnly = isOnlyImportedAsDefault(node.parent.moduleSpecifier);
|
|
49071
49079
|
var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, node.parent.moduleSpecifier);
|
|
49072
|
-
if (!exportDefaultSymbol && !hasSyntheticDefault) {
|
|
49080
|
+
if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
|
|
49073
49081
|
if (hasExportAssignmentSymbol(moduleSymbol)) {
|
|
49074
49082
|
var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop";
|
|
49075
49083
|
var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */);
|
|
@@ -49083,7 +49091,7 @@ var ts;
|
|
|
49083
49091
|
reportNonDefaultExport(moduleSymbol, node);
|
|
49084
49092
|
}
|
|
49085
49093
|
}
|
|
49086
|
-
else if (hasSyntheticDefault) {
|
|
49094
|
+
else if (hasSyntheticDefault || hasDefaultOnly) {
|
|
49087
49095
|
// per emit behavior, a synthetic default overrides a "real" .default member if `__esModule` is not present
|
|
49088
49096
|
var resolved = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
|
49089
49097
|
markSymbolOfAliasDeclarationIfTypeOnly(node, moduleSymbol, resolved, /*overwriteTypeOnly*/ false);
|
|
@@ -49208,7 +49216,7 @@ var ts;
|
|
|
49208
49216
|
var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
|
|
49209
49217
|
if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) {
|
|
49210
49218
|
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
49211
|
-
if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
|
|
49219
|
+
if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
|
|
49212
49220
|
symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
|
49213
49221
|
}
|
|
49214
49222
|
}
|
|
@@ -49759,6 +49767,9 @@ var ts;
|
|
|
49759
49767
|
if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
|
|
49760
49768
|
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);
|
|
49761
49769
|
}
|
|
49770
|
+
if (mode === ts.ModuleKind.ESNext && compilerOptions.resolveJsonModule && resolvedModule.extension === ".json" /* Json */) {
|
|
49771
|
+
error(errorNode, ts.Diagnostics.JSON_imports_are_experimental_in_ES_module_mode_imports);
|
|
49772
|
+
}
|
|
49762
49773
|
}
|
|
49763
49774
|
// merged symbol is module declaration symbol combined with all augmentations
|
|
49764
49775
|
return getMergedSymbol(sourceFile.symbol);
|
|
@@ -49897,40 +49908,50 @@ var ts;
|
|
|
49897
49908
|
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);
|
|
49898
49909
|
return symbol;
|
|
49899
49910
|
}
|
|
49900
|
-
|
|
49901
|
-
|
|
49902
|
-
|
|
49903
|
-
|
|
49904
|
-
|
|
49911
|
+
var referenceParent = referencingLocation.parent;
|
|
49912
|
+
if ((ts.isImportDeclaration(referenceParent) && ts.getNamespaceDeclarationNode(referenceParent)) ||
|
|
49913
|
+
ts.isImportCall(referenceParent)) {
|
|
49914
|
+
var reference = ts.isImportCall(referenceParent) ? referenceParent.arguments[0] : referenceParent.moduleSpecifier;
|
|
49915
|
+
var type = getTypeOfSymbol(symbol);
|
|
49916
|
+
var defaultOnlyType = getTypeWithSyntheticDefaultOnly(type, symbol, moduleSymbol, reference);
|
|
49917
|
+
if (defaultOnlyType) {
|
|
49918
|
+
return cloneTypeAsModuleType(symbol, defaultOnlyType, referenceParent);
|
|
49919
|
+
}
|
|
49920
|
+
if (ts.getESModuleInterop(compilerOptions)) {
|
|
49905
49921
|
var sigs = getSignaturesOfStructuredType(type, 0 /* Call */);
|
|
49906
49922
|
if (!sigs || !sigs.length) {
|
|
49907
49923
|
sigs = getSignaturesOfStructuredType(type, 1 /* Construct */);
|
|
49908
49924
|
}
|
|
49909
|
-
if (sigs && sigs.length) {
|
|
49910
|
-
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol,
|
|
49911
|
-
|
|
49912
|
-
var result = createSymbol(symbol.flags, symbol.escapedName);
|
|
49913
|
-
result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
|
|
49914
|
-
result.parent = symbol.parent;
|
|
49915
|
-
result.target = symbol;
|
|
49916
|
-
result.originatingImport = referenceParent;
|
|
49917
|
-
if (symbol.valueDeclaration)
|
|
49918
|
-
result.valueDeclaration = symbol.valueDeclaration;
|
|
49919
|
-
if (symbol.constEnumOnlyModule)
|
|
49920
|
-
result.constEnumOnlyModule = true;
|
|
49921
|
-
if (symbol.members)
|
|
49922
|
-
result.members = new ts.Map(symbol.members);
|
|
49923
|
-
if (symbol.exports)
|
|
49924
|
-
result.exports = new ts.Map(symbol.exports);
|
|
49925
|
-
var resolvedModuleType = resolveStructuredTypeMembers(moduleType); // Should already be resolved from the signature checks above
|
|
49926
|
-
result.type = createAnonymousType(result, resolvedModuleType.members, ts.emptyArray, ts.emptyArray, resolvedModuleType.indexInfos);
|
|
49927
|
-
return result;
|
|
49925
|
+
if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */)) {
|
|
49926
|
+
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference);
|
|
49927
|
+
return cloneTypeAsModuleType(symbol, moduleType, referenceParent);
|
|
49928
49928
|
}
|
|
49929
49929
|
}
|
|
49930
49930
|
}
|
|
49931
49931
|
}
|
|
49932
49932
|
return symbol;
|
|
49933
49933
|
}
|
|
49934
|
+
/**
|
|
49935
|
+
* Create a new symbol which has the module's type less the call and construct signatures
|
|
49936
|
+
*/
|
|
49937
|
+
function cloneTypeAsModuleType(symbol, moduleType, referenceParent) {
|
|
49938
|
+
var result = createSymbol(symbol.flags, symbol.escapedName);
|
|
49939
|
+
result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
|
|
49940
|
+
result.parent = symbol.parent;
|
|
49941
|
+
result.target = symbol;
|
|
49942
|
+
result.originatingImport = referenceParent;
|
|
49943
|
+
if (symbol.valueDeclaration)
|
|
49944
|
+
result.valueDeclaration = symbol.valueDeclaration;
|
|
49945
|
+
if (symbol.constEnumOnlyModule)
|
|
49946
|
+
result.constEnumOnlyModule = true;
|
|
49947
|
+
if (symbol.members)
|
|
49948
|
+
result.members = new ts.Map(symbol.members);
|
|
49949
|
+
if (symbol.exports)
|
|
49950
|
+
result.exports = new ts.Map(symbol.exports);
|
|
49951
|
+
var resolvedModuleType = resolveStructuredTypeMembers(moduleType); // Should already be resolved from the signature checks above
|
|
49952
|
+
result.type = createAnonymousType(result, resolvedModuleType.members, ts.emptyArray, ts.emptyArray, resolvedModuleType.indexInfos);
|
|
49953
|
+
return result;
|
|
49954
|
+
}
|
|
49934
49955
|
function hasExportAssignmentSymbol(moduleSymbol) {
|
|
49935
49956
|
return moduleSymbol.exports.get("export=" /* ExportEquals */) !== undefined;
|
|
49936
49957
|
}
|
|
@@ -61729,7 +61750,8 @@ var ts;
|
|
|
61729
61750
|
return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) {
|
|
61730
61751
|
if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
|
|
61731
61752
|
if (!type.declaration.nameType) {
|
|
61732
|
-
|
|
61753
|
+
var constraint = void 0;
|
|
61754
|
+
if (isArrayType(t) || (t.flags & 1 /* Any */) && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
|
|
61733
61755
|
return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
|
|
61734
61756
|
}
|
|
61735
61757
|
if (isGenericTupleType(t)) {
|
|
@@ -67376,8 +67398,11 @@ var ts;
|
|
|
67376
67398
|
function getFlowCacheKey(node, declaredType, initialType, flowContainer) {
|
|
67377
67399
|
switch (node.kind) {
|
|
67378
67400
|
case 79 /* Identifier */:
|
|
67379
|
-
|
|
67380
|
-
|
|
67401
|
+
if (!ts.isThisInTypeQuery(node)) {
|
|
67402
|
+
var symbol = getResolvedSymbol(node);
|
|
67403
|
+
return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined;
|
|
67404
|
+
}
|
|
67405
|
+
// falls through
|
|
67381
67406
|
case 108 /* ThisKeyword */:
|
|
67382
67407
|
return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType);
|
|
67383
67408
|
case 229 /* NonNullExpression */:
|
|
@@ -75106,11 +75131,33 @@ var ts;
|
|
|
75106
75131
|
if (moduleSymbol) {
|
|
75107
75132
|
var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false);
|
|
75108
75133
|
if (esModuleSymbol) {
|
|
75109
|
-
return createPromiseReturnType(node,
|
|
75134
|
+
return createPromiseReturnType(node, getTypeWithSyntheticDefaultOnly(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier) ||
|
|
75135
|
+
getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier));
|
|
75110
75136
|
}
|
|
75111
75137
|
}
|
|
75112
75138
|
return createPromiseReturnType(node, anyType);
|
|
75113
75139
|
}
|
|
75140
|
+
function createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol) {
|
|
75141
|
+
var memberTable = ts.createSymbolTable();
|
|
75142
|
+
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
|
|
75143
|
+
newSymbol.parent = originalSymbol;
|
|
75144
|
+
newSymbol.nameType = getStringLiteralType("default");
|
|
75145
|
+
newSymbol.target = resolveSymbol(symbol);
|
|
75146
|
+
memberTable.set("default" /* Default */, newSymbol);
|
|
75147
|
+
return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
75148
|
+
}
|
|
75149
|
+
function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) {
|
|
75150
|
+
var hasDefaultOnly = isOnlyImportedAsDefault(moduleSpecifier);
|
|
75151
|
+
if (hasDefaultOnly && type && !isErrorType(type)) {
|
|
75152
|
+
var synthType = type;
|
|
75153
|
+
if (!synthType.defaultOnlyType) {
|
|
75154
|
+
var type_4 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
|
|
75155
|
+
synthType.defaultOnlyType = type_4;
|
|
75156
|
+
}
|
|
75157
|
+
return synthType.defaultOnlyType;
|
|
75158
|
+
}
|
|
75159
|
+
return undefined;
|
|
75160
|
+
}
|
|
75114
75161
|
function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol, moduleSpecifier) {
|
|
75115
75162
|
var _a;
|
|
75116
75163
|
if (allowSyntheticDefaultImports && type && !isErrorType(type)) {
|
|
@@ -75119,14 +75166,8 @@ var ts;
|
|
|
75119
75166
|
var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
75120
75167
|
var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier);
|
|
75121
75168
|
if (hasSyntheticDefault) {
|
|
75122
|
-
var memberTable = ts.createSymbolTable();
|
|
75123
|
-
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
|
|
75124
|
-
newSymbol.parent = originalSymbol;
|
|
75125
|
-
newSymbol.nameType = getStringLiteralType("default");
|
|
75126
|
-
newSymbol.target = resolveSymbol(symbol);
|
|
75127
|
-
memberTable.set("default" /* Default */, newSymbol);
|
|
75128
75169
|
var anonymousSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */);
|
|
75129
|
-
var defaultContainingObject =
|
|
75170
|
+
var defaultContainingObject = createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol);
|
|
75130
75171
|
anonymousSymbol.type = defaultContainingObject;
|
|
75131
75172
|
synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, /*objectFlags*/ 0, /*readonly*/ false) : defaultContainingObject;
|
|
75132
75173
|
}
|
|
@@ -75834,12 +75875,12 @@ var ts;
|
|
|
75834
75875
|
var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false);
|
|
75835
75876
|
// notEqualFacts states that the type of the switched value is not equal to every type in the switch.
|
|
75836
75877
|
var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true);
|
|
75837
|
-
var
|
|
75878
|
+
var type_5 = getBaseConstraintOfType(operandType) || operandType;
|
|
75838
75879
|
// Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types.
|
|
75839
|
-
if (
|
|
75880
|
+
if (type_5.flags & 3 /* AnyOrUnknown */) {
|
|
75840
75881
|
return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */;
|
|
75841
75882
|
}
|
|
75842
|
-
return !!(filterType(
|
|
75883
|
+
return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
|
|
75843
75884
|
}
|
|
75844
75885
|
var type = getTypeOfExpression(node.expression);
|
|
75845
75886
|
if (!isLiteralType(type)) {
|
|
@@ -115651,7 +115692,9 @@ var ts;
|
|
|
115651
115692
|
}
|
|
115652
115693
|
}
|
|
115653
115694
|
if (options.resolveJsonModule) {
|
|
115654
|
-
if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs
|
|
115695
|
+
if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs &&
|
|
115696
|
+
ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 &&
|
|
115697
|
+
ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
|
|
115655
115698
|
createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule");
|
|
115656
115699
|
}
|
|
115657
115700
|
// Any emit other than common js, amd, es2015 or esnext is error
|
package/lib/typingsInstaller.js
CHANGED
|
@@ -89,7 +89,7 @@ var ts;
|
|
|
89
89
|
// The following is baselined as a literal template type without intervention
|
|
90
90
|
/** The version of the TypeScript compiler release */
|
|
91
91
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
92
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
92
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20211028";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -9332,6 +9332,7 @@ var ts;
|
|
|
9332
9332
|
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."),
|
|
9333
9333
|
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."),
|
|
9334
9334
|
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."),
|
|
9335
|
+
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."),
|
|
9335
9336
|
You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
|
|
9336
9337
|
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."),
|
|
9337
9338
|
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."),
|
|
@@ -19628,6 +19629,8 @@ var ts;
|
|
|
19628
19629
|
case ts.ModuleKind.ES2020:
|
|
19629
19630
|
case ts.ModuleKind.ES2022:
|
|
19630
19631
|
case ts.ModuleKind.ESNext:
|
|
19632
|
+
case ts.ModuleKind.Node12:
|
|
19633
|
+
case ts.ModuleKind.NodeNext:
|
|
19631
19634
|
return true;
|
|
19632
19635
|
default:
|
|
19633
19636
|
return false;
|
|
@@ -48813,6 +48816,10 @@ var ts;
|
|
|
48813
48816
|
function isESMFormatImportImportingCommonjsFormatFile(usageMode, targetMode) {
|
|
48814
48817
|
return usageMode === ts.ModuleKind.ESNext && targetMode === ts.ModuleKind.CommonJS;
|
|
48815
48818
|
}
|
|
48819
|
+
function isOnlyImportedAsDefault(usage) {
|
|
48820
|
+
var usageMode = getUsageModeForExpression(usage);
|
|
48821
|
+
return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Json */);
|
|
48822
|
+
}
|
|
48816
48823
|
function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) {
|
|
48817
48824
|
var usageMode = file && getUsageModeForExpression(usage);
|
|
48818
48825
|
if (file && usageMode !== undefined) {
|
|
@@ -48863,8 +48870,9 @@ var ts;
|
|
|
48863
48870
|
exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias);
|
|
48864
48871
|
}
|
|
48865
48872
|
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
48873
|
+
var hasDefaultOnly = isOnlyImportedAsDefault(node.parent.moduleSpecifier);
|
|
48866
48874
|
var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, node.parent.moduleSpecifier);
|
|
48867
|
-
if (!exportDefaultSymbol && !hasSyntheticDefault) {
|
|
48875
|
+
if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
|
|
48868
48876
|
if (hasExportAssignmentSymbol(moduleSymbol)) {
|
|
48869
48877
|
var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop";
|
|
48870
48878
|
var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */);
|
|
@@ -48878,7 +48886,7 @@ var ts;
|
|
|
48878
48886
|
reportNonDefaultExport(moduleSymbol, node);
|
|
48879
48887
|
}
|
|
48880
48888
|
}
|
|
48881
|
-
else if (hasSyntheticDefault) {
|
|
48889
|
+
else if (hasSyntheticDefault || hasDefaultOnly) {
|
|
48882
48890
|
// per emit behavior, a synthetic default overrides a "real" .default member if `__esModule` is not present
|
|
48883
48891
|
var resolved = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
|
48884
48892
|
markSymbolOfAliasDeclarationIfTypeOnly(node, moduleSymbol, resolved, /*overwriteTypeOnly*/ false);
|
|
@@ -49003,7 +49011,7 @@ var ts;
|
|
|
49003
49011
|
var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
|
|
49004
49012
|
if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) {
|
|
49005
49013
|
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
49006
|
-
if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
|
|
49014
|
+
if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
|
|
49007
49015
|
symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
|
49008
49016
|
}
|
|
49009
49017
|
}
|
|
@@ -49554,6 +49562,9 @@ var ts;
|
|
|
49554
49562
|
if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
|
|
49555
49563
|
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);
|
|
49556
49564
|
}
|
|
49565
|
+
if (mode === ts.ModuleKind.ESNext && compilerOptions.resolveJsonModule && resolvedModule.extension === ".json" /* Json */) {
|
|
49566
|
+
error(errorNode, ts.Diagnostics.JSON_imports_are_experimental_in_ES_module_mode_imports);
|
|
49567
|
+
}
|
|
49557
49568
|
}
|
|
49558
49569
|
// merged symbol is module declaration symbol combined with all augmentations
|
|
49559
49570
|
return getMergedSymbol(sourceFile.symbol);
|
|
@@ -49692,40 +49703,50 @@ var ts;
|
|
|
49692
49703
|
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);
|
|
49693
49704
|
return symbol;
|
|
49694
49705
|
}
|
|
49695
|
-
|
|
49696
|
-
|
|
49697
|
-
|
|
49698
|
-
|
|
49699
|
-
|
|
49706
|
+
var referenceParent = referencingLocation.parent;
|
|
49707
|
+
if ((ts.isImportDeclaration(referenceParent) && ts.getNamespaceDeclarationNode(referenceParent)) ||
|
|
49708
|
+
ts.isImportCall(referenceParent)) {
|
|
49709
|
+
var reference = ts.isImportCall(referenceParent) ? referenceParent.arguments[0] : referenceParent.moduleSpecifier;
|
|
49710
|
+
var type = getTypeOfSymbol(symbol);
|
|
49711
|
+
var defaultOnlyType = getTypeWithSyntheticDefaultOnly(type, symbol, moduleSymbol, reference);
|
|
49712
|
+
if (defaultOnlyType) {
|
|
49713
|
+
return cloneTypeAsModuleType(symbol, defaultOnlyType, referenceParent);
|
|
49714
|
+
}
|
|
49715
|
+
if (ts.getESModuleInterop(compilerOptions)) {
|
|
49700
49716
|
var sigs = getSignaturesOfStructuredType(type, 0 /* Call */);
|
|
49701
49717
|
if (!sigs || !sigs.length) {
|
|
49702
49718
|
sigs = getSignaturesOfStructuredType(type, 1 /* Construct */);
|
|
49703
49719
|
}
|
|
49704
|
-
if (sigs && sigs.length) {
|
|
49705
|
-
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol,
|
|
49706
|
-
|
|
49707
|
-
var result = createSymbol(symbol.flags, symbol.escapedName);
|
|
49708
|
-
result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
|
|
49709
|
-
result.parent = symbol.parent;
|
|
49710
|
-
result.target = symbol;
|
|
49711
|
-
result.originatingImport = referenceParent;
|
|
49712
|
-
if (symbol.valueDeclaration)
|
|
49713
|
-
result.valueDeclaration = symbol.valueDeclaration;
|
|
49714
|
-
if (symbol.constEnumOnlyModule)
|
|
49715
|
-
result.constEnumOnlyModule = true;
|
|
49716
|
-
if (symbol.members)
|
|
49717
|
-
result.members = new ts.Map(symbol.members);
|
|
49718
|
-
if (symbol.exports)
|
|
49719
|
-
result.exports = new ts.Map(symbol.exports);
|
|
49720
|
-
var resolvedModuleType = resolveStructuredTypeMembers(moduleType); // Should already be resolved from the signature checks above
|
|
49721
|
-
result.type = createAnonymousType(result, resolvedModuleType.members, ts.emptyArray, ts.emptyArray, resolvedModuleType.indexInfos);
|
|
49722
|
-
return result;
|
|
49720
|
+
if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */)) {
|
|
49721
|
+
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference);
|
|
49722
|
+
return cloneTypeAsModuleType(symbol, moduleType, referenceParent);
|
|
49723
49723
|
}
|
|
49724
49724
|
}
|
|
49725
49725
|
}
|
|
49726
49726
|
}
|
|
49727
49727
|
return symbol;
|
|
49728
49728
|
}
|
|
49729
|
+
/**
|
|
49730
|
+
* Create a new symbol which has the module's type less the call and construct signatures
|
|
49731
|
+
*/
|
|
49732
|
+
function cloneTypeAsModuleType(symbol, moduleType, referenceParent) {
|
|
49733
|
+
var result = createSymbol(symbol.flags, symbol.escapedName);
|
|
49734
|
+
result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
|
|
49735
|
+
result.parent = symbol.parent;
|
|
49736
|
+
result.target = symbol;
|
|
49737
|
+
result.originatingImport = referenceParent;
|
|
49738
|
+
if (symbol.valueDeclaration)
|
|
49739
|
+
result.valueDeclaration = symbol.valueDeclaration;
|
|
49740
|
+
if (symbol.constEnumOnlyModule)
|
|
49741
|
+
result.constEnumOnlyModule = true;
|
|
49742
|
+
if (symbol.members)
|
|
49743
|
+
result.members = new ts.Map(symbol.members);
|
|
49744
|
+
if (symbol.exports)
|
|
49745
|
+
result.exports = new ts.Map(symbol.exports);
|
|
49746
|
+
var resolvedModuleType = resolveStructuredTypeMembers(moduleType); // Should already be resolved from the signature checks above
|
|
49747
|
+
result.type = createAnonymousType(result, resolvedModuleType.members, ts.emptyArray, ts.emptyArray, resolvedModuleType.indexInfos);
|
|
49748
|
+
return result;
|
|
49749
|
+
}
|
|
49729
49750
|
function hasExportAssignmentSymbol(moduleSymbol) {
|
|
49730
49751
|
return moduleSymbol.exports.get("export=" /* ExportEquals */) !== undefined;
|
|
49731
49752
|
}
|
|
@@ -61524,7 +61545,8 @@ var ts;
|
|
|
61524
61545
|
return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) {
|
|
61525
61546
|
if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
|
|
61526
61547
|
if (!type.declaration.nameType) {
|
|
61527
|
-
|
|
61548
|
+
var constraint = void 0;
|
|
61549
|
+
if (isArrayType(t) || (t.flags & 1 /* Any */) && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
|
|
61528
61550
|
return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
|
|
61529
61551
|
}
|
|
61530
61552
|
if (isGenericTupleType(t)) {
|
|
@@ -67171,8 +67193,11 @@ var ts;
|
|
|
67171
67193
|
function getFlowCacheKey(node, declaredType, initialType, flowContainer) {
|
|
67172
67194
|
switch (node.kind) {
|
|
67173
67195
|
case 79 /* Identifier */:
|
|
67174
|
-
|
|
67175
|
-
|
|
67196
|
+
if (!ts.isThisInTypeQuery(node)) {
|
|
67197
|
+
var symbol = getResolvedSymbol(node);
|
|
67198
|
+
return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined;
|
|
67199
|
+
}
|
|
67200
|
+
// falls through
|
|
67176
67201
|
case 108 /* ThisKeyword */:
|
|
67177
67202
|
return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType);
|
|
67178
67203
|
case 229 /* NonNullExpression */:
|
|
@@ -74901,11 +74926,33 @@ var ts;
|
|
|
74901
74926
|
if (moduleSymbol) {
|
|
74902
74927
|
var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false);
|
|
74903
74928
|
if (esModuleSymbol) {
|
|
74904
|
-
return createPromiseReturnType(node,
|
|
74929
|
+
return createPromiseReturnType(node, getTypeWithSyntheticDefaultOnly(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier) ||
|
|
74930
|
+
getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier));
|
|
74905
74931
|
}
|
|
74906
74932
|
}
|
|
74907
74933
|
return createPromiseReturnType(node, anyType);
|
|
74908
74934
|
}
|
|
74935
|
+
function createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol) {
|
|
74936
|
+
var memberTable = ts.createSymbolTable();
|
|
74937
|
+
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
|
|
74938
|
+
newSymbol.parent = originalSymbol;
|
|
74939
|
+
newSymbol.nameType = getStringLiteralType("default");
|
|
74940
|
+
newSymbol.target = resolveSymbol(symbol);
|
|
74941
|
+
memberTable.set("default" /* Default */, newSymbol);
|
|
74942
|
+
return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
74943
|
+
}
|
|
74944
|
+
function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) {
|
|
74945
|
+
var hasDefaultOnly = isOnlyImportedAsDefault(moduleSpecifier);
|
|
74946
|
+
if (hasDefaultOnly && type && !isErrorType(type)) {
|
|
74947
|
+
var synthType = type;
|
|
74948
|
+
if (!synthType.defaultOnlyType) {
|
|
74949
|
+
var type_4 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
|
|
74950
|
+
synthType.defaultOnlyType = type_4;
|
|
74951
|
+
}
|
|
74952
|
+
return synthType.defaultOnlyType;
|
|
74953
|
+
}
|
|
74954
|
+
return undefined;
|
|
74955
|
+
}
|
|
74909
74956
|
function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol, moduleSpecifier) {
|
|
74910
74957
|
var _a;
|
|
74911
74958
|
if (allowSyntheticDefaultImports && type && !isErrorType(type)) {
|
|
@@ -74914,14 +74961,8 @@ var ts;
|
|
|
74914
74961
|
var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
74915
74962
|
var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier);
|
|
74916
74963
|
if (hasSyntheticDefault) {
|
|
74917
|
-
var memberTable = ts.createSymbolTable();
|
|
74918
|
-
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
|
|
74919
|
-
newSymbol.parent = originalSymbol;
|
|
74920
|
-
newSymbol.nameType = getStringLiteralType("default");
|
|
74921
|
-
newSymbol.target = resolveSymbol(symbol);
|
|
74922
|
-
memberTable.set("default" /* Default */, newSymbol);
|
|
74923
74964
|
var anonymousSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */);
|
|
74924
|
-
var defaultContainingObject =
|
|
74965
|
+
var defaultContainingObject = createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol);
|
|
74925
74966
|
anonymousSymbol.type = defaultContainingObject;
|
|
74926
74967
|
synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, /*objectFlags*/ 0, /*readonly*/ false) : defaultContainingObject;
|
|
74927
74968
|
}
|
|
@@ -75629,12 +75670,12 @@ var ts;
|
|
|
75629
75670
|
var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false);
|
|
75630
75671
|
// notEqualFacts states that the type of the switched value is not equal to every type in the switch.
|
|
75631
75672
|
var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true);
|
|
75632
|
-
var
|
|
75673
|
+
var type_5 = getBaseConstraintOfType(operandType) || operandType;
|
|
75633
75674
|
// Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types.
|
|
75634
|
-
if (
|
|
75675
|
+
if (type_5.flags & 3 /* AnyOrUnknown */) {
|
|
75635
75676
|
return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */;
|
|
75636
75677
|
}
|
|
75637
|
-
return !!(filterType(
|
|
75678
|
+
return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
|
|
75638
75679
|
}
|
|
75639
75680
|
var type = getTypeOfExpression(node.expression);
|
|
75640
75681
|
if (!isLiteralType(type)) {
|
|
@@ -115446,7 +115487,9 @@ var ts;
|
|
|
115446
115487
|
}
|
|
115447
115488
|
}
|
|
115448
115489
|
if (options.resolveJsonModule) {
|
|
115449
|
-
if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs
|
|
115490
|
+
if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs &&
|
|
115491
|
+
ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 &&
|
|
115492
|
+
ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
|
|
115450
115493
|
createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule");
|
|
115451
115494
|
}
|
|
115452
115495
|
// Any emit other than common js, amd, es2015 or esnext is error
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "typescript",
|
|
3
3
|
"author": "Microsoft Corp.",
|
|
4
4
|
"homepage": "https://www.typescriptlang.org/",
|
|
5
|
-
"version": "4.5.0-dev.
|
|
5
|
+
"version": "4.5.0-dev.20211028",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|