typescript 5.4.0-dev.20231120 → 5.4.0-dev.20231122
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 +135 -77
- package/lib/tsserver.js +171 -91
- package/lib/typescript.d.ts +5 -3
- package/lib/typescript.js +170 -91
- package/lib/typingsInstaller.js +23 -23
- package/package.json +2 -2
package/lib/tsc.js
CHANGED
|
@@ -18,7 +18,7 @@ and limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
// src/compiler/corePublic.ts
|
|
20
20
|
var versionMajorMinor = "5.4";
|
|
21
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
21
|
+
var version = `${versionMajorMinor}.0-dev.20231122`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -3661,7 +3661,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
|
|
|
3661
3661
|
TypeFlags2[TypeFlags2["InstantiablePrimitive"] = 406847488] = "InstantiablePrimitive";
|
|
3662
3662
|
TypeFlags2[TypeFlags2["Instantiable"] = 465829888] = "Instantiable";
|
|
3663
3663
|
TypeFlags2[TypeFlags2["StructuredOrInstantiable"] = 469499904] = "StructuredOrInstantiable";
|
|
3664
|
-
TypeFlags2[TypeFlags2["ObjectFlagsType"] =
|
|
3664
|
+
TypeFlags2[TypeFlags2["ObjectFlagsType"] = 3899393] = "ObjectFlagsType";
|
|
3665
3665
|
TypeFlags2[TypeFlags2["Simplifiable"] = 25165824] = "Simplifiable";
|
|
3666
3666
|
TypeFlags2[TypeFlags2["Singleton"] = 67358815] = "Singleton";
|
|
3667
3667
|
TypeFlags2[TypeFlags2["Narrowable"] = 536624127] = "Narrowable";
|
|
@@ -5935,6 +5935,10 @@ var Diagnostics = {
|
|
|
5935
5935
|
ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled: diag(1286, 1 /* Error */, "ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled_1286", "ESM syntax is not allowed in a CommonJS module when 'verbatimModuleSyntax' is enabled."),
|
|
5936
5936
|
A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled: diag(1287, 1 /* Error */, "A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimM_1287", "A top-level 'export' modifier cannot be used on value declarations in a CommonJS module when 'verbatimModuleSyntax' is enabled."),
|
|
5937
5937
|
An_import_alias_cannot_resolve_to_a_type_or_type_only_declaration_when_verbatimModuleSyntax_is_enabled: diag(1288, 1 /* Error */, "An_import_alias_cannot_resolve_to_a_type_or_type_only_declaration_when_verbatimModuleSyntax_is_enabl_1288", "An import alias cannot resolve to a type or type-only declaration when 'verbatimModuleSyntax' is enabled."),
|
|
5938
|
+
_0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_import_type_where_0_is_imported: diag(1289, 1 /* Error */, "_0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_1289", "'{0}' resolves to a type-only declaration and must be marked type-only in this file before re-exporting when '{1}' is enabled. Consider using 'import type' where '{0}' is imported."),
|
|
5939
|
+
_0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_export_type_0_as_default: diag(1290, 1 /* Error */, "_0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_1290", "'{0}' resolves to a type-only declaration and must be marked type-only in this file before re-exporting when '{1}' is enabled. Consider using 'export type { {0} as default }'."),
|
|
5940
|
+
_0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_import_type_where_0_is_imported: diag(1291, 1 /* Error */, "_0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enable_1291", "'{0}' resolves to a type and must be marked type-only in this file before re-exporting when '{1}' is enabled. Consider using 'import type' where '{0}' is imported."),
|
|
5941
|
+
_0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_export_type_0_as_default: diag(1292, 1 /* Error */, "_0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enable_1292", "'{0}' resolves to a type and must be marked type-only in this file before re-exporting when '{1}' is enabled. Consider using 'export type { {0} as default }'."),
|
|
5938
5942
|
with_statements_are_not_allowed_in_an_async_function_block: diag(1300, 1 /* Error */, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
|
|
5939
5943
|
await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, 1 /* Error */, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."),
|
|
5940
5944
|
The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level: diag(1309, 1 /* Error */, "The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level_1309", "The current file is a CommonJS module and cannot use 'await' at the top level."),
|
|
@@ -15970,7 +15974,7 @@ function getClassLikeDeclarationOfSymbol(symbol) {
|
|
|
15970
15974
|
return (_a = symbol.declarations) == null ? void 0 : _a.find(isClassLike);
|
|
15971
15975
|
}
|
|
15972
15976
|
function getObjectFlags(type) {
|
|
15973
|
-
return type.flags &
|
|
15977
|
+
return type.flags & 3899393 /* ObjectFlagsType */ ? type.objectFlags : 0;
|
|
15974
15978
|
}
|
|
15975
15979
|
function isUMDExportSymbol(symbol) {
|
|
15976
15980
|
return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && isNamespaceExportDeclaration(symbol.declarations[0]);
|
|
@@ -18115,7 +18119,7 @@ var nullNodeConverters = {
|
|
|
18115
18119
|
var nextAutoGenerateId = 0;
|
|
18116
18120
|
var nodeFactoryPatchers = [];
|
|
18117
18121
|
function createNodeFactory(flags, baseFactory2) {
|
|
18118
|
-
const
|
|
18122
|
+
const setOriginal = flags & 8 /* NoOriginalNode */ ? identity : setOriginalNode;
|
|
18119
18123
|
const parenthesizerRules = memoize(() => flags & 1 /* NoParenthesizerRules */ ? nullParenthesizerRules : createParenthesizerRules(factory2));
|
|
18120
18124
|
const converters = memoize(() => flags & 2 /* NoNodeConverters */ ? nullNodeConverters : createNodeConverters(factory2));
|
|
18121
18125
|
const getBinaryCreateFunction = memoizeOne((operator) => (left, right) => createBinaryExpression(left, operator, right));
|
|
@@ -21613,7 +21617,7 @@ function createNodeFactory(flags, baseFactory2) {
|
|
|
21613
21617
|
}
|
|
21614
21618
|
function cloneSourceFile(source) {
|
|
21615
21619
|
const node = source.redirectInfo ? cloneRedirectedSourceFile(source) : cloneSourceFileWorker(source);
|
|
21616
|
-
|
|
21620
|
+
setOriginal(node, source);
|
|
21617
21621
|
return node;
|
|
21618
21622
|
}
|
|
21619
21623
|
function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) {
|
|
@@ -21746,7 +21750,7 @@ function createNodeFactory(flags, baseFactory2) {
|
|
|
21746
21750
|
const clone2 = createBaseIdentifier(node.escapedText);
|
|
21747
21751
|
clone2.flags |= node.flags & ~16 /* Synthesized */;
|
|
21748
21752
|
clone2.transformFlags = node.transformFlags;
|
|
21749
|
-
|
|
21753
|
+
setOriginal(clone2, node);
|
|
21750
21754
|
setIdentifierAutoGenerate(clone2, { ...node.emitNode.autoGenerate });
|
|
21751
21755
|
return clone2;
|
|
21752
21756
|
}
|
|
@@ -21757,7 +21761,7 @@ function createNodeFactory(flags, baseFactory2) {
|
|
|
21757
21761
|
clone2.flowNode = node.flowNode;
|
|
21758
21762
|
clone2.symbol = node.symbol;
|
|
21759
21763
|
clone2.transformFlags = node.transformFlags;
|
|
21760
|
-
|
|
21764
|
+
setOriginal(clone2, node);
|
|
21761
21765
|
const typeArguments = getIdentifierTypeArguments(node);
|
|
21762
21766
|
if (typeArguments)
|
|
21763
21767
|
setIdentifierTypeArguments(clone2, typeArguments);
|
|
@@ -21767,7 +21771,7 @@ function createNodeFactory(flags, baseFactory2) {
|
|
|
21767
21771
|
const clone2 = createBasePrivateIdentifier(node.escapedText);
|
|
21768
21772
|
clone2.flags |= node.flags & ~16 /* Synthesized */;
|
|
21769
21773
|
clone2.transformFlags = node.transformFlags;
|
|
21770
|
-
|
|
21774
|
+
setOriginal(clone2, node);
|
|
21771
21775
|
setIdentifierAutoGenerate(clone2, { ...node.emitNode.autoGenerate });
|
|
21772
21776
|
return clone2;
|
|
21773
21777
|
}
|
|
@@ -21775,7 +21779,7 @@ function createNodeFactory(flags, baseFactory2) {
|
|
|
21775
21779
|
const clone2 = createBasePrivateIdentifier(node.escapedText);
|
|
21776
21780
|
clone2.flags |= node.flags & ~16 /* Synthesized */;
|
|
21777
21781
|
clone2.transformFlags = node.transformFlags;
|
|
21778
|
-
|
|
21782
|
+
setOriginal(clone2, node);
|
|
21779
21783
|
return clone2;
|
|
21780
21784
|
}
|
|
21781
21785
|
function cloneNode(node) {
|
|
@@ -21800,7 +21804,7 @@ function createNodeFactory(flags, baseFactory2) {
|
|
|
21800
21804
|
const clone2 = !isNodeKind(node.kind) ? baseFactory2.createBaseTokenNode(node.kind) : baseFactory2.createBaseNode(node.kind);
|
|
21801
21805
|
clone2.flags |= node.flags & ~16 /* Synthesized */;
|
|
21802
21806
|
clone2.transformFlags = node.transformFlags;
|
|
21803
|
-
|
|
21807
|
+
setOriginal(clone2, node);
|
|
21804
21808
|
for (const key in node) {
|
|
21805
21809
|
if (hasProperty(clone2, key) || !hasProperty(node, key)) {
|
|
21806
21810
|
continue;
|
|
@@ -22325,7 +22329,7 @@ function createNodeFactory(flags, baseFactory2) {
|
|
|
22325
22329
|
return typeof value === "number" ? createToken(value) : value;
|
|
22326
22330
|
}
|
|
22327
22331
|
function asEmbeddedStatement(statement) {
|
|
22328
|
-
return statement && isNotEmittedStatement(statement) ? setTextRange(
|
|
22332
|
+
return statement && isNotEmittedStatement(statement) ? setTextRange(setOriginal(createEmptyStatement(), statement), statement) : statement;
|
|
22329
22333
|
}
|
|
22330
22334
|
function asVariableDeclaration(variableDeclaration) {
|
|
22331
22335
|
if (typeof variableDeclaration === "string" || variableDeclaration && !isVariableDeclaration(variableDeclaration)) {
|
|
@@ -22341,19 +22345,13 @@ function createNodeFactory(flags, baseFactory2) {
|
|
|
22341
22345
|
}
|
|
22342
22346
|
return variableDeclaration;
|
|
22343
22347
|
}
|
|
22344
|
-
|
|
22345
|
-
|
|
22346
|
-
|
|
22347
|
-
|
|
22348
|
-
|
|
22349
|
-
|
|
22350
|
-
}
|
|
22351
|
-
function updateWithOriginal(updated, original) {
|
|
22352
|
-
if (updated !== original) {
|
|
22353
|
-
setOriginalNode(updated, original);
|
|
22354
|
-
setTextRange(updated, original);
|
|
22348
|
+
function update(updated, original) {
|
|
22349
|
+
if (updated !== original) {
|
|
22350
|
+
setOriginal(updated, original);
|
|
22351
|
+
setTextRange(updated, original);
|
|
22352
|
+
}
|
|
22353
|
+
return updated;
|
|
22355
22354
|
}
|
|
22356
|
-
return updated;
|
|
22357
22355
|
}
|
|
22358
22356
|
function getDefaultTagNameForKind(kind) {
|
|
22359
22357
|
switch (kind) {
|
|
@@ -26893,8 +26891,10 @@ var Parser;
|
|
|
26893
26891
|
setTextRangePosWidth(sourceFile, 0, sourceText.length);
|
|
26894
26892
|
setFields(sourceFile);
|
|
26895
26893
|
if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 67108864 /* ContainsPossibleTopLevelAwait */) {
|
|
26894
|
+
const oldSourceFile = sourceFile;
|
|
26896
26895
|
sourceFile = reparseTopLevelAwait(sourceFile);
|
|
26897
|
-
|
|
26896
|
+
if (oldSourceFile !== sourceFile)
|
|
26897
|
+
setFields(sourceFile);
|
|
26898
26898
|
}
|
|
26899
26899
|
return sourceFile;
|
|
26900
26900
|
function setFields(sourceFile2) {
|
|
@@ -54197,7 +54197,12 @@ function createTypeChecker(host) {
|
|
|
54197
54197
|
const checkType = type.checkType;
|
|
54198
54198
|
const constraint = getLowerBoundOfKeyType(checkType);
|
|
54199
54199
|
if (constraint !== checkType) {
|
|
54200
|
-
return getConditionalTypeInstantiation(
|
|
54200
|
+
return getConditionalTypeInstantiation(
|
|
54201
|
+
type,
|
|
54202
|
+
prependTypeMapping(type.root.checkType, constraint, type.mapper),
|
|
54203
|
+
/*forConstraint*/
|
|
54204
|
+
false
|
|
54205
|
+
);
|
|
54201
54206
|
}
|
|
54202
54207
|
}
|
|
54203
54208
|
return type;
|
|
@@ -54549,7 +54554,12 @@ function createTypeChecker(host) {
|
|
|
54549
54554
|
);
|
|
54550
54555
|
const constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified;
|
|
54551
54556
|
if (constraint && constraint !== type.checkType) {
|
|
54552
|
-
const instantiated = getConditionalTypeInstantiation(
|
|
54557
|
+
const instantiated = getConditionalTypeInstantiation(
|
|
54558
|
+
type,
|
|
54559
|
+
prependTypeMapping(type.root.checkType, constraint, type.mapper),
|
|
54560
|
+
/*forConstraint*/
|
|
54561
|
+
true
|
|
54562
|
+
);
|
|
54553
54563
|
if (!(instantiated.flags & 131072 /* Never */)) {
|
|
54554
54564
|
type.resolvedConstraintOfDistributive = instantiated;
|
|
54555
54565
|
return instantiated;
|
|
@@ -56983,7 +56993,7 @@ function createTypeChecker(host) {
|
|
|
56983
56993
|
}
|
|
56984
56994
|
}
|
|
56985
56995
|
function removeStringLiteralsMatchedByTemplateLiterals(types) {
|
|
56986
|
-
const templates = filter(types, (t) => !!(t.flags & 134217728 /* TemplateLiteral */) && isPatternLiteralType(t)
|
|
56996
|
+
const templates = filter(types, (t) => !!(t.flags & 134217728 /* TemplateLiteral */) && isPatternLiteralType(t));
|
|
56987
56997
|
if (templates.length) {
|
|
56988
56998
|
let i = types.length;
|
|
56989
56999
|
while (i > 0) {
|
|
@@ -57383,19 +57393,14 @@ function createTypeChecker(host) {
|
|
|
57383
57393
|
function getConstituentCountOfTypes(types) {
|
|
57384
57394
|
return reduceLeft(types, (n, t) => n + getConstituentCount(t), 0);
|
|
57385
57395
|
}
|
|
57386
|
-
function areIntersectedTypesAvoidingPrimitiveReduction(types, primitiveFlags = 4 /* String */ | 8 /* Number */ | 64 /* BigInt */) {
|
|
57387
|
-
if (types.length !== 2) {
|
|
57388
|
-
return false;
|
|
57389
|
-
}
|
|
57390
|
-
const [t1, t2] = types;
|
|
57391
|
-
return !!(t1.flags & primitiveFlags) && t2 === emptyTypeLiteralType || !!(t2.flags & primitiveFlags) && t1 === emptyTypeLiteralType;
|
|
57392
|
-
}
|
|
57393
57396
|
function getTypeFromIntersectionTypeNode(node) {
|
|
57394
57397
|
const links = getNodeLinks(node);
|
|
57395
57398
|
if (!links.resolvedType) {
|
|
57396
57399
|
const aliasSymbol = getAliasSymbolForTypeNode(node);
|
|
57397
57400
|
const types = map(node.types, getTypeFromTypeNode);
|
|
57398
|
-
const
|
|
57401
|
+
const emptyIndex = types.length === 2 ? types.indexOf(emptyTypeLiteralType) : -1;
|
|
57402
|
+
const t = emptyIndex >= 0 ? types[1 - emptyIndex] : unknownType;
|
|
57403
|
+
const noSupertypeReduction = !!(t.flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */) || t.flags & 134217728 /* TemplateLiteral */ && isPatternLiteralType(t));
|
|
57399
57404
|
links.resolvedType = getIntersectionType(types, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), noSupertypeReduction);
|
|
57400
57405
|
}
|
|
57401
57406
|
return links.resolvedType;
|
|
@@ -57422,19 +57427,17 @@ function createTypeChecker(host) {
|
|
|
57422
57427
|
return constraintType;
|
|
57423
57428
|
}
|
|
57424
57429
|
const keyTypes = [];
|
|
57425
|
-
if (
|
|
57426
|
-
if (
|
|
57427
|
-
const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
|
|
57428
|
-
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, !!(indexFlags & 1 /* StringsOnly */), addMemberForKeyType);
|
|
57429
|
-
} else {
|
|
57430
|
+
if (isGenericIndexType(constraintType)) {
|
|
57431
|
+
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
57430
57432
|
return getIndexTypeForGenericType(type, indexFlags);
|
|
57431
57433
|
}
|
|
57434
|
+
forEachType(constraintType, addMemberForKeyType);
|
|
57435
|
+
} else if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
57436
|
+
const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
|
|
57437
|
+
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, !!(indexFlags & 1 /* StringsOnly */), addMemberForKeyType);
|
|
57432
57438
|
} else {
|
|
57433
57439
|
forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
|
|
57434
57440
|
}
|
|
57435
|
-
if (isGenericIndexType(constraintType)) {
|
|
57436
|
-
forEachType(constraintType, addMemberForKeyType);
|
|
57437
|
-
}
|
|
57438
57441
|
const result = indexFlags & 2 /* NoIndexSignatures */ ? filterType(getUnionType(keyTypes), (t) => !(t.flags & (1 /* Any */ | 4 /* String */))) : getUnionType(keyTypes);
|
|
57439
57442
|
if (result.flags & 1048576 /* Union */ && constraintType.flags & 1048576 /* Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) {
|
|
57440
57443
|
return constraintType;
|
|
@@ -57607,11 +57610,6 @@ function createTypeChecker(host) {
|
|
|
57607
57610
|
}
|
|
57608
57611
|
function createTemplateLiteralType(texts, types) {
|
|
57609
57612
|
const type = createType(134217728 /* TemplateLiteral */);
|
|
57610
|
-
type.objectFlags = getPropagatingFlagsOfTypes(
|
|
57611
|
-
types,
|
|
57612
|
-
/*excludeKinds*/
|
|
57613
|
-
98304 /* Nullable */
|
|
57614
|
-
);
|
|
57615
57613
|
type.texts = texts;
|
|
57616
57614
|
type.types = types;
|
|
57617
57615
|
return type;
|
|
@@ -57906,7 +57904,15 @@ function createTypeChecker(host) {
|
|
|
57906
57904
|
}
|
|
57907
57905
|
function isPatternLiteralPlaceholderType(type) {
|
|
57908
57906
|
if (type.flags & 2097152 /* Intersection */) {
|
|
57909
|
-
|
|
57907
|
+
let seenPlaceholder = false;
|
|
57908
|
+
for (const t of type.types) {
|
|
57909
|
+
if (t.flags & (2944 /* Literal */ | 98304 /* Nullable */) || isPatternLiteralPlaceholderType(t)) {
|
|
57910
|
+
seenPlaceholder = true;
|
|
57911
|
+
} else if (!(t.flags & 524288 /* Object */)) {
|
|
57912
|
+
return false;
|
|
57913
|
+
}
|
|
57914
|
+
}
|
|
57915
|
+
return seenPlaceholder;
|
|
57910
57916
|
}
|
|
57911
57917
|
return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || isPatternLiteralType(type);
|
|
57912
57918
|
}
|
|
@@ -57923,7 +57929,7 @@ function createTypeChecker(host) {
|
|
|
57923
57929
|
return !!(getGenericObjectFlags(type) & 8388608 /* IsGenericIndexType */);
|
|
57924
57930
|
}
|
|
57925
57931
|
function getGenericObjectFlags(type) {
|
|
57926
|
-
if (type.flags &
|
|
57932
|
+
if (type.flags & 3145728 /* UnionOrIntersection */) {
|
|
57927
57933
|
if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) {
|
|
57928
57934
|
type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | reduceLeft(type.types, (flags, t) => flags | getGenericObjectFlags(t), 0);
|
|
57929
57935
|
}
|
|
@@ -57935,7 +57941,7 @@ function createTypeChecker(host) {
|
|
|
57935
57941
|
}
|
|
57936
57942
|
return type.objectFlags & 12582912 /* IsGenericType */;
|
|
57937
57943
|
}
|
|
57938
|
-
return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* IsGenericIndexType */ : 0);
|
|
57944
|
+
return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* IsGenericIndexType */ : 0);
|
|
57939
57945
|
}
|
|
57940
57946
|
function getSimplifiedType(type, writing) {
|
|
57941
57947
|
return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : type;
|
|
@@ -58116,7 +58122,7 @@ function createTypeChecker(host) {
|
|
|
58116
58122
|
function isDeferredType(type, checkTuples) {
|
|
58117
58123
|
return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
|
|
58118
58124
|
}
|
|
58119
|
-
function getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) {
|
|
58125
|
+
function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
|
|
58120
58126
|
let result;
|
|
58121
58127
|
let extraTypes;
|
|
58122
58128
|
let tailCount = 0;
|
|
@@ -58162,7 +58168,7 @@ function createTypeChecker(host) {
|
|
|
58162
58168
|
const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
|
|
58163
58169
|
if (!checkTypeDeferred && !isDeferredType(inferredExtendsType, checkTuples)) {
|
|
58164
58170
|
if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (checkType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
|
|
58165
|
-
if (checkType.flags & 1 /* Any */) {
|
|
58171
|
+
if (checkType.flags & 1 /* Any */ || forConstraint && !(inferredExtendsType.flags & 131072 /* Never */) && someType(getPermissiveInstantiation(inferredExtendsType), (t) => isTypeAssignableTo(t, getPermissiveInstantiation(checkType)))) {
|
|
58166
58172
|
(extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
|
|
58167
58173
|
}
|
|
58168
58174
|
const falseType2 = getTypeFromTypeNode(root.node.falseType);
|
|
@@ -58272,7 +58278,9 @@ function createTypeChecker(host) {
|
|
|
58272
58278
|
links.resolvedType = getConditionalType(
|
|
58273
58279
|
root,
|
|
58274
58280
|
/*mapper*/
|
|
58275
|
-
void 0
|
|
58281
|
+
void 0,
|
|
58282
|
+
/*forConstraint*/
|
|
58283
|
+
false
|
|
58276
58284
|
);
|
|
58277
58285
|
if (outerTypeParameters) {
|
|
58278
58286
|
root.instantiations = /* @__PURE__ */ new Map();
|
|
@@ -58961,7 +58969,7 @@ function createTypeChecker(host) {
|
|
|
58961
58969
|
result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
|
|
58962
58970
|
target.instantiations.set(id, result);
|
|
58963
58971
|
const resultObjectFlags = getObjectFlags(result);
|
|
58964
|
-
if (result.flags &
|
|
58972
|
+
if (result.flags & 3899393 /* ObjectFlagsType */ && !(resultObjectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
58965
58973
|
const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables);
|
|
58966
58974
|
if (!(getObjectFlags(result) & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
58967
58975
|
if (resultObjectFlags & (32 /* Mapped */ | 16 /* Anonymous */ | 4 /* Reference */)) {
|
|
@@ -59127,17 +59135,17 @@ function createTypeChecker(host) {
|
|
|
59127
59135
|
result.objectFlags |= result.aliasTypeArguments ? getPropagatingFlagsOfTypes(result.aliasTypeArguments) : 0;
|
|
59128
59136
|
return result;
|
|
59129
59137
|
}
|
|
59130
|
-
function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
|
|
59138
|
+
function getConditionalTypeInstantiation(type, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
|
|
59131
59139
|
const root = type.root;
|
|
59132
59140
|
if (root.outerTypeParameters) {
|
|
59133
59141
|
const typeArguments = map(root.outerTypeParameters, (t) => getMappedType(t, mapper));
|
|
59134
|
-
const id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
|
|
59142
|
+
const id = (forConstraint ? "C" : "") + getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
|
|
59135
59143
|
let result = root.instantiations.get(id);
|
|
59136
59144
|
if (!result) {
|
|
59137
59145
|
const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
|
|
59138
59146
|
const checkType = root.checkType;
|
|
59139
59147
|
const distributionType = root.isDistributive ? getMappedType(checkType, newMapper) : void 0;
|
|
59140
|
-
result = distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapTypeWithAlias(getReducedType(distributionType), (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper)), aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper, aliasSymbol, aliasTypeArguments);
|
|
59148
|
+
result = distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapTypeWithAlias(getReducedType(distributionType), (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper), forConstraint), aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper, forConstraint, aliasSymbol, aliasTypeArguments);
|
|
59141
59149
|
root.instantiations.set(id, result);
|
|
59142
59150
|
}
|
|
59143
59151
|
return result;
|
|
@@ -59225,7 +59233,14 @@ function createTypeChecker(host) {
|
|
|
59225
59233
|
);
|
|
59226
59234
|
}
|
|
59227
59235
|
if (flags & 16777216 /* Conditional */) {
|
|
59228
|
-
return getConditionalTypeInstantiation(
|
|
59236
|
+
return getConditionalTypeInstantiation(
|
|
59237
|
+
type,
|
|
59238
|
+
combineTypeMappers(type.mapper, mapper),
|
|
59239
|
+
/*forConstraint*/
|
|
59240
|
+
false,
|
|
59241
|
+
aliasSymbol,
|
|
59242
|
+
aliasTypeArguments
|
|
59243
|
+
);
|
|
59229
59244
|
}
|
|
59230
59245
|
if (flags & 33554432 /* Substitution */) {
|
|
59231
59246
|
const newBaseType = instantiateType(type.baseType, mapper);
|
|
@@ -60869,7 +60884,7 @@ function createTypeChecker(host) {
|
|
|
60869
60884
|
return relation === comparableRelation ? someTypeRelatedToType(source2, target2, reportErrors2 && !(source2.flags & 402784252 /* Primitive */), intersectionState) : eachTypeRelatedToType(source2, target2, reportErrors2 && !(source2.flags & 402784252 /* Primitive */), intersectionState);
|
|
60870
60885
|
}
|
|
60871
60886
|
if (target2.flags & 1048576 /* Union */) {
|
|
60872
|
-
return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source2), target2, reportErrors2 && !(source2.flags & 402784252 /* Primitive */) && !(target2.flags & 402784252 /* Primitive */));
|
|
60887
|
+
return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source2), target2, reportErrors2 && !(source2.flags & 402784252 /* Primitive */) && !(target2.flags & 402784252 /* Primitive */), intersectionState);
|
|
60873
60888
|
}
|
|
60874
60889
|
if (target2.flags & 2097152 /* Intersection */) {
|
|
60875
60890
|
return typeRelatedToEachType(source2, target2, reportErrors2, 2 /* Target */);
|
|
@@ -60914,7 +60929,8 @@ function createTypeChecker(host) {
|
|
|
60914
60929
|
sourceType,
|
|
60915
60930
|
target2,
|
|
60916
60931
|
/*reportErrors*/
|
|
60917
|
-
false
|
|
60932
|
+
false,
|
|
60933
|
+
0 /* None */
|
|
60918
60934
|
);
|
|
60919
60935
|
if (!related) {
|
|
60920
60936
|
return 0 /* False */;
|
|
@@ -60923,7 +60939,7 @@ function createTypeChecker(host) {
|
|
|
60923
60939
|
}
|
|
60924
60940
|
return result2;
|
|
60925
60941
|
}
|
|
60926
|
-
function typeRelatedToSomeType(source2, target2, reportErrors2) {
|
|
60942
|
+
function typeRelatedToSomeType(source2, target2, reportErrors2, intersectionState) {
|
|
60927
60943
|
const targetTypes = target2.types;
|
|
60928
60944
|
if (target2.flags & 1048576 /* Union */) {
|
|
60929
60945
|
if (containsType(targetTypes, source2)) {
|
|
@@ -60941,7 +60957,10 @@ function createTypeChecker(host) {
|
|
|
60941
60957
|
match,
|
|
60942
60958
|
2 /* Target */,
|
|
60943
60959
|
/*reportErrors*/
|
|
60944
|
-
false
|
|
60960
|
+
false,
|
|
60961
|
+
/*headMessage*/
|
|
60962
|
+
void 0,
|
|
60963
|
+
intersectionState
|
|
60945
60964
|
);
|
|
60946
60965
|
if (related) {
|
|
60947
60966
|
return related;
|
|
@@ -60954,7 +60973,10 @@ function createTypeChecker(host) {
|
|
|
60954
60973
|
type,
|
|
60955
60974
|
2 /* Target */,
|
|
60956
60975
|
/*reportErrors*/
|
|
60957
|
-
false
|
|
60976
|
+
false,
|
|
60977
|
+
/*headMessage*/
|
|
60978
|
+
void 0,
|
|
60979
|
+
intersectionState
|
|
60958
60980
|
);
|
|
60959
60981
|
if (related) {
|
|
60960
60982
|
return related;
|
|
@@ -60968,7 +60990,10 @@ function createTypeChecker(host) {
|
|
|
60968
60990
|
bestMatchingType,
|
|
60969
60991
|
2 /* Target */,
|
|
60970
60992
|
/*reportErrors*/
|
|
60971
|
-
true
|
|
60993
|
+
true,
|
|
60994
|
+
/*headMessage*/
|
|
60995
|
+
void 0,
|
|
60996
|
+
intersectionState
|
|
60972
60997
|
);
|
|
60973
60998
|
}
|
|
60974
60999
|
}
|
|
@@ -61766,13 +61791,6 @@ function createTypeChecker(host) {
|
|
|
61766
61791
|
return result2;
|
|
61767
61792
|
}
|
|
61768
61793
|
}
|
|
61769
|
-
} else {
|
|
61770
|
-
const distributiveConstraint = hasNonCircularBaseConstraint(source2) ? getConstraintOfDistributiveConditionalType(source2) : void 0;
|
|
61771
|
-
if (distributiveConstraint) {
|
|
61772
|
-
if (result2 = isRelatedTo(distributiveConstraint, target2, 1 /* Source */, reportErrors2)) {
|
|
61773
|
-
return result2;
|
|
61774
|
-
}
|
|
61775
|
-
}
|
|
61776
61794
|
}
|
|
61777
61795
|
const defaultConstraint = getDefaultConstraintOfConditionalType(source2);
|
|
61778
61796
|
if (defaultConstraint) {
|
|
@@ -61780,6 +61798,13 @@ function createTypeChecker(host) {
|
|
|
61780
61798
|
return result2;
|
|
61781
61799
|
}
|
|
61782
61800
|
}
|
|
61801
|
+
const distributiveConstraint = !(targetFlags & 16777216 /* Conditional */) && hasNonCircularBaseConstraint(source2) ? getConstraintOfDistributiveConditionalType(source2) : void 0;
|
|
61802
|
+
if (distributiveConstraint) {
|
|
61803
|
+
resetErrorInfo(saveErrorInfo);
|
|
61804
|
+
if (result2 = isRelatedTo(distributiveConstraint, target2, 1 /* Source */, reportErrors2)) {
|
|
61805
|
+
return result2;
|
|
61806
|
+
}
|
|
61807
|
+
}
|
|
61783
61808
|
} else {
|
|
61784
61809
|
if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target2) && isEmptyObjectType(source2)) {
|
|
61785
61810
|
return -1 /* True */;
|
|
@@ -63677,8 +63702,8 @@ function createTypeChecker(host) {
|
|
|
63677
63702
|
if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) {
|
|
63678
63703
|
return !!(objectFlags & 1048576 /* CouldContainTypeVariables */);
|
|
63679
63704
|
}
|
|
63680
|
-
const result = !!(type.flags & 465829888 /* Instantiable */ || type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || some(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || type.flags &
|
|
63681
|
-
if (type.flags &
|
|
63705
|
+
const result = !!(type.flags & 465829888 /* Instantiable */ || type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || some(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && some(type.types, couldContainTypeVariables));
|
|
63706
|
+
if (type.flags & 3899393 /* ObjectFlagsType */) {
|
|
63682
63707
|
type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0);
|
|
63683
63708
|
}
|
|
63684
63709
|
return result;
|
|
@@ -64805,7 +64830,8 @@ function createTypeChecker(host) {
|
|
|
64805
64830
|
if (hasOnlyExpressionInitializer(declaration) && isBlockScopedNameDeclaredBeforeUse(declaration, node)) {
|
|
64806
64831
|
const initializer = getEffectiveInitializer(declaration);
|
|
64807
64832
|
if (initializer) {
|
|
64808
|
-
|
|
64833
|
+
const initializerType = isBindingPattern(declaration.parent) ? getTypeForBindingElement(declaration) : getTypeOfExpression(initializer);
|
|
64834
|
+
return initializerType && tryGetNameFromType(initializerType);
|
|
64809
64835
|
}
|
|
64810
64836
|
if (isEnumMember(declaration)) {
|
|
64811
64837
|
return getTextOfPropertyName(declaration.name);
|
|
@@ -80651,10 +80677,11 @@ function createTypeChecker(host) {
|
|
|
80651
80677
|
node
|
|
80652
80678
|
));
|
|
80653
80679
|
if (sym) {
|
|
80680
|
+
const typeOnlyDeclaration = getTypeOnlyAliasDeclaration(sym, 111551 /* Value */);
|
|
80654
80681
|
markAliasReferenced(sym, id);
|
|
80655
80682
|
if (getSymbolFlags(sym) & 111551 /* Value */) {
|
|
80656
80683
|
checkExpressionCached(id);
|
|
80657
|
-
if (!isIllegalExportDefaultInCJS && !(node.flags & 33554432 /* Ambient */) && compilerOptions.verbatimModuleSyntax &&
|
|
80684
|
+
if (!isIllegalExportDefaultInCJS && !(node.flags & 33554432 /* Ambient */) && compilerOptions.verbatimModuleSyntax && typeOnlyDeclaration) {
|
|
80658
80685
|
error(
|
|
80659
80686
|
id,
|
|
80660
80687
|
node.isExportEquals ? Diagnostics.An_export_declaration_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration : Diagnostics.An_export_default_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration,
|
|
@@ -80668,6 +80695,33 @@ function createTypeChecker(host) {
|
|
|
80668
80695
|
idText(id)
|
|
80669
80696
|
);
|
|
80670
80697
|
}
|
|
80698
|
+
if (!isIllegalExportDefaultInCJS && getIsolatedModules(compilerOptions) && !(sym.flags & 111551 /* Value */)) {
|
|
80699
|
+
if (sym.flags & 2097152 /* Alias */ && resolveAlias(sym) !== unknownSymbol && getSymbolFlags(
|
|
80700
|
+
sym,
|
|
80701
|
+
/*excludeTypeOnlyMeanings*/
|
|
80702
|
+
false,
|
|
80703
|
+
/*excludeLocalMeanings*/
|
|
80704
|
+
true
|
|
80705
|
+
) & 788968 /* Type */ && (!typeOnlyDeclaration || getSourceFileOfNode(typeOnlyDeclaration) !== getSourceFileOfNode(node))) {
|
|
80706
|
+
error(
|
|
80707
|
+
id,
|
|
80708
|
+
node.isExportEquals ? Diagnostics._0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_import_type_where_0_is_imported : Diagnostics._0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_export_type_0_as_default,
|
|
80709
|
+
idText(id),
|
|
80710
|
+
isolatedModulesLikeFlagName
|
|
80711
|
+
);
|
|
80712
|
+
} else if (typeOnlyDeclaration && getSourceFileOfNode(typeOnlyDeclaration) !== getSourceFileOfNode(node)) {
|
|
80713
|
+
addTypeOnlyDeclarationRelatedInfo(
|
|
80714
|
+
error(
|
|
80715
|
+
id,
|
|
80716
|
+
node.isExportEquals ? Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_import_type_where_0_is_imported : Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_export_type_0_as_default,
|
|
80717
|
+
idText(id),
|
|
80718
|
+
isolatedModulesLikeFlagName
|
|
80719
|
+
),
|
|
80720
|
+
typeOnlyDeclaration,
|
|
80721
|
+
idText(id)
|
|
80722
|
+
);
|
|
80723
|
+
}
|
|
80724
|
+
}
|
|
80671
80725
|
} else {
|
|
80672
80726
|
checkExpressionCached(id);
|
|
80673
80727
|
}
|
|
@@ -82062,7 +82116,11 @@ function createTypeChecker(host) {
|
|
|
82062
82116
|
const exportClause = node.exportClause;
|
|
82063
82117
|
return !!exportClause && (isNamespaceExport(exportClause) || some(exportClause.elements, isValueAliasDeclaration));
|
|
82064
82118
|
case 277 /* ExportAssignment */:
|
|
82065
|
-
return node.expression && node.expression.kind === 80 /* Identifier */ ? isAliasResolvedToValue(
|
|
82119
|
+
return node.expression && node.expression.kind === 80 /* Identifier */ ? isAliasResolvedToValue(
|
|
82120
|
+
getSymbolOfDeclaration(node),
|
|
82121
|
+
/*excludeTypeOnlyValues*/
|
|
82122
|
+
true
|
|
82123
|
+
) : true;
|
|
82066
82124
|
}
|
|
82067
82125
|
return false;
|
|
82068
82126
|
}
|