Skip to content

Commit

Permalink
Update LKG
Browse files Browse the repository at this point in the history
  • Loading branch information
typescript-bot committed Jun 3, 2024
1 parent 2c50458 commit f7bf3b2
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 97 deletions.
115 changes: 70 additions & 45 deletions lib/tsc.js
Original file line number Diff line number Diff line change
Expand Up @@ -51544,10 +51544,11 @@ function createTypeChecker(host) {
return result ? setTextRange2(context, result, node) : void 0;
}
function createRecoveryBoundary() {
let trackedSymbols;
let unreportedErrors;
const oldTracker = context.tracker;
const oldTrackedSymbols = context.trackedSymbols;
context.trackedSymbols = [];
context.trackedSymbols = void 0;
const oldEncounteredError = context.encounteredError;
context.tracker = new SymbolTrackerImpl(context, {
...oldTracker.inner,
Expand All @@ -51567,17 +51568,7 @@ function createTypeChecker(host) {
markError(() => oldTracker.reportNonSerializableProperty(name));
},
trackSymbol(sym, decl, meaning) {
const accessibility = isSymbolAccessible(
sym,
decl,
meaning,
/*shouldComputeAliasesToMakeVisible*/
false
);
if (accessibility.accessibility !== 0 /* Accessible */) {
(context.trackedSymbols ?? (context.trackedSymbols = [])).push([sym, decl, meaning]);
return true;
}
(trackedSymbols ?? (trackedSymbols = [])).push([sym, decl, meaning]);
return false;
},
moduleResolverHost: context.tracker.moduleResolverHost
Expand All @@ -51591,13 +51582,12 @@ function createTypeChecker(host) {
(unreportedErrors ?? (unreportedErrors = [])).push(unreportedError);
}
function startRecoveryScope2() {
var _a;
const initialTrackedSymbolsTop = ((_a = context.trackedSymbols) == null ? void 0 : _a.length) ?? 0;
const trackedSymbolsTop = (trackedSymbols == null ? void 0 : trackedSymbols.length) ?? 0;
const unreportedErrorsTop = (unreportedErrors == null ? void 0 : unreportedErrors.length) ?? 0;
return () => {
hadError = false;
if (context.trackedSymbols) {
context.trackedSymbols.length = initialTrackedSymbolsTop;
if (trackedSymbols) {
trackedSymbols.length = trackedSymbolsTop;
}
if (unreportedErrors) {
unreportedErrors.length = unreportedErrorsTop;
Expand All @@ -51606,14 +51596,13 @@ function createTypeChecker(host) {
}
function finalizeBoundary2() {
context.tracker = oldTracker;
const newTrackedSymbols = context.trackedSymbols;
context.trackedSymbols = oldTrackedSymbols;
context.encounteredError = oldEncounteredError;
unreportedErrors == null ? void 0 : unreportedErrors.forEach((fn) => fn());
if (hadError) {
return false;
}
newTrackedSymbols == null ? void 0 : newTrackedSymbols.forEach(
trackedSymbols == null ? void 0 : trackedSymbols.forEach(
([symbol, enclosingDeclaration, meaning]) => context.tracker.trackSymbol(
symbol,
enclosingDeclaration,
Expand All @@ -51626,6 +51615,57 @@ function createTypeChecker(host) {
function onEnterNewScope(node) {
return enterNewScope(context, node, getParametersInScope(node), getTypeParametersInScope(node));
}
function tryVisitSimpleTypeNode(node) {
const innerNode = skipTypeParentheses(node);
switch (innerNode.kind) {
case 183 /* TypeReference */:
return tryVisitTypeReference(innerNode);
case 186 /* TypeQuery */:
return tryVisitTypeQuery(innerNode);
case 199 /* IndexedAccessType */:
return tryVisitIndexedAccess(innerNode);
case 198 /* TypeOperator */:
const typeOperatorNode = innerNode;
if (typeOperatorNode.operator === 143 /* KeyOfKeyword */) {
return tryVisitKeyOf(typeOperatorNode);
}
}
return visitNode(node, visitExistingNodeTreeSymbols, isTypeNode);
}
function tryVisitIndexedAccess(node) {
const resultObjectType = tryVisitSimpleTypeNode(node.objectType);
if (resultObjectType === void 0) {
return void 0;
}
return factory.updateIndexedAccessTypeNode(node, resultObjectType, visitNode(node.indexType, visitExistingNodeTreeSymbols, isTypeNode));
}
function tryVisitKeyOf(node) {
Debug.assertEqual(node.operator, 143 /* KeyOfKeyword */);
const type = tryVisitSimpleTypeNode(node.type);
if (type === void 0) {
return void 0;
}
return factory.updateTypeOperatorNode(node, type);
}
function tryVisitTypeQuery(node) {
const { introducesError, node: exprName } = trackExistingEntityName(node.exprName, context);
if (!introducesError) {
return factory.updateTypeQueryNode(
node,
exprName,
visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode)
);
}
const serializedName = serializeTypeName(
context,
node.exprName,
/*isTypeOf*/
true
);
if (serializedName) {
return setTextRange2(context, serializedName, node.exprName);
}
}
function tryVisitTypeReference(node) {
if (canReuseTypeNode(context, node)) {
const { introducesError, node: newName } = trackExistingEntityName(node.typeName, context);
Expand Down Expand Up @@ -51759,13 +51799,13 @@ function createTypeChecker(host) {
visitNode(node.default, visitExistingNodeTreeSymbols, isTypeNode)
);
}
if (isIndexedAccessTypeNode(node) && isTypeReferenceNode(node.objectType)) {
const objectType = tryVisitTypeReference(node.objectType);
if (!objectType) {
if (isIndexedAccessTypeNode(node)) {
const result = tryVisitIndexedAccess(node);
if (!result) {
hadError = true;
return node;
}
return factory.updateIndexedAccessTypeNode(node, objectType, visitNode(node.indexType, visitExistingNodeTreeSymbols, isTypeNode));
return result;
}
if (isTypeReferenceNode(node)) {
const result = tryVisitTypeReference(node);
Expand Down Expand Up @@ -51808,25 +51848,12 @@ function createTypeChecker(host) {
return visited;
}
if (isTypeQueryNode(node)) {
const { introducesError, node: exprName } = trackExistingEntityName(node.exprName, context);
if (introducesError) {
const serializedName = serializeTypeName(
context,
node.exprName,
/*isTypeOf*/
true
);
if (serializedName) {
return setTextRange2(context, serializedName, node.exprName);
}
const result = tryVisitTypeQuery(node);
if (!result) {
hadError = true;
return node;
}
return factory.updateTypeQueryNode(
node,
exprName,
visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode)
);
return result;
}
if (isComputedPropertyName(node) && isEntityNameExpression(node.expression)) {
const { node: result, introducesError } = trackExistingEntityName(node.expression, context);
Expand Down Expand Up @@ -51891,14 +51918,12 @@ function createTypeChecker(host) {
return node;
}
} else if (node.operator === 143 /* KeyOfKeyword */) {
if (isTypeReferenceNode(node.type)) {
const type = tryVisitTypeReference(node.type);
if (!type) {
hadError = true;
return node;
}
return factory.updateTypeOperatorNode(node, type);
const result = tryVisitKeyOf(node);
if (!result) {
hadError = true;
return node;
}
return result;
}
}
return visitEachChild2(node, visitExistingNodeTreeSymbols);
Expand Down
Loading

0 comments on commit f7bf3b2

Please sign in to comment.