Update LKG
This commit is contained in:
Родитель
2c5045854b
Коммит
f7bf3b2231
115
lib/tsc.js
115
lib/tsc.js
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
|
|
@ -56313,10 +56313,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,
|
||||
|
@ -56336,17 +56337,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
|
||||
|
@ -56360,13 +56351,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;
|
||||
|
@ -56375,14 +56365,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,
|
||||
|
@ -56395,6 +56384,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);
|
||||
|
@ -56528,13 +56568,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);
|
||||
|
@ -56577,25 +56617,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);
|
||||
|
@ -56660,14 +56687,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);
|
||||
|
@ -136867,12 +136892,12 @@ function isInReferenceCommentWorker(sourceFile, position, shouldBeReference) {
|
|||
);
|
||||
return !!range && shouldBeReference === tripleSlashDirectivePrefixRegex.test(sourceFile.text.substring(range.pos, range.end));
|
||||
}
|
||||
function getReplacementSpanForContextToken(contextToken) {
|
||||
function getReplacementSpanForContextToken(contextToken, position) {
|
||||
if (!contextToken) return void 0;
|
||||
switch (contextToken.kind) {
|
||||
case 11 /* StringLiteral */:
|
||||
case 15 /* NoSubstitutionTemplateLiteral */:
|
||||
return createTextSpanFromStringLiteralLikeContent(contextToken);
|
||||
return createTextSpanFromStringLiteralLikeContent(contextToken, position);
|
||||
default:
|
||||
return createTextSpanFromNode(contextToken);
|
||||
}
|
||||
|
@ -136880,11 +136905,11 @@ function getReplacementSpanForContextToken(contextToken) {
|
|||
function createTextSpanFromNode(node, sourceFile, endNode2) {
|
||||
return createTextSpanFromBounds(node.getStart(sourceFile), (endNode2 || node).getEnd());
|
||||
}
|
||||
function createTextSpanFromStringLiteralLikeContent(node) {
|
||||
function createTextSpanFromStringLiteralLikeContent(node, position) {
|
||||
let replacementEnd = node.getEnd() - 1;
|
||||
if (node.isUnterminated) {
|
||||
if (node.getStart() === replacementEnd) return void 0;
|
||||
replacementEnd = node.getEnd();
|
||||
replacementEnd = Math.min(position, node.getEnd());
|
||||
}
|
||||
return createTextSpanFromBounds(node.getStart() + 1, replacementEnd);
|
||||
}
|
||||
|
@ -158687,6 +158712,7 @@ function withContext(context, typePrintMode, cb) {
|
|||
textChanges: changeTracker.getChanges()
|
||||
};
|
||||
function addTypeAnnotation(span) {
|
||||
context.cancellationToken.throwIfCancellationRequested();
|
||||
const nodeWithDiag = getTokenAtPosition(sourceFile, span.start);
|
||||
const expandoFunction = findExpandoFunction(nodeWithDiag);
|
||||
if (expandoFunction) {
|
||||
|
@ -158758,6 +158784,7 @@ function withContext(context, typePrintMode, cb) {
|
|||
return factory.createAsExpression(factory.createSatisfiesExpression(node, getSynthesizedDeepClone(type)), type);
|
||||
}
|
||||
function addInlineAssertion(span) {
|
||||
context.cancellationToken.throwIfCancellationRequested();
|
||||
const nodeWithDiag = getTokenAtPosition(sourceFile, span.start);
|
||||
const expandoFunction = findExpandoFunction(nodeWithDiag);
|
||||
if (expandoFunction) return;
|
||||
|
@ -158815,6 +158842,7 @@ function withContext(context, typePrintMode, cb) {
|
|||
return [Diagnostics.Add_satisfies_and_an_inline_type_assertion_with_0, typeToStringForDiag(typeNode)];
|
||||
}
|
||||
function extractAsVariable(span) {
|
||||
context.cancellationToken.throwIfCancellationRequested();
|
||||
const nodeWithDiag = getTokenAtPosition(sourceFile, span.start);
|
||||
const targetNode = findBestFittingNode(nodeWithDiag, span);
|
||||
if (!targetNode || isValueSignatureDeclaration(targetNode) || isValueSignatureDeclaration(targetNode.parent)) return;
|
||||
|
@ -163311,7 +163339,7 @@ function createCompletionEntry(symbol, sortText, replacementToken, contextToken,
|
|||
var _a, _b;
|
||||
let insertText;
|
||||
let filterText;
|
||||
let replacementSpan = getReplacementSpanForContextToken(replacementToken);
|
||||
let replacementSpan = getReplacementSpanForContextToken(replacementToken, position);
|
||||
let data;
|
||||
let isSnippet;
|
||||
let source = getSourceFromOrigin(origin);
|
||||
|
@ -166305,7 +166333,7 @@ function convertStringLiteralCompletions(completion, contextToken, sourceFile, h
|
|||
if (completion === void 0) {
|
||||
return void 0;
|
||||
}
|
||||
const optionalReplacementSpan = createTextSpanFromStringLiteralLikeContent(contextToken);
|
||||
const optionalReplacementSpan = createTextSpanFromStringLiteralLikeContent(contextToken, position);
|
||||
switch (completion.kind) {
|
||||
case 0 /* Paths */:
|
||||
return convertPathCompletions(completion.paths);
|
||||
|
@ -166359,7 +166387,7 @@ function convertStringLiteralCompletions(completion, contextToken, sourceFile, h
|
|||
kindModifiers: "" /* none */,
|
||||
kind: "string" /* string */,
|
||||
sortText: SortText.LocationPriority,
|
||||
replacementSpan: getReplacementSpanForContextToken(contextToken)
|
||||
replacementSpan: getReplacementSpanForContextToken(contextToken, position)
|
||||
}));
|
||||
return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: completion.isNewIdentifier, optionalReplacementSpan, entries };
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче