Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into numeric-constraint-ma…
Browse files Browse the repository at this point in the history
…pped-type-with-name-type
  • Loading branch information
Andarist committed Nov 11, 2023
2 parents 51c588c + ca7a3af commit e33988d
Show file tree
Hide file tree
Showing 1,373 changed files with 148,760 additions and 39,318 deletions.
132 changes: 66 additions & 66 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 22 additions & 15 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6838,6 +6838,21 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
const typeId = type.id;
const symbol = type.symbol;
if (symbol) {
const isInstantiationExpressionType = !!(getObjectFlags(type) & ObjectFlags.InstantiationExpressionType);
if (isInstantiationExpressionType) {
const instantiationExpressionType = type as InstantiationExpressionType;
const existing = instantiationExpressionType.node;
if (isTypeQueryNode(existing) && getTypeFromTypeNode(existing) === type) {
const typeNode = serializeExistingTypeNode(context, existing);
if (typeNode) {
return typeNode;
}
}
if (context.visitedTypes?.has(typeId)) {
return createElidedInformationPlaceholder(context);
}
return visitAndTransformType(type, createTypeNodeFromObjectType);
}
const isInstanceType = isClassInstanceSide(type) ? SymbolFlags.Type : SymbolFlags.Value;
if (isJSConstructor(symbol.valueDeclaration)) {
// Instance and static types share the same symbol; only add 'typeof' for the static side.
Expand Down Expand Up @@ -6869,20 +6884,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}
}
else {
const isInstantiationExpressionType = !!(getObjectFlags(type) & ObjectFlags.InstantiationExpressionType);
if (isInstantiationExpressionType) {
const instantiationExpressionType = type as InstantiationExpressionType;
if (isTypeQueryNode(instantiationExpressionType.node)) {
const typeNode = serializeExistingTypeNode(context, instantiationExpressionType.node);
if (typeNode) {
return typeNode;
}
}
if (context.visitedTypes?.has(typeId)) {
return createElidedInformationPlaceholder(context);
}
return visitAndTransformType(type, createTypeNodeFromObjectType);
}
// Anonymous types without a symbol are never circular.
return createTypeNodeFromObjectType(type);
}
Expand Down Expand Up @@ -19550,6 +19551,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}

function instantiateAnonymousType(type: AnonymousType, mapper: TypeMapper, aliasSymbol?: Symbol, aliasTypeArguments?: readonly Type[]): AnonymousType {
Debug.assert(type.symbol, "anonymous type must have symbol to be instantiated");
const result = createObjectType(type.objectFlags & ~(ObjectFlags.CouldContainTypeVariablesComputed | ObjectFlags.CouldContainTypeVariables) | ObjectFlags.Instantiated, type.symbol) as AnonymousType;
if (type.objectFlags & ObjectFlags.Mapped) {
(result as MappedType).declaration = (type as MappedType).declaration;
Expand Down Expand Up @@ -23082,6 +23084,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
// method). Simply do a pairwise comparison of the signatures in the two signature lists instead
// of the much more expensive N * M comparison matrix we explore below. We erase type parameters
// as they are known to always be the same.
Debug.assertEqual(sourceSignatures.length, targetSignatures.length);
for (let i = 0; i < targetSignatures.length; i++) {
const related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors, intersectionState, incompatibleReporter(sourceSignatures[i], targetSignatures[i]));
if (!related) {
Expand Down Expand Up @@ -27249,6 +27252,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
case SyntaxKind.ElementAccessExpression:
// The resolvedSymbol property is initialized by checkPropertyAccess or checkElementAccess before we get here.
return isConstantReference((node as AccessExpression).expression) && isReadonlySymbol(getNodeLinks(node).resolvedSymbol || unknownSymbol);
case SyntaxKind.ObjectBindingPattern:
case SyntaxKind.ArrayBindingPattern:
const rootDeclaration = getRootDeclaration(node.parent);
return isVariableDeclaration(rootDeclaration) && isVarConstLike(rootDeclaration);
}
return false;
}
Expand Down Expand Up @@ -35685,7 +35692,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
hasSignatures ||= resolved.callSignatures.length !== 0 || resolved.constructSignatures.length !== 0;
hasApplicableSignature ||= callSignatures.length !== 0 || constructSignatures.length !== 0;
if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) {
const result = createAnonymousType(/*symbol*/ undefined, resolved.members, callSignatures, constructSignatures, resolved.indexInfos) as ResolvedType & InstantiationExpressionType;
const result = createAnonymousType(createSymbol(SymbolFlags.None, InternalSymbolName.InstantiationExpression), resolved.members, callSignatures, constructSignatures, resolved.indexInfos) as ResolvedType & InstantiationExpressionType;
result.objectFlags |= ObjectFlags.InstantiationExpressionType;
result.node = node;
return result;
Expand Down
1 change: 1 addition & 0 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5955,6 +5955,7 @@ export const enum InternalSymbolName {
ExportEquals = "export=", // Export assignment symbol
Default = "default", // Default export symbol (technically not wholly internal, but included here for usability)
This = "this",
InstantiationExpression = "__instantiationExpression", // Instantiation expressions
}

/**
Expand Down
Loading

0 comments on commit e33988d

Please sign in to comment.