mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
Update LKG
This commit is contained in:
parent
245809a746
commit
fd2ddfe12d
439
lib/tsc.js
439
lib/tsc.js
@ -10551,6 +10551,14 @@ var ts;
|
||||
}
|
||||
}
|
||||
ts.getThisContainer = getThisContainer;
|
||||
function isInTopLevelContext(node) {
|
||||
if (ts.isIdentifier(node) && (ts.isClassDeclaration(node.parent) || ts.isFunctionDeclaration(node.parent)) && node.parent.name === node) {
|
||||
node = node.parent;
|
||||
}
|
||||
var container = getThisContainer(node, true);
|
||||
return ts.isSourceFile(container);
|
||||
}
|
||||
ts.isInTopLevelContext = isInTopLevelContext;
|
||||
function getNewTargetContainer(node) {
|
||||
var container = getThisContainer(node, false);
|
||||
if (container) {
|
||||
@ -11639,13 +11647,7 @@ var ts;
|
||||
case 198:
|
||||
return parent.name === node;
|
||||
case 156:
|
||||
if (parent.right === node) {
|
||||
while (parent.kind === 156) {
|
||||
parent = parent.parent;
|
||||
}
|
||||
return parent.kind === 175 || parent.kind === 172;
|
||||
}
|
||||
return false;
|
||||
return parent.right === node;
|
||||
case 195:
|
||||
case 262:
|
||||
return parent.propertyName === node;
|
||||
@ -22057,31 +22059,6 @@ var ts;
|
||||
createBaseNode: function (kind) { return countNode(new NodeConstructor(kind, 0, 0)); }
|
||||
};
|
||||
var factory = ts.createNodeFactory(1 | 2 | 8, baseNodeFactory);
|
||||
var reparseContext = {
|
||||
get factory() { return factory; },
|
||||
enableEmitNotification: ts.notImplemented,
|
||||
enableSubstitution: ts.notImplemented,
|
||||
endLexicalEnvironment: ts.returnUndefined,
|
||||
getCompilerOptions: ts.notImplemented,
|
||||
getEmitHost: ts.notImplemented,
|
||||
getEmitResolver: ts.notImplemented,
|
||||
getEmitHelperFactory: ts.notImplemented,
|
||||
setLexicalEnvironmentFlags: ts.noop,
|
||||
getLexicalEnvironmentFlags: function () { return 0; },
|
||||
hoistFunctionDeclaration: ts.notImplemented,
|
||||
hoistVariableDeclaration: ts.notImplemented,
|
||||
addInitializationStatement: ts.notImplemented,
|
||||
isEmitNotificationEnabled: ts.notImplemented,
|
||||
isSubstitutionEnabled: ts.notImplemented,
|
||||
onEmitNode: ts.notImplemented,
|
||||
onSubstituteNode: ts.notImplemented,
|
||||
readEmitHelpers: ts.notImplemented,
|
||||
requestEmitHelper: ts.notImplemented,
|
||||
resumeLexicalEnvironment: ts.noop,
|
||||
startLexicalEnvironment: ts.noop,
|
||||
suspendLexicalEnvironment: ts.noop,
|
||||
addDiagnostic: ts.notImplemented,
|
||||
};
|
||||
var fileName;
|
||||
var sourceFlags;
|
||||
var sourceText;
|
||||
@ -22099,6 +22076,7 @@ var ts;
|
||||
var parsingContext;
|
||||
var notParenthesizedArrow;
|
||||
var contextFlags;
|
||||
var topLevel = true;
|
||||
var parseErrorBeforeNextFinishedNode = false;
|
||||
function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) {
|
||||
if (setParentNodes === void 0) { setParentNodes = false; }
|
||||
@ -22210,6 +22188,7 @@ var ts;
|
||||
identifierCount = 0;
|
||||
nodeCount = 0;
|
||||
sourceFlags = 0;
|
||||
topLevel = true;
|
||||
switch (scriptKind) {
|
||||
case 1:
|
||||
case 2:
|
||||
@ -22243,6 +22222,7 @@ var ts;
|
||||
parsingContext = 0;
|
||||
identifiers = undefined;
|
||||
notParenthesizedArrow = undefined;
|
||||
topLevel = true;
|
||||
}
|
||||
function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind) {
|
||||
var isDeclarationFile = isDeclarationFileName(fileName);
|
||||
@ -22289,106 +22269,90 @@ var ts;
|
||||
return node;
|
||||
}
|
||||
function reparseTopLevelAwait(sourceFile) {
|
||||
return ts.visitEachChild(sourceFile, visitor, reparseContext);
|
||||
function visitor(node) {
|
||||
if (!(node.transformFlags & 8388608)) {
|
||||
return node;
|
||||
var savedSyntaxCursor = syntaxCursor;
|
||||
var baseSyntaxCursor = IncrementalParser.createSyntaxCursor(sourceFile);
|
||||
syntaxCursor = { currentNode: currentNode };
|
||||
var statements = [];
|
||||
var savedParseDiagnostics = parseDiagnostics;
|
||||
parseDiagnostics = [];
|
||||
var pos = 0;
|
||||
var start = findNextStatementWithAwait(sourceFile.statements, 0);
|
||||
var _loop_3 = function () {
|
||||
var prevStatement = sourceFile.statements[pos];
|
||||
var nextStatement = sourceFile.statements[start];
|
||||
ts.addRange(statements, sourceFile.statements, pos, start);
|
||||
pos = findNextStatementWithoutAwait(sourceFile.statements, start);
|
||||
var diagnosticStart = ts.findIndex(savedParseDiagnostics, function (diagnostic) { return diagnostic.start >= prevStatement.pos; });
|
||||
var diagnosticEnd = diagnosticStart >= 0 ? ts.findIndex(savedParseDiagnostics, function (diagnostic) { return diagnostic.start >= nextStatement.pos; }, diagnosticStart) : -1;
|
||||
if (diagnosticStart >= 0) {
|
||||
ts.addRange(parseDiagnostics, savedParseDiagnostics, diagnosticStart, diagnosticEnd >= 0 ? diagnosticEnd : undefined);
|
||||
}
|
||||
switch (node.kind) {
|
||||
case 160: return reparseDecorator(node);
|
||||
case 157: return reparseComputedPropertyName(node);
|
||||
case 220: return reparseExpressionWithTypeArguments(node);
|
||||
case 230: return reparseExpressionStatement(node);
|
||||
case 231: return reparseIfStatement(node);
|
||||
case 241: return reparseSwitchStatement(node);
|
||||
case 240: return reparseWithStatement(node);
|
||||
case 232: return reparseDoStatement(node);
|
||||
case 233: return reparseWhileStatement(node);
|
||||
case 234: return reparseForStatement(node);
|
||||
case 235: return reparseForInStatement(node);
|
||||
case 236: return reparseForOfStatement(node);
|
||||
case 239: return reparseReturnStatement(node);
|
||||
case 243: return reparseThrowStatement(node);
|
||||
case 263: return reparseExportAssignment(node);
|
||||
case 246: return reparseVariableDeclaration(node);
|
||||
case 195: return reparseBindingElement(node);
|
||||
default: return ts.visitEachChild(node, visitor, reparseContext);
|
||||
speculationHelper(function () {
|
||||
var savedContextFlags = contextFlags;
|
||||
contextFlags |= 32768;
|
||||
scanner.setTextPos(nextStatement.pos);
|
||||
nextToken();
|
||||
while (token() !== 1) {
|
||||
var startPos = scanner.getStartPos();
|
||||
var statement = parseListElement(0, parseStatement);
|
||||
statements.push(statement);
|
||||
if (startPos === scanner.getStartPos()) {
|
||||
nextToken();
|
||||
}
|
||||
if (pos >= 0) {
|
||||
var nonAwaitStatement = sourceFile.statements[pos];
|
||||
if (statement.end === nonAwaitStatement.pos) {
|
||||
break;
|
||||
}
|
||||
if (statement.end > nonAwaitStatement.pos) {
|
||||
pos = findNextStatementWithoutAwait(sourceFile.statements, pos + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
contextFlags = savedContextFlags;
|
||||
}, 2);
|
||||
start = pos >= 0 ? findNextStatementWithAwait(sourceFile.statements, pos) : -1;
|
||||
};
|
||||
while (start !== -1) {
|
||||
_loop_3();
|
||||
}
|
||||
if (pos >= 0) {
|
||||
var prevStatement_1 = sourceFile.statements[pos];
|
||||
ts.addRange(statements, sourceFile.statements, pos);
|
||||
var diagnosticStart = ts.findIndex(savedParseDiagnostics, function (diagnostic) { return diagnostic.start >= prevStatement_1.pos; });
|
||||
if (diagnosticStart >= 0) {
|
||||
ts.addRange(parseDiagnostics, savedParseDiagnostics, diagnosticStart);
|
||||
}
|
||||
}
|
||||
function reparse(node, parse) {
|
||||
if (node && node.transformFlags & 8388608) {
|
||||
if (ts.isExpression(node)) {
|
||||
return speculationHelper(function () {
|
||||
scanner.setTextPos(node.pos);
|
||||
var savedContextFlags = contextFlags;
|
||||
contextFlags = node.flags & 25358336;
|
||||
nextToken();
|
||||
var result = doInAwaitContext(parse);
|
||||
contextFlags = savedContextFlags;
|
||||
return result;
|
||||
}, 2);
|
||||
syntaxCursor = savedSyntaxCursor;
|
||||
return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements));
|
||||
function containsPossibleTopLevelAwait(node) {
|
||||
return !(node.flags & 32768)
|
||||
&& !!(node.transformFlags & 8388608);
|
||||
}
|
||||
function findNextStatementWithAwait(statements, start) {
|
||||
for (var i = start; i < statements.length; i++) {
|
||||
if (containsPossibleTopLevelAwait(statements[i])) {
|
||||
return i;
|
||||
}
|
||||
return ts.visitEachChild(node, visitor, reparseContext);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
function findNextStatementWithoutAwait(statements, start) {
|
||||
for (var i = start; i < statements.length; i++) {
|
||||
if (!containsPossibleTopLevelAwait(statements[i])) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
function currentNode(position) {
|
||||
var node = baseSyntaxCursor.currentNode(position);
|
||||
if (topLevel && node && containsPossibleTopLevelAwait(node)) {
|
||||
node.intersectsChange = true;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
function update(updated, original) {
|
||||
if (updated !== original) {
|
||||
ts.setNodeFlags(updated, updated.flags | 32768);
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
function reparseExpressionStatement(node) {
|
||||
return update(factory.updateExpressionStatement(node, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseReturnStatement(node) {
|
||||
return update(factory.updateReturnStatement(node, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseThrowStatement(node) {
|
||||
return update(factory.updateThrowStatement(node, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseIfStatement(node) {
|
||||
return update(factory.updateIfStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.thenStatement, visitor), ts.visitNode(node.elseStatement, visitor)), node);
|
||||
}
|
||||
function reparseSwitchStatement(node) {
|
||||
return update(factory.updateSwitchStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.caseBlock, visitor)), node);
|
||||
}
|
||||
function reparseWithStatement(node) {
|
||||
return update(factory.updateWithStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
|
||||
}
|
||||
function reparseDoStatement(node) {
|
||||
return update(factory.updateDoStatement(node, ts.visitNode(node.statement, visitor), reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseWhileStatement(node) {
|
||||
return update(factory.updateWhileStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
|
||||
}
|
||||
function reparseForStatement(node) {
|
||||
return update(factory.updateForStatement(node, reparse(node.initializer, parseExpression), reparse(node.condition, parseExpression), reparse(node.incrementor, parseExpression), ts.visitNode(node, visitor)), node);
|
||||
}
|
||||
function reparseForInStatement(node) {
|
||||
return update(factory.updateForInStatement(node, reparse(node.initializer, parseExpression), reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
|
||||
}
|
||||
function reparseForOfStatement(node) {
|
||||
return update(factory.updateForOfStatement(node, node.awaitModifier, reparse(node.initializer, parseExpression), reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
|
||||
}
|
||||
function reparseExportAssignment(node) {
|
||||
return update(factory.updateExportAssignment(node, ts.visitNodes(node.decorators, visitor), node.modifiers, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseExpressionWithTypeArguments(node) {
|
||||
return update(factory.updateExpressionWithTypeArguments(node, reparse(node.expression, parseLeftHandSideExpressionOrHigher), node.typeArguments), node);
|
||||
}
|
||||
function reparseDecorator(node) {
|
||||
return update(factory.updateDecorator(node, reparse(node.expression, parseLeftHandSideExpressionOrHigher)), node);
|
||||
}
|
||||
function reparseComputedPropertyName(node) {
|
||||
return update(factory.updateComputedPropertyName(node, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseVariableDeclaration(node) {
|
||||
return update(factory.updateVariableDeclaration(node, ts.visitNode(node.name, visitor), node.exclamationToken, node.type, reparse(node.initializer, parseExpression)), node);
|
||||
}
|
||||
function reparseBindingElement(node) {
|
||||
return update(factory.updateBindingElement(node, node.dotDotDotToken, ts.visitNode(node.propertyName, visitor), ts.visitNode(node.name, visitor), reparse(node.initializer, parseExpression)), node);
|
||||
}
|
||||
}
|
||||
function fixupParentReferences(rootNode) {
|
||||
ts.setParentRecursive(rootNode, true);
|
||||
@ -22582,6 +22546,12 @@ var ts;
|
||||
function tryParse(callback) {
|
||||
return speculationHelper(callback, 0);
|
||||
}
|
||||
function isBindingIdentifier() {
|
||||
if (token() === 78) {
|
||||
return true;
|
||||
}
|
||||
return token() > 115;
|
||||
}
|
||||
function isIdentifier() {
|
||||
if (token() === 78) {
|
||||
return true;
|
||||
@ -22734,6 +22704,9 @@ var ts;
|
||||
ts.Diagnostics.Identifier_expected;
|
||||
return createMissingNode(78, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg);
|
||||
}
|
||||
function parseBindingIdentifier(privateIdentifierDiagnosticMessage) {
|
||||
return createIdentifier(isBindingIdentifier(), undefined, privateIdentifierDiagnosticMessage);
|
||||
}
|
||||
function parseIdentifier(diagnosticMessage, privateIdentifierDiagnosticMessage) {
|
||||
return createIdentifier(isIdentifier(), diagnosticMessage, privateIdentifierDiagnosticMessage);
|
||||
}
|
||||
@ -22886,9 +22859,9 @@ var ts;
|
||||
return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword();
|
||||
}
|
||||
case 8:
|
||||
return isIdentifierOrPrivateIdentifierOrPattern();
|
||||
return isBindingIdentifierOrPrivateIdentifierOrPattern();
|
||||
case 10:
|
||||
return token() === 27 || token() === 25 || isIdentifierOrPrivateIdentifierOrPattern();
|
||||
return token() === 27 || token() === 25 || isBindingIdentifierOrPrivateIdentifierOrPattern();
|
||||
case 19:
|
||||
return isIdentifier();
|
||||
case 15:
|
||||
@ -23538,7 +23511,7 @@ var ts;
|
||||
}
|
||||
function isStartOfParameter(isJSDocParameter) {
|
||||
return token() === 25 ||
|
||||
isIdentifierOrPrivateIdentifierOrPattern() ||
|
||||
isBindingIdentifierOrPrivateIdentifierOrPattern() ||
|
||||
ts.isModifierKind(token()) ||
|
||||
token() === 59 ||
|
||||
isStartOfType(!isJSDocParameter);
|
||||
@ -23550,15 +23523,26 @@ var ts;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
function parseParameterInOuterAwaitContext() {
|
||||
return parseParameterWorker(true);
|
||||
}
|
||||
function parseParameter() {
|
||||
return parseParameterWorker(false);
|
||||
}
|
||||
function parseParameterWorker(inOuterAwaitContext) {
|
||||
var pos = getNodePos();
|
||||
var hasJSDoc = hasPrecedingJSDocComment();
|
||||
if (token() === 107) {
|
||||
var node = factory.createParameterDeclaration(undefined, undefined, undefined, createIdentifier(true), undefined, parseTypeAnnotation(), undefined);
|
||||
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
||||
var node_1 = factory.createParameterDeclaration(undefined, undefined, undefined, createIdentifier(true), undefined, parseTypeAnnotation(), undefined);
|
||||
return withJSDoc(finishNode(node_1, pos), hasJSDoc);
|
||||
}
|
||||
var modifiers;
|
||||
return withJSDoc(finishNode(factory.createParameterDeclaration(parseDecorators(), modifiers = parseModifiers(), parseOptionalToken(25), parseNameOfParameter(modifiers), parseOptionalToken(57), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc);
|
||||
var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators();
|
||||
var savedTopLevel = topLevel;
|
||||
topLevel = false;
|
||||
var modifiers = parseModifiers();
|
||||
var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, parseOptionalToken(25), parseNameOfParameter(modifiers), parseOptionalToken(57), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc);
|
||||
topLevel = savedTopLevel;
|
||||
return node;
|
||||
}
|
||||
function parseReturnType(returnToken, isType) {
|
||||
if (shouldParseReturnType(returnToken, isType)) {
|
||||
@ -23587,7 +23571,7 @@ var ts;
|
||||
setAwaitContext(!!(flags & 2));
|
||||
var parameters = flags & 32 ?
|
||||
parseDelimitedList(17, parseJSDocParameter) :
|
||||
parseDelimitedList(16, parseParameter);
|
||||
parseDelimitedList(16, savedAwaitContext ? parseParameterInOuterAwaitContext : parseParameter);
|
||||
setYieldContext(savedYieldContext);
|
||||
setAwaitContext(savedAwaitContext);
|
||||
return parameters;
|
||||
@ -24480,9 +24464,13 @@ var ts;
|
||||
!isStartOfExpressionStatement()) {
|
||||
return parseFunctionBlock(16 | (isAsync ? 2 : 0));
|
||||
}
|
||||
return isAsync
|
||||
var savedTopLevel = topLevel;
|
||||
topLevel = false;
|
||||
var node = isAsync
|
||||
? doInAwaitContext(parseAssignmentExpressionOrHigher)
|
||||
: doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
|
||||
topLevel = savedTopLevel;
|
||||
return node;
|
||||
}
|
||||
function parseConditionalExpressionRest(leftOperand, pos) {
|
||||
var questionToken = parseOptionalToken(57);
|
||||
@ -25215,10 +25203,10 @@ var ts;
|
||||
var asteriskToken = parseOptionalToken(41);
|
||||
var isGenerator = asteriskToken ? 1 : 0;
|
||||
var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 : 0;
|
||||
var name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) :
|
||||
isGenerator ? doInYieldContext(parseOptionalIdentifier) :
|
||||
isAsync ? doInAwaitContext(parseOptionalIdentifier) :
|
||||
parseOptionalIdentifier();
|
||||
var name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalBindingIdentifier) :
|
||||
isGenerator ? doInYieldContext(parseOptionalBindingIdentifier) :
|
||||
isAsync ? doInAwaitContext(parseOptionalBindingIdentifier) :
|
||||
parseOptionalBindingIdentifier();
|
||||
var typeParameters = parseTypeParameters();
|
||||
var parameters = parseParameters(isGenerator | isAsync);
|
||||
var type = parseReturnType(58, false);
|
||||
@ -25229,8 +25217,8 @@ var ts;
|
||||
var node = factory.createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body);
|
||||
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
||||
}
|
||||
function parseOptionalIdentifier() {
|
||||
return isIdentifier() ? parseIdentifier() : undefined;
|
||||
function parseOptionalBindingIdentifier() {
|
||||
return isBindingIdentifier() ? parseBindingIdentifier() : undefined;
|
||||
}
|
||||
function parseNewExpressionOrNewDotTarget() {
|
||||
var pos = getNodePos();
|
||||
@ -25285,6 +25273,8 @@ var ts;
|
||||
setYieldContext(!!(flags & 1));
|
||||
var savedAwaitContext = inAwaitContext();
|
||||
setAwaitContext(!!(flags & 2));
|
||||
var savedTopLevel = topLevel;
|
||||
topLevel = false;
|
||||
var saveDecoratorContext = inDecoratorContext();
|
||||
if (saveDecoratorContext) {
|
||||
setDecoratorContext(false);
|
||||
@ -25293,6 +25283,7 @@ var ts;
|
||||
if (saveDecoratorContext) {
|
||||
setDecoratorContext(true);
|
||||
}
|
||||
topLevel = savedTopLevel;
|
||||
setYieldContext(savedYieldContext);
|
||||
setAwaitContext(savedAwaitContext);
|
||||
return block;
|
||||
@ -25791,7 +25782,7 @@ var ts;
|
||||
function parseObjectBindingElement() {
|
||||
var pos = getNodePos();
|
||||
var dotDotDotToken = parseOptionalToken(25);
|
||||
var tokenIsIdentifier = isIdentifier();
|
||||
var tokenIsIdentifier = isBindingIdentifier();
|
||||
var propertyName = parsePropertyName();
|
||||
var name;
|
||||
if (tokenIsIdentifier && token() !== 58) {
|
||||
@ -25819,11 +25810,11 @@ var ts;
|
||||
parseExpected(23);
|
||||
return finishNode(factory.createArrayBindingPattern(elements), pos);
|
||||
}
|
||||
function isIdentifierOrPrivateIdentifierOrPattern() {
|
||||
function isBindingIdentifierOrPrivateIdentifierOrPattern() {
|
||||
return token() === 18
|
||||
|| token() === 22
|
||||
|| token() === 79
|
||||
|| isIdentifier();
|
||||
|| isBindingIdentifier();
|
||||
}
|
||||
function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) {
|
||||
if (token() === 22) {
|
||||
@ -25832,7 +25823,7 @@ var ts;
|
||||
if (token() === 18) {
|
||||
return parseObjectBindingPattern();
|
||||
}
|
||||
return parseIdentifier(undefined, privateIdentifierDiagnosticMessage);
|
||||
return parseBindingIdentifier(privateIdentifierDiagnosticMessage);
|
||||
}
|
||||
function parseVariableDeclarationAllowExclamation() {
|
||||
return parseVariableDeclaration(true);
|
||||
@ -25893,7 +25884,7 @@ var ts;
|
||||
var modifierFlags = ts.modifiersToFlags(modifiers);
|
||||
parseExpected(97);
|
||||
var asteriskToken = parseOptionalToken(41);
|
||||
var name = modifierFlags & 512 ? parseOptionalIdentifier() : parseIdentifier();
|
||||
var name = modifierFlags & 512 ? parseOptionalBindingIdentifier() : parseBindingIdentifier();
|
||||
var isGenerator = asteriskToken ? 1 : 0;
|
||||
var isAsync = modifierFlags & 256 ? 2 : 0;
|
||||
var typeParameters = parseTypeParameters();
|
||||
@ -26013,12 +26004,22 @@ var ts;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function parseDecoratorExpression() {
|
||||
if (inAwaitContext() && token() === 130) {
|
||||
var pos = getNodePos();
|
||||
var awaitExpression = parseIdentifier(ts.Diagnostics.Expression_expected);
|
||||
nextToken();
|
||||
var memberExpression = parseMemberExpressionRest(pos, awaitExpression, true);
|
||||
return parseCallExpressionRest(pos, memberExpression);
|
||||
}
|
||||
return parseLeftHandSideExpressionOrHigher();
|
||||
}
|
||||
function tryParseDecorator() {
|
||||
var pos = getNodePos();
|
||||
if (!parseOptional(59)) {
|
||||
return undefined;
|
||||
}
|
||||
var expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher);
|
||||
var expression = doInDecoratorContext(parseDecoratorExpression);
|
||||
return finishNode(factory.createDecorator(expression), pos);
|
||||
}
|
||||
function parseDecorators() {
|
||||
@ -26138,8 +26139,8 @@ var ts;
|
||||
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
||||
}
|
||||
function parseNameOfClassDeclarationOrExpression() {
|
||||
return isIdentifier() && !isImplementsClause()
|
||||
? parseIdentifier()
|
||||
return isBindingIdentifier() && !isImplementsClause()
|
||||
? createIdentifier(isBindingIdentifier())
|
||||
: undefined;
|
||||
}
|
||||
function isImplementsClause() {
|
||||
@ -27603,6 +27604,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
IncrementalParser.createSyntaxCursor = createSyntaxCursor;
|
||||
})(IncrementalParser || (IncrementalParser = {}));
|
||||
function isDeclarationFileName(fileName) {
|
||||
return ts.fileExtensionIs(fileName, ".d.ts");
|
||||
@ -29277,7 +29279,7 @@ var ts;
|
||||
}
|
||||
function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) {
|
||||
var result = returnValue ? {} : undefined;
|
||||
var _loop_3 = function (element) {
|
||||
var _loop_4 = function (element) {
|
||||
if (element.kind !== 285) {
|
||||
errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected));
|
||||
return "continue";
|
||||
@ -29325,7 +29327,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
|
||||
var element = _a[_i];
|
||||
_loop_3(element);
|
||||
_loop_4(element);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -29489,7 +29491,7 @@ var ts;
|
||||
var optionsNameMap = _a.optionsNameMap;
|
||||
var result = ts.createMap();
|
||||
var getCanonicalFileName = pathOptions && ts.createGetCanonicalFileName(pathOptions.useCaseSensitiveFileNames);
|
||||
var _loop_4 = function (name) {
|
||||
var _loop_5 = function (name) {
|
||||
if (ts.hasProperty(options, name)) {
|
||||
if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) {
|
||||
return "continue";
|
||||
@ -29518,7 +29520,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var name in options) {
|
||||
_loop_4(name);
|
||||
_loop_5(name);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -30138,7 +30140,7 @@ var ts;
|
||||
}
|
||||
var jsonOnlyIncludeRegexes;
|
||||
if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) {
|
||||
var _loop_5 = function (file) {
|
||||
var _loop_6 = function (file) {
|
||||
if (ts.fileExtensionIs(file, ".json")) {
|
||||
if (!jsonOnlyIncludeRegexes) {
|
||||
var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json"); });
|
||||
@ -30165,7 +30167,7 @@ var ts;
|
||||
};
|
||||
for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensionsWithJsonIfResolveJsonModule, validatedExcludeSpecs, validatedIncludeSpecs, undefined); _a < _b.length; _a++) {
|
||||
var file = _b[_a];
|
||||
_loop_5(file);
|
||||
_loop_6(file);
|
||||
}
|
||||
}
|
||||
var literalFiles = ts.arrayFrom(literalFileMap.values());
|
||||
@ -33063,16 +33065,27 @@ var ts;
|
||||
parent = saveParent;
|
||||
currentFlow = saveCurrentFlow;
|
||||
}
|
||||
function checkStrictModeIdentifier(node) {
|
||||
if (inStrictMode &&
|
||||
node.originalKeywordKind >= 116 &&
|
||||
node.originalKeywordKind <= 124 &&
|
||||
!ts.isIdentifierName(node) &&
|
||||
function checkContextualIdentifier(node) {
|
||||
if (!file.parseDiagnostics.length &&
|
||||
!(node.flags & 8388608) &&
|
||||
!(node.flags & 4194304)) {
|
||||
if (!file.parseDiagnostics.length) {
|
||||
!(node.flags & 4194304) &&
|
||||
!ts.isIdentifierName(node)) {
|
||||
if (inStrictMode &&
|
||||
node.originalKeywordKind >= 116 &&
|
||||
node.originalKeywordKind <= 124) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node)));
|
||||
}
|
||||
else if (node.originalKeywordKind === 130) {
|
||||
if (ts.isExternalModule(file) && ts.isInTopLevelContext(node)) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.declarationNameToString(node)));
|
||||
}
|
||||
else if (node.flags & 32768) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node)));
|
||||
}
|
||||
}
|
||||
else if (node.originalKeywordKind === 124 && node.flags & 8192) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node)));
|
||||
}
|
||||
}
|
||||
}
|
||||
function getStrictModeIdentifierMessage(node) {
|
||||
@ -33278,7 +33291,7 @@ var ts;
|
||||
if (currentFlow && (ts.isExpression(node) || parent.kind === 286)) {
|
||||
node.flowNode = currentFlow;
|
||||
}
|
||||
return checkStrictModeIdentifier(node);
|
||||
return checkContextualIdentifier(node);
|
||||
case 105:
|
||||
node.flowNode = currentFlow;
|
||||
break;
|
||||
@ -35112,7 +35125,7 @@ var ts;
|
||||
function addDuplicateDeclarationError(node, message, symbolName, relatedNodes) {
|
||||
var errorNode = (ts.getExpandoInitializer(node, false) ? ts.getNameOfExpando(node) : ts.getNameOfDeclaration(node)) || node;
|
||||
var err = lookupOrIssueError(errorNode, message, symbolName);
|
||||
var _loop_6 = function (relatedNode) {
|
||||
var _loop_7 = function (relatedNode) {
|
||||
var adjustedNode = (ts.getExpandoInitializer(relatedNode, false) ? ts.getNameOfExpando(relatedNode) : ts.getNameOfDeclaration(relatedNode)) || relatedNode;
|
||||
if (adjustedNode === errorNode)
|
||||
return "continue";
|
||||
@ -35125,7 +35138,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, _a = relatedNodes || ts.emptyArray; _i < _a.length; _i++) {
|
||||
var relatedNode = _a[_i];
|
||||
_loop_6(relatedNode);
|
||||
_loop_7(relatedNode);
|
||||
}
|
||||
}
|
||||
function combineSymbolTables(first, second) {
|
||||
@ -37026,7 +37039,7 @@ var ts;
|
||||
}
|
||||
function forEachSymbolTableInScope(enclosingDeclaration, callback) {
|
||||
var result;
|
||||
var _loop_7 = function (location) {
|
||||
var _loop_8 = function (location) {
|
||||
if (location.locals && !isGlobalSourceFile(location)) {
|
||||
if (result = callback(location.locals)) {
|
||||
return { value: result };
|
||||
@ -37059,7 +37072,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var location = enclosingDeclaration; location; location = location.parent) {
|
||||
var state_2 = _loop_7(location);
|
||||
var state_2 = _loop_8(location);
|
||||
if (typeof state_2 === "object")
|
||||
return state_2.value;
|
||||
}
|
||||
@ -38886,7 +38899,7 @@ var ts;
|
||||
if (ts.length(reexports) > 1) {
|
||||
var groups = ts.group(reexports, function (decl) { return ts.isStringLiteral(decl.moduleSpecifier) ? ">" + decl.moduleSpecifier.text : ">"; });
|
||||
if (groups.length !== reexports.length) {
|
||||
var _loop_8 = function (group_1) {
|
||||
var _loop_9 = function (group_1) {
|
||||
if (group_1.length > 1) {
|
||||
statements = __spreadArrays(ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), [
|
||||
ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamedExports(ts.flatMap(group_1, function (e) { return ts.cast(e.exportClause, ts.isNamedExports).elements; })), group_1[0].moduleSpecifier)
|
||||
@ -38895,7 +38908,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) {
|
||||
var group_1 = groups_1[_i];
|
||||
_loop_8(group_1);
|
||||
_loop_9(group_1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -41829,7 +41842,7 @@ var ts;
|
||||
if (!ts.length(result) && indexWithLengthOverOne !== -1) {
|
||||
var masterList = signatureLists[indexWithLengthOverOne !== undefined ? indexWithLengthOverOne : 0];
|
||||
var results = masterList.slice();
|
||||
var _loop_9 = function (signatures) {
|
||||
var _loop_10 = function (signatures) {
|
||||
if (signatures !== masterList) {
|
||||
var signature_1 = signatures[0];
|
||||
ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass");
|
||||
@ -41841,7 +41854,7 @@ var ts;
|
||||
};
|
||||
for (var _b = 0, signatureLists_1 = signatureLists; _b < signatureLists_1.length; _b++) {
|
||||
var signatures = signatureLists_1[_b];
|
||||
var state_3 = _loop_9(signatures);
|
||||
var state_3 = _loop_10(signatures);
|
||||
if (state_3 === "break")
|
||||
break;
|
||||
}
|
||||
@ -41956,7 +41969,7 @@ var ts;
|
||||
var types = type.types;
|
||||
var mixinFlags = findMixins(types);
|
||||
var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; });
|
||||
var _loop_10 = function (i) {
|
||||
var _loop_11 = function (i) {
|
||||
var t = type.types[i];
|
||||
if (!mixinFlags[i]) {
|
||||
var signatures = getSignaturesOfType(t, 1);
|
||||
@ -41974,19 +41987,19 @@ var ts;
|
||||
numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1));
|
||||
};
|
||||
for (var i = 0; i < types.length; i++) {
|
||||
_loop_10(i);
|
||||
_loop_11(i);
|
||||
}
|
||||
setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo);
|
||||
}
|
||||
function appendSignatures(signatures, newSignatures) {
|
||||
var _loop_11 = function (sig) {
|
||||
var _loop_12 = function (sig) {
|
||||
if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, false, false, false, compareTypesIdentical); })) {
|
||||
signatures = ts.append(signatures, sig);
|
||||
}
|
||||
};
|
||||
for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) {
|
||||
var sig = newSignatures_1[_i];
|
||||
_loop_11(sig);
|
||||
_loop_12(sig);
|
||||
}
|
||||
return signatures;
|
||||
}
|
||||
@ -44032,7 +44045,7 @@ var ts;
|
||||
var expandedDeclarations = [];
|
||||
var optionalIndex = -1;
|
||||
var restTypes;
|
||||
var _loop_12 = function (i) {
|
||||
var _loop_13 = function (i) {
|
||||
var type = elementTypes[i];
|
||||
var flags = target.elementFlags[i];
|
||||
if (flags & 8) {
|
||||
@ -44051,7 +44064,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var i = 0; i < elementTypes.length; i++) {
|
||||
_loop_12(i);
|
||||
_loop_13(i);
|
||||
}
|
||||
if (restTypes) {
|
||||
expandedTypes[expandedTypes.length - 1] = getUnionType(restTypes);
|
||||
@ -44976,7 +44989,7 @@ var ts;
|
||||
function getConditionalType(root, mapper) {
|
||||
var result;
|
||||
var extraTypes;
|
||||
var _loop_13 = function () {
|
||||
var _loop_14 = function () {
|
||||
var checkType = instantiateType(root.checkType, mapper);
|
||||
var checkTypeInstantiable = isGenericObjectType(checkType) || isGenericIndexType(checkType);
|
||||
var extendsType = instantiateType(root.extendsType, mapper);
|
||||
@ -45025,7 +45038,7 @@ var ts;
|
||||
return "break";
|
||||
};
|
||||
while (true) {
|
||||
var state_4 = _loop_13();
|
||||
var state_4 = _loop_14();
|
||||
if (typeof state_4 === "object")
|
||||
return state_4.value;
|
||||
if (state_4 === "break")
|
||||
@ -47216,7 +47229,7 @@ var ts;
|
||||
reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
|
||||
checkTypes = reducedTarget.flags & 1048576 ? reducedTarget.types : [reducedTarget];
|
||||
}
|
||||
var _loop_14 = function (prop) {
|
||||
var _loop_15 = function (prop) {
|
||||
if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
|
||||
if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
|
||||
if (reportErrors) {
|
||||
@ -47269,7 +47282,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) {
|
||||
var prop = _a[_i];
|
||||
var state_5 = _loop_14(prop);
|
||||
var state_5 = _loop_15(prop);
|
||||
if (typeof state_5 === "object")
|
||||
return state_5.value;
|
||||
}
|
||||
@ -47821,11 +47834,11 @@ var ts;
|
||||
}
|
||||
var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
|
||||
var matchingTypes = [];
|
||||
var _loop_15 = function (combination) {
|
||||
var _loop_16 = function (combination) {
|
||||
var hasMatch = false;
|
||||
outer: for (var _i = 0, _a = target.types; _i < _a.length; _i++) {
|
||||
var type = _a[_i];
|
||||
var _loop_16 = function (i) {
|
||||
var _loop_17 = function (i) {
|
||||
var sourceProperty = sourcePropertiesFiltered[i];
|
||||
var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
|
||||
if (!targetProperty)
|
||||
@ -47838,7 +47851,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
|
||||
var state_7 = _loop_16(i);
|
||||
var state_7 = _loop_17(i);
|
||||
switch (state_7) {
|
||||
case "continue-outer": continue outer;
|
||||
}
|
||||
@ -47852,7 +47865,7 @@ var ts;
|
||||
};
|
||||
for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
|
||||
var combination = discriminantCombinations_1[_a];
|
||||
var state_6 = _loop_15(combination);
|
||||
var state_6 = _loop_16(combination);
|
||||
if (typeof state_6 === "object")
|
||||
return state_6.value;
|
||||
}
|
||||
@ -48433,7 +48446,7 @@ var ts;
|
||||
if (!variances) {
|
||||
cache.variances = ts.emptyArray;
|
||||
variances = [];
|
||||
var _loop_17 = function (tp) {
|
||||
var _loop_18 = function (tp) {
|
||||
var unmeasurable = false;
|
||||
var unreliable = false;
|
||||
var oldHandler = outofbandVarianceMarkerHandler;
|
||||
@ -48458,7 +48471,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) {
|
||||
var tp = typeParameters_1[_i];
|
||||
_loop_17(tp);
|
||||
_loop_18(tp);
|
||||
}
|
||||
cache.variances = variances;
|
||||
}
|
||||
@ -54858,7 +54871,7 @@ var ts;
|
||||
var spreadIndex = getSpreadArgumentIndex(args);
|
||||
if (spreadIndex >= 0) {
|
||||
var effectiveArgs_1 = args.slice(0, spreadIndex);
|
||||
var _loop_18 = function (i) {
|
||||
var _loop_19 = function (i) {
|
||||
var arg = args[i];
|
||||
var spreadType = arg.kind === 217 && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
|
||||
if (spreadType && isTupleType(spreadType)) {
|
||||
@ -54874,7 +54887,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var i = spreadIndex; i < args.length; i++) {
|
||||
_loop_18(i);
|
||||
_loop_19(i);
|
||||
}
|
||||
return effectiveArgs_1;
|
||||
}
|
||||
@ -55109,7 +55122,7 @@ var ts;
|
||||
var min_3 = Number.MAX_VALUE;
|
||||
var minIndex = 0;
|
||||
var i_1 = 0;
|
||||
var _loop_19 = function (c) {
|
||||
var _loop_20 = function (c) {
|
||||
var chain_2 = function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
|
||||
var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0, true, chain_2);
|
||||
if (diags_2) {
|
||||
@ -55127,7 +55140,7 @@ var ts;
|
||||
};
|
||||
for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
|
||||
var c = candidatesForArgumentError_1[_a];
|
||||
_loop_19(c);
|
||||
_loop_20(c);
|
||||
}
|
||||
var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
|
||||
ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
|
||||
@ -55248,7 +55261,7 @@ var ts;
|
||||
}
|
||||
var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
|
||||
var parameters = [];
|
||||
var _loop_20 = function (i) {
|
||||
var _loop_21 = function (i) {
|
||||
var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
|
||||
i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
|
||||
i < s.parameters.length ? s.parameters[i] : undefined; });
|
||||
@ -55256,7 +55269,7 @@ var ts;
|
||||
parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
|
||||
};
|
||||
for (var i = 0; i < maxNonRestParam; i++) {
|
||||
_loop_20(i);
|
||||
_loop_21(i);
|
||||
}
|
||||
var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
|
||||
var flags = 0;
|
||||
@ -56765,14 +56778,10 @@ var ts;
|
||||
checkExpression(node.expression);
|
||||
return undefinedWideningType;
|
||||
}
|
||||
function isInTopLevelContext(node) {
|
||||
var container = ts.getThisContainer(node, true);
|
||||
return ts.isSourceFile(container);
|
||||
}
|
||||
function checkAwaitExpression(node) {
|
||||
if (produceDiagnostics) {
|
||||
if (!(node.flags & 32768)) {
|
||||
if (isInTopLevelContext(node)) {
|
||||
if (ts.isInTopLevelContext(node)) {
|
||||
var sourceFile = ts.getSourceFileOfNode(node);
|
||||
if (!hasParseDiagnostics(sourceFile)) {
|
||||
var span = void 0;
|
||||
@ -61108,7 +61117,7 @@ var ts;
|
||||
}
|
||||
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
|
||||
var issuedMemberError = false;
|
||||
var _loop_21 = function (member) {
|
||||
var _loop_22 = function (member) {
|
||||
if (ts.hasStaticModifier(member)) {
|
||||
return "continue";
|
||||
}
|
||||
@ -61126,7 +61135,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
||||
var member = _a[_i];
|
||||
_loop_21(member);
|
||||
_loop_22(member);
|
||||
}
|
||||
if (!issuedMemberError) {
|
||||
checkTypeAssignableTo(typeWithThis, baseWithThis, node.name || node, broadDiag);
|
||||
@ -61811,7 +61820,6 @@ var ts;
|
||||
}
|
||||
}
|
||||
function checkImportBinding(node) {
|
||||
checkGrammarAwaitIdentifier(node.name);
|
||||
checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
|
||||
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
|
||||
checkAliasSymbol(node);
|
||||
@ -62864,10 +62872,10 @@ var ts;
|
||||
return checkDestructuringAssignment(expr, iteratedType || errorType);
|
||||
}
|
||||
if (expr.parent.kind === 285) {
|
||||
var node_1 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
|
||||
var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_1) || errorType;
|
||||
var propertyIndex = ts.indexOfNode(node_1.properties, expr.parent);
|
||||
return checkObjectLiteralDestructuringPropertyAssignment(node_1, typeOfParentObjectLiteral, propertyIndex);
|
||||
var node_2 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
|
||||
var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_2) || errorType;
|
||||
var propertyIndex = ts.indexOfNode(node_2.properties, expr.parent);
|
||||
return checkObjectLiteralDestructuringPropertyAssignment(node_2, typeOfParentObjectLiteral, propertyIndex);
|
||||
}
|
||||
var node = ts.cast(expr.parent, ts.isArrayLiteralExpression);
|
||||
var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType;
|
||||
@ -64097,28 +64105,17 @@ var ts;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function checkGrammarAwaitIdentifier(name) {
|
||||
if (name && ts.isIdentifier(name) && name.originalKeywordKind === 130 && isInTopLevelContext(name.parent)) {
|
||||
var file = ts.getSourceFileOfNode(name);
|
||||
if (!file.isDeclarationFile && ts.isExternalModule(file)) {
|
||||
return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.idText(name));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function checkGrammarFunctionLikeDeclaration(node) {
|
||||
var file = ts.getSourceFileOfNode(node);
|
||||
return checkGrammarDecoratorsAndModifiers(node) ||
|
||||
checkGrammarTypeParameterList(node.typeParameters, file) ||
|
||||
(ts.isFunctionDeclaration(node) && checkGrammarAwaitIdentifier(node.name)) ||
|
||||
checkGrammarParameterList(node.parameters) ||
|
||||
checkGrammarArrowFunction(node, file) ||
|
||||
(ts.isFunctionLikeDeclaration(node) && checkGrammarForUseStrictSimpleParameterList(node));
|
||||
}
|
||||
function checkGrammarClassLikeDeclaration(node) {
|
||||
var file = ts.getSourceFileOfNode(node);
|
||||
return (ts.isClassDeclaration(node) && checkGrammarAwaitIdentifier(node.name)) ||
|
||||
checkGrammarClassDeclarationHeritageClauses(node) ||
|
||||
return checkGrammarClassDeclarationHeritageClauses(node) ||
|
||||
checkGrammarTypeParameterList(node.typeParameters, file);
|
||||
}
|
||||
function checkGrammarArrowFunction(node, file) {
|
||||
@ -64645,9 +64642,6 @@ var ts;
|
||||
return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_have_a_property_name);
|
||||
}
|
||||
}
|
||||
if (ts.isIdentifier(node.name) && checkGrammarAwaitIdentifier(node.name)) {
|
||||
return true;
|
||||
}
|
||||
if (node.dotDotDotToken && node.initializer) {
|
||||
return grammarErrorAtPos(node, node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer);
|
||||
}
|
||||
@ -64703,9 +64697,6 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ts.isIdentifier(node.name) && checkGrammarAwaitIdentifier(node.name)) {
|
||||
return true;
|
||||
}
|
||||
if (node.exclamationToken && (node.parent.parent.kind !== 229 || !node.type || node.initializer || node.flags & 8388608)) {
|
||||
return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation);
|
||||
}
|
||||
@ -87967,7 +87958,7 @@ var ts;
|
||||
importedFileFromNodeModules = importedFileFromNodeModules || ts.pathContainsNodeModules(path);
|
||||
});
|
||||
var sortedPaths = [];
|
||||
var _loop_22 = function (directory) {
|
||||
var _loop_23 = function (directory) {
|
||||
var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
|
||||
var pathsInDirectory;
|
||||
allFileNames.forEach(function (canonicalFileName, fileName) {
|
||||
@ -87992,7 +87983,7 @@ var ts;
|
||||
};
|
||||
var out_directory_1;
|
||||
for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) {
|
||||
var state_8 = _loop_22(directory);
|
||||
var state_8 = _loop_23(directory);
|
||||
directory = out_directory_1;
|
||||
if (state_8 === "break")
|
||||
break;
|
||||
|
||||
460
lib/tsserver.js
460
lib/tsserver.js
@ -13822,6 +13822,15 @@ var ts;
|
||||
}
|
||||
}
|
||||
ts.getThisContainer = getThisContainer;
|
||||
function isInTopLevelContext(node) {
|
||||
// The name of a class or function declaration is a BindingIdentifier in its surrounding scope.
|
||||
if (ts.isIdentifier(node) && (ts.isClassDeclaration(node.parent) || ts.isFunctionDeclaration(node.parent)) && node.parent.name === node) {
|
||||
node = node.parent;
|
||||
}
|
||||
var container = getThisContainer(node, /*includeArrowFunctions*/ true);
|
||||
return ts.isSourceFile(container);
|
||||
}
|
||||
ts.isInTopLevelContext = isInTopLevelContext;
|
||||
function getNewTargetContainer(node) {
|
||||
var container = getThisContainer(node, /*includeArrowFunctions*/ false);
|
||||
if (container) {
|
||||
@ -15019,13 +15028,7 @@ var ts;
|
||||
return parent.name === node;
|
||||
case 156 /* QualifiedName */:
|
||||
// Name on right hand side of dot in a type query or type reference
|
||||
if (parent.right === node) {
|
||||
while (parent.kind === 156 /* QualifiedName */) {
|
||||
parent = parent.parent;
|
||||
}
|
||||
return parent.kind === 175 /* TypeQuery */ || parent.kind === 172 /* TypeReference */;
|
||||
}
|
||||
return false;
|
||||
return parent.right === node;
|
||||
case 195 /* BindingElement */:
|
||||
case 262 /* ImportSpecifier */:
|
||||
// Property name in binding element or import specifier
|
||||
@ -27382,31 +27385,6 @@ var ts;
|
||||
createBaseNode: function (kind) { return countNode(new NodeConstructor(kind, /*pos*/ 0, /*end*/ 0)); }
|
||||
};
|
||||
var factory = ts.createNodeFactory(1 /* NoParenthesizerRules */ | 2 /* NoNodeConverters */ | 8 /* NoOriginalNode */, baseNodeFactory);
|
||||
var reparseContext = {
|
||||
get factory() { return factory; },
|
||||
enableEmitNotification: ts.notImplemented,
|
||||
enableSubstitution: ts.notImplemented,
|
||||
endLexicalEnvironment: ts.returnUndefined,
|
||||
getCompilerOptions: ts.notImplemented,
|
||||
getEmitHost: ts.notImplemented,
|
||||
getEmitResolver: ts.notImplemented,
|
||||
getEmitHelperFactory: ts.notImplemented,
|
||||
setLexicalEnvironmentFlags: ts.noop,
|
||||
getLexicalEnvironmentFlags: function () { return 0; },
|
||||
hoistFunctionDeclaration: ts.notImplemented,
|
||||
hoistVariableDeclaration: ts.notImplemented,
|
||||
addInitializationStatement: ts.notImplemented,
|
||||
isEmitNotificationEnabled: ts.notImplemented,
|
||||
isSubstitutionEnabled: ts.notImplemented,
|
||||
onEmitNode: ts.notImplemented,
|
||||
onSubstituteNode: ts.notImplemented,
|
||||
readEmitHelpers: ts.notImplemented,
|
||||
requestEmitHelper: ts.notImplemented,
|
||||
resumeLexicalEnvironment: ts.noop,
|
||||
startLexicalEnvironment: ts.noop,
|
||||
suspendLexicalEnvironment: ts.noop,
|
||||
addDiagnostic: ts.notImplemented,
|
||||
};
|
||||
var fileName;
|
||||
var sourceFlags;
|
||||
var sourceText;
|
||||
@ -27470,6 +27448,8 @@ var ts;
|
||||
// parsing. These context flags are naturally stored and restored through normal recursive
|
||||
// descent parsing and unwinding.
|
||||
var contextFlags;
|
||||
// Indicates whether we are currently parsing top-level statements.
|
||||
var topLevel = true;
|
||||
// Whether or not we've had a parse error since creating the last AST node. If we have
|
||||
// encountered an error, it will be stored on the next AST node we create. Parse errors
|
||||
// can be broken down into three categories:
|
||||
@ -27613,6 +27593,7 @@ var ts;
|
||||
identifierCount = 0;
|
||||
nodeCount = 0;
|
||||
sourceFlags = 0;
|
||||
topLevel = true;
|
||||
switch (scriptKind) {
|
||||
case 1 /* JS */:
|
||||
case 2 /* JSX */:
|
||||
@ -27649,6 +27630,7 @@ var ts;
|
||||
parsingContext = 0;
|
||||
identifiers = undefined;
|
||||
notParenthesizedArrow = undefined;
|
||||
topLevel = true;
|
||||
}
|
||||
function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind) {
|
||||
var isDeclarationFile = isDeclarationFileName(fileName);
|
||||
@ -27697,108 +27679,98 @@ var ts;
|
||||
return node;
|
||||
}
|
||||
function reparseTopLevelAwait(sourceFile) {
|
||||
return ts.visitEachChild(sourceFile, visitor, reparseContext);
|
||||
function visitor(node) {
|
||||
if (!(node.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */)) {
|
||||
return node;
|
||||
var savedSyntaxCursor = syntaxCursor;
|
||||
var baseSyntaxCursor = IncrementalParser.createSyntaxCursor(sourceFile);
|
||||
syntaxCursor = { currentNode: currentNode };
|
||||
var statements = [];
|
||||
var savedParseDiagnostics = parseDiagnostics;
|
||||
parseDiagnostics = [];
|
||||
var pos = 0;
|
||||
var start = findNextStatementWithAwait(sourceFile.statements, 0);
|
||||
var _loop_3 = function () {
|
||||
// append all statements between pos and start
|
||||
var prevStatement = sourceFile.statements[pos];
|
||||
var nextStatement = sourceFile.statements[start];
|
||||
ts.addRange(statements, sourceFile.statements, pos, start);
|
||||
pos = findNextStatementWithoutAwait(sourceFile.statements, start);
|
||||
// append all diagnostics associated with the copied range
|
||||
var diagnosticStart = ts.findIndex(savedParseDiagnostics, function (diagnostic) { return diagnostic.start >= prevStatement.pos; });
|
||||
var diagnosticEnd = diagnosticStart >= 0 ? ts.findIndex(savedParseDiagnostics, function (diagnostic) { return diagnostic.start >= nextStatement.pos; }, diagnosticStart) : -1;
|
||||
if (diagnosticStart >= 0) {
|
||||
ts.addRange(parseDiagnostics, savedParseDiagnostics, diagnosticStart, diagnosticEnd >= 0 ? diagnosticEnd : undefined);
|
||||
}
|
||||
// We explicitly visit each non-Expression node that has an immediate Expression child so that
|
||||
// we can reparse the Expression in an Await context
|
||||
switch (node.kind) {
|
||||
case 160 /* Decorator */: return reparseDecorator(node);
|
||||
case 157 /* ComputedPropertyName */: return reparseComputedPropertyName(node);
|
||||
case 220 /* ExpressionWithTypeArguments */: return reparseExpressionWithTypeArguments(node);
|
||||
case 230 /* ExpressionStatement */: return reparseExpressionStatement(node);
|
||||
case 231 /* IfStatement */: return reparseIfStatement(node);
|
||||
case 241 /* SwitchStatement */: return reparseSwitchStatement(node);
|
||||
case 240 /* WithStatement */: return reparseWithStatement(node);
|
||||
case 232 /* DoStatement */: return reparseDoStatement(node);
|
||||
case 233 /* WhileStatement */: return reparseWhileStatement(node);
|
||||
case 234 /* ForStatement */: return reparseForStatement(node);
|
||||
case 235 /* ForInStatement */: return reparseForInStatement(node);
|
||||
case 236 /* ForOfStatement */: return reparseForOfStatement(node);
|
||||
case 239 /* ReturnStatement */: return reparseReturnStatement(node);
|
||||
case 243 /* ThrowStatement */: return reparseThrowStatement(node);
|
||||
case 263 /* ExportAssignment */: return reparseExportAssignment(node);
|
||||
case 246 /* VariableDeclaration */: return reparseVariableDeclaration(node);
|
||||
case 195 /* BindingElement */: return reparseBindingElement(node);
|
||||
default: return ts.visitEachChild(node, visitor, reparseContext);
|
||||
// reparse all statements between start and pos. We skip existing diagnostics for the same range and allow the parser to generate new ones.
|
||||
speculationHelper(function () {
|
||||
var savedContextFlags = contextFlags;
|
||||
contextFlags |= 32768 /* AwaitContext */;
|
||||
scanner.setTextPos(nextStatement.pos);
|
||||
nextToken();
|
||||
while (token() !== 1 /* EndOfFileToken */) {
|
||||
var startPos = scanner.getStartPos();
|
||||
var statement = parseListElement(0 /* SourceElements */, parseStatement);
|
||||
statements.push(statement);
|
||||
if (startPos === scanner.getStartPos()) {
|
||||
nextToken();
|
||||
}
|
||||
if (pos >= 0) {
|
||||
var nonAwaitStatement = sourceFile.statements[pos];
|
||||
if (statement.end === nonAwaitStatement.pos) {
|
||||
// done reparsing this section
|
||||
break;
|
||||
}
|
||||
if (statement.end > nonAwaitStatement.pos) {
|
||||
// we ate into the next statement, so we must reparse it.
|
||||
pos = findNextStatementWithoutAwait(sourceFile.statements, pos + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
contextFlags = savedContextFlags;
|
||||
}, 2 /* Reparse */);
|
||||
// find the next statement containing an `await`
|
||||
start = pos >= 0 ? findNextStatementWithAwait(sourceFile.statements, pos) : -1;
|
||||
};
|
||||
while (start !== -1) {
|
||||
_loop_3();
|
||||
}
|
||||
// append all statements between pos and the end of the list
|
||||
if (pos >= 0) {
|
||||
var prevStatement_1 = sourceFile.statements[pos];
|
||||
ts.addRange(statements, sourceFile.statements, pos);
|
||||
// append all diagnostics associated with the copied range
|
||||
var diagnosticStart = ts.findIndex(savedParseDiagnostics, function (diagnostic) { return diagnostic.start >= prevStatement_1.pos; });
|
||||
if (diagnosticStart >= 0) {
|
||||
ts.addRange(parseDiagnostics, savedParseDiagnostics, diagnosticStart);
|
||||
}
|
||||
}
|
||||
function reparse(node, parse) {
|
||||
if (node && node.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */) {
|
||||
if (ts.isExpression(node)) {
|
||||
return speculationHelper(function () {
|
||||
scanner.setTextPos(node.pos);
|
||||
var savedContextFlags = contextFlags;
|
||||
contextFlags = node.flags & 25358336 /* ContextFlags */;
|
||||
nextToken();
|
||||
var result = doInAwaitContext(parse);
|
||||
contextFlags = savedContextFlags;
|
||||
return result;
|
||||
}, 2 /* Reparse */);
|
||||
syntaxCursor = savedSyntaxCursor;
|
||||
return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements));
|
||||
function containsPossibleTopLevelAwait(node) {
|
||||
return !(node.flags & 32768 /* AwaitContext */)
|
||||
&& !!(node.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */);
|
||||
}
|
||||
function findNextStatementWithAwait(statements, start) {
|
||||
for (var i = start; i < statements.length; i++) {
|
||||
if (containsPossibleTopLevelAwait(statements[i])) {
|
||||
return i;
|
||||
}
|
||||
return ts.visitEachChild(node, visitor, reparseContext);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
function findNextStatementWithoutAwait(statements, start) {
|
||||
for (var i = start; i < statements.length; i++) {
|
||||
if (!containsPossibleTopLevelAwait(statements[i])) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
function currentNode(position) {
|
||||
var node = baseSyntaxCursor.currentNode(position);
|
||||
if (topLevel && node && containsPossibleTopLevelAwait(node)) {
|
||||
node.intersectsChange = true;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
function update(updated, original) {
|
||||
if (updated !== original) {
|
||||
ts.setNodeFlags(updated, updated.flags | 32768 /* AwaitContext */);
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
function reparseExpressionStatement(node) {
|
||||
return update(factory.updateExpressionStatement(node, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseReturnStatement(node) {
|
||||
return update(factory.updateReturnStatement(node, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseThrowStatement(node) {
|
||||
return update(factory.updateThrowStatement(node, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseIfStatement(node) {
|
||||
return update(factory.updateIfStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.thenStatement, visitor), ts.visitNode(node.elseStatement, visitor)), node);
|
||||
}
|
||||
function reparseSwitchStatement(node) {
|
||||
return update(factory.updateSwitchStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.caseBlock, visitor)), node);
|
||||
}
|
||||
function reparseWithStatement(node) {
|
||||
return update(factory.updateWithStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
|
||||
}
|
||||
function reparseDoStatement(node) {
|
||||
return update(factory.updateDoStatement(node, ts.visitNode(node.statement, visitor), reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseWhileStatement(node) {
|
||||
return update(factory.updateWhileStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
|
||||
}
|
||||
function reparseForStatement(node) {
|
||||
return update(factory.updateForStatement(node, reparse(node.initializer, parseExpression), reparse(node.condition, parseExpression), reparse(node.incrementor, parseExpression), ts.visitNode(node, visitor)), node);
|
||||
}
|
||||
function reparseForInStatement(node) {
|
||||
return update(factory.updateForInStatement(node, reparse(node.initializer, parseExpression), reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
|
||||
}
|
||||
function reparseForOfStatement(node) {
|
||||
return update(factory.updateForOfStatement(node, node.awaitModifier, reparse(node.initializer, parseExpression), reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
|
||||
}
|
||||
function reparseExportAssignment(node) {
|
||||
return update(factory.updateExportAssignment(node, ts.visitNodes(node.decorators, visitor), node.modifiers, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseExpressionWithTypeArguments(node) {
|
||||
return update(factory.updateExpressionWithTypeArguments(node, reparse(node.expression, parseLeftHandSideExpressionOrHigher), node.typeArguments), node);
|
||||
}
|
||||
function reparseDecorator(node) {
|
||||
return update(factory.updateDecorator(node, reparse(node.expression, parseLeftHandSideExpressionOrHigher)), node);
|
||||
}
|
||||
function reparseComputedPropertyName(node) {
|
||||
return update(factory.updateComputedPropertyName(node, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseVariableDeclaration(node) {
|
||||
return update(factory.updateVariableDeclaration(node, ts.visitNode(node.name, visitor), node.exclamationToken, node.type, reparse(node.initializer, parseExpression)), node);
|
||||
}
|
||||
function reparseBindingElement(node) {
|
||||
return update(factory.updateBindingElement(node, node.dotDotDotToken, ts.visitNode(node.propertyName, visitor), ts.visitNode(node.name, visitor), reparse(node.initializer, parseExpression)), node);
|
||||
}
|
||||
}
|
||||
function fixupParentReferences(rootNode) {
|
||||
// normally parent references are set during binding. However, for clients that only need
|
||||
@ -28048,6 +28020,12 @@ var ts;
|
||||
function tryParse(callback) {
|
||||
return speculationHelper(callback, 0 /* TryParse */);
|
||||
}
|
||||
function isBindingIdentifier() {
|
||||
if (token() === 78 /* Identifier */) {
|
||||
return true;
|
||||
}
|
||||
return token() > 115 /* LastReservedWord */;
|
||||
}
|
||||
// Ignore strict mode flag because we will report an error in type checker instead.
|
||||
function isIdentifier() {
|
||||
if (token() === 78 /* Identifier */) {
|
||||
@ -28217,6 +28195,9 @@ var ts;
|
||||
ts.Diagnostics.Identifier_expected;
|
||||
return createMissingNode(78 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg);
|
||||
}
|
||||
function parseBindingIdentifier(privateIdentifierDiagnosticMessage) {
|
||||
return createIdentifier(isBindingIdentifier(), /*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage);
|
||||
}
|
||||
function parseIdentifier(diagnosticMessage, privateIdentifierDiagnosticMessage) {
|
||||
return createIdentifier(isIdentifier(), diagnosticMessage, privateIdentifierDiagnosticMessage);
|
||||
}
|
||||
@ -28394,9 +28375,9 @@ var ts;
|
||||
return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword();
|
||||
}
|
||||
case 8 /* VariableDeclarations */:
|
||||
return isIdentifierOrPrivateIdentifierOrPattern();
|
||||
return isBindingIdentifierOrPrivateIdentifierOrPattern();
|
||||
case 10 /* ArrayBindingElements */:
|
||||
return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isIdentifierOrPrivateIdentifierOrPattern();
|
||||
return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern();
|
||||
case 19 /* TypeParameters */:
|
||||
return isIdentifier();
|
||||
case 15 /* ArrayLiteralMembers */:
|
||||
@ -29238,7 +29219,7 @@ var ts;
|
||||
}
|
||||
function isStartOfParameter(isJSDocParameter) {
|
||||
return token() === 25 /* DotDotDotToken */ ||
|
||||
isIdentifierOrPrivateIdentifierOrPattern() ||
|
||||
isBindingIdentifierOrPrivateIdentifierOrPattern() ||
|
||||
ts.isModifierKind(token()) ||
|
||||
token() === 59 /* AtToken */ ||
|
||||
isStartOfType(/*inStartOfParameter*/ !isJSDocParameter);
|
||||
@ -29260,22 +29241,34 @@ var ts;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
function parseParameterInOuterAwaitContext() {
|
||||
return parseParameterWorker(/*inOuterAwaitContext*/ true);
|
||||
}
|
||||
function parseParameter() {
|
||||
return parseParameterWorker(/*inOuterAwaitContext*/ false);
|
||||
}
|
||||
function parseParameterWorker(inOuterAwaitContext) {
|
||||
var pos = getNodePos();
|
||||
var hasJSDoc = hasPrecedingJSDocComment();
|
||||
if (token() === 107 /* ThisKeyword */) {
|
||||
var node = factory.createParameterDeclaration(
|
||||
var node_1 = factory.createParameterDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
/*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true),
|
||||
/*questionToken*/ undefined, parseTypeAnnotation(),
|
||||
/*initializer*/ undefined);
|
||||
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
||||
return withJSDoc(finishNode(node_1, pos), hasJSDoc);
|
||||
}
|
||||
// FormalParameter [Yield,Await]:
|
||||
// BindingElement[?Yield,?Await]
|
||||
var modifiers;
|
||||
return withJSDoc(finishNode(factory.createParameterDeclaration(parseDecorators(), modifiers = parseModifiers(), parseOptionalToken(25 /* DotDotDotToken */), parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc);
|
||||
// Decorators are parsed in the outer [Await] context, the rest of the parameter is parsed in the function's [Await] context.
|
||||
var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators();
|
||||
var savedTopLevel = topLevel;
|
||||
topLevel = false;
|
||||
var modifiers = parseModifiers();
|
||||
var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, parseOptionalToken(25 /* DotDotDotToken */), parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc);
|
||||
topLevel = savedTopLevel;
|
||||
return node;
|
||||
}
|
||||
function parseReturnType(returnToken, isType) {
|
||||
if (shouldParseReturnType(returnToken, isType)) {
|
||||
@ -29318,7 +29311,7 @@ var ts;
|
||||
setAwaitContext(!!(flags & 2 /* Await */));
|
||||
var parameters = flags & 32 /* JSDoc */ ?
|
||||
parseDelimitedList(17 /* JSDocParameters */, parseJSDocParameter) :
|
||||
parseDelimitedList(16 /* Parameters */, parseParameter);
|
||||
parseDelimitedList(16 /* Parameters */, savedAwaitContext ? parseParameterInOuterAwaitContext : parseParameter);
|
||||
setYieldContext(savedYieldContext);
|
||||
setAwaitContext(savedAwaitContext);
|
||||
return parameters;
|
||||
@ -30447,9 +30440,13 @@ var ts;
|
||||
// Note: even when 'IgnoreMissingOpenBrace' is passed, parseBody will still error.
|
||||
return parseFunctionBlock(16 /* IgnoreMissingOpenBrace */ | (isAsync ? 2 /* Await */ : 0 /* None */));
|
||||
}
|
||||
return isAsync
|
||||
var savedTopLevel = topLevel;
|
||||
topLevel = false;
|
||||
var node = isAsync
|
||||
? doInAwaitContext(parseAssignmentExpressionOrHigher)
|
||||
: doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
|
||||
topLevel = savedTopLevel;
|
||||
return node;
|
||||
}
|
||||
function parseConditionalExpressionRest(leftOperand, pos) {
|
||||
// Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher.
|
||||
@ -31440,10 +31437,10 @@ var ts;
|
||||
var asteriskToken = parseOptionalToken(41 /* AsteriskToken */);
|
||||
var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */;
|
||||
var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */;
|
||||
var name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) :
|
||||
isGenerator ? doInYieldContext(parseOptionalIdentifier) :
|
||||
isAsync ? doInAwaitContext(parseOptionalIdentifier) :
|
||||
parseOptionalIdentifier();
|
||||
var name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalBindingIdentifier) :
|
||||
isGenerator ? doInYieldContext(parseOptionalBindingIdentifier) :
|
||||
isAsync ? doInAwaitContext(parseOptionalBindingIdentifier) :
|
||||
parseOptionalBindingIdentifier();
|
||||
var typeParameters = parseTypeParameters();
|
||||
var parameters = parseParameters(isGenerator | isAsync);
|
||||
var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
|
||||
@ -31454,8 +31451,8 @@ var ts;
|
||||
var node = factory.createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body);
|
||||
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
||||
}
|
||||
function parseOptionalIdentifier() {
|
||||
return isIdentifier() ? parseIdentifier() : undefined;
|
||||
function parseOptionalBindingIdentifier() {
|
||||
return isBindingIdentifier() ? parseBindingIdentifier() : undefined;
|
||||
}
|
||||
function parseNewExpressionOrNewDotTarget() {
|
||||
var pos = getNodePos();
|
||||
@ -31511,6 +31508,8 @@ var ts;
|
||||
setYieldContext(!!(flags & 1 /* Yield */));
|
||||
var savedAwaitContext = inAwaitContext();
|
||||
setAwaitContext(!!(flags & 2 /* Await */));
|
||||
var savedTopLevel = topLevel;
|
||||
topLevel = false;
|
||||
// We may be in a [Decorator] context when parsing a function expression or
|
||||
// arrow function. The body of the function is not in [Decorator] context.
|
||||
var saveDecoratorContext = inDecoratorContext();
|
||||
@ -31521,6 +31520,7 @@ var ts;
|
||||
if (saveDecoratorContext) {
|
||||
setDecoratorContext(/*val*/ true);
|
||||
}
|
||||
topLevel = savedTopLevel;
|
||||
setYieldContext(savedYieldContext);
|
||||
setAwaitContext(savedAwaitContext);
|
||||
return block;
|
||||
@ -32079,7 +32079,7 @@ var ts;
|
||||
function parseObjectBindingElement() {
|
||||
var pos = getNodePos();
|
||||
var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */);
|
||||
var tokenIsIdentifier = isIdentifier();
|
||||
var tokenIsIdentifier = isBindingIdentifier();
|
||||
var propertyName = parsePropertyName();
|
||||
var name;
|
||||
if (tokenIsIdentifier && token() !== 58 /* ColonToken */) {
|
||||
@ -32107,11 +32107,11 @@ var ts;
|
||||
parseExpected(23 /* CloseBracketToken */);
|
||||
return finishNode(factory.createArrayBindingPattern(elements), pos);
|
||||
}
|
||||
function isIdentifierOrPrivateIdentifierOrPattern() {
|
||||
function isBindingIdentifierOrPrivateIdentifierOrPattern() {
|
||||
return token() === 18 /* OpenBraceToken */
|
||||
|| token() === 22 /* OpenBracketToken */
|
||||
|| token() === 79 /* PrivateIdentifier */
|
||||
|| isIdentifier();
|
||||
|| isBindingIdentifier();
|
||||
}
|
||||
function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) {
|
||||
if (token() === 22 /* OpenBracketToken */) {
|
||||
@ -32120,7 +32120,7 @@ var ts;
|
||||
if (token() === 18 /* OpenBraceToken */) {
|
||||
return parseObjectBindingPattern();
|
||||
}
|
||||
return parseIdentifier(/*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage);
|
||||
return parseBindingIdentifier(privateIdentifierDiagnosticMessage);
|
||||
}
|
||||
function parseVariableDeclarationAllowExclamation() {
|
||||
return parseVariableDeclaration(/*allowExclamation*/ true);
|
||||
@ -32192,7 +32192,7 @@ var ts;
|
||||
parseExpected(97 /* FunctionKeyword */);
|
||||
var asteriskToken = parseOptionalToken(41 /* AsteriskToken */);
|
||||
// We don't parse the name here in await context, instead we will report a grammar error in the checker.
|
||||
var name = modifierFlags & 512 /* Default */ ? parseOptionalIdentifier() : parseIdentifier();
|
||||
var name = modifierFlags & 512 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier();
|
||||
var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */;
|
||||
var isAsync = modifierFlags & 256 /* Async */ ? 2 /* Await */ : 0 /* None */;
|
||||
var typeParameters = parseTypeParameters();
|
||||
@ -32336,12 +32336,24 @@ var ts;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function parseDecoratorExpression() {
|
||||
if (inAwaitContext() && token() === 130 /* AwaitKeyword */) {
|
||||
// `@await` is is disallowed in an [Await] context, but can cause parsing to go off the rails
|
||||
// This simply parses the missing identifier and moves on.
|
||||
var pos = getNodePos();
|
||||
var awaitExpression = parseIdentifier(ts.Diagnostics.Expression_expected);
|
||||
nextToken();
|
||||
var memberExpression = parseMemberExpressionRest(pos, awaitExpression, /*allowOptionalChain*/ true);
|
||||
return parseCallExpressionRest(pos, memberExpression);
|
||||
}
|
||||
return parseLeftHandSideExpressionOrHigher();
|
||||
}
|
||||
function tryParseDecorator() {
|
||||
var pos = getNodePos();
|
||||
if (!parseOptional(59 /* AtToken */)) {
|
||||
return undefined;
|
||||
}
|
||||
var expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher);
|
||||
var expression = doInDecoratorContext(parseDecoratorExpression);
|
||||
return finishNode(factory.createDecorator(expression), pos);
|
||||
}
|
||||
function parseDecorators() {
|
||||
@ -32482,8 +32494,8 @@ var ts;
|
||||
// - class expression with omitted name, 'implements' starts heritage clause
|
||||
// - class with name 'implements'
|
||||
// 'isImplementsClause' helps to disambiguate between these two cases
|
||||
return isIdentifier() && !isImplementsClause()
|
||||
? parseIdentifier()
|
||||
return isBindingIdentifier() && !isImplementsClause()
|
||||
? createIdentifier(isBindingIdentifier())
|
||||
: undefined;
|
||||
}
|
||||
function isImplementsClause() {
|
||||
@ -34279,6 +34291,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
IncrementalParser.createSyntaxCursor = createSyntaxCursor;
|
||||
var InvalidPosition;
|
||||
(function (InvalidPosition) {
|
||||
InvalidPosition[InvalidPosition["Value"] = -1] = "Value";
|
||||
@ -36065,7 +36078,7 @@ var ts;
|
||||
}
|
||||
function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) {
|
||||
var result = returnValue ? {} : undefined;
|
||||
var _loop_3 = function (element) {
|
||||
var _loop_4 = function (element) {
|
||||
if (element.kind !== 285 /* PropertyAssignment */) {
|
||||
errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected));
|
||||
return "continue";
|
||||
@ -36118,7 +36131,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
|
||||
var element = _a[_i];
|
||||
_loop_3(element);
|
||||
_loop_4(element);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -36301,7 +36314,7 @@ var ts;
|
||||
var optionsNameMap = _a.optionsNameMap;
|
||||
var result = ts.createMap();
|
||||
var getCanonicalFileName = pathOptions && ts.createGetCanonicalFileName(pathOptions.useCaseSensitiveFileNames);
|
||||
var _loop_4 = function (name) {
|
||||
var _loop_5 = function (name) {
|
||||
if (ts.hasProperty(options, name)) {
|
||||
// tsconfig only options cannot be specified via command line,
|
||||
// so we can assume that only types that can appear here string | number | boolean
|
||||
@ -36335,7 +36348,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var name in options) {
|
||||
_loop_4(name);
|
||||
_loop_5(name);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -37096,7 +37109,7 @@ var ts;
|
||||
}
|
||||
var jsonOnlyIncludeRegexes;
|
||||
if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) {
|
||||
var _loop_5 = function (file) {
|
||||
var _loop_6 = function (file) {
|
||||
if (ts.fileExtensionIs(file, ".json" /* Json */)) {
|
||||
// Valid only if *.json specified
|
||||
if (!jsonOnlyIncludeRegexes) {
|
||||
@ -37134,7 +37147,7 @@ var ts;
|
||||
};
|
||||
for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensionsWithJsonIfResolveJsonModule, validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined); _a < _b.length; _a++) {
|
||||
var file = _b[_a];
|
||||
_loop_5(file);
|
||||
_loop_6(file);
|
||||
}
|
||||
}
|
||||
var literalFiles = ts.arrayFrom(literalFileMap.values());
|
||||
@ -40541,18 +40554,31 @@ var ts;
|
||||
currentFlow = saveCurrentFlow;
|
||||
}
|
||||
// The binder visits every node in the syntax tree so it is a convenient place to perform a single localized
|
||||
// check for reserved words used as identifiers in strict mode code.
|
||||
function checkStrictModeIdentifier(node) {
|
||||
if (inStrictMode &&
|
||||
node.originalKeywordKind >= 116 /* FirstFutureReservedWord */ &&
|
||||
node.originalKeywordKind <= 124 /* LastFutureReservedWord */ &&
|
||||
!ts.isIdentifierName(node) &&
|
||||
// check for reserved words used as identifiers in strict mode code, as well as `yield` or `await` in
|
||||
// [Yield] or [Await] contexts, respectively.
|
||||
function checkContextualIdentifier(node) {
|
||||
// Report error only if there are no parse errors in file
|
||||
if (!file.parseDiagnostics.length &&
|
||||
!(node.flags & 8388608 /* Ambient */) &&
|
||||
!(node.flags & 4194304 /* JSDoc */)) {
|
||||
// Report error only if there are no parse errors in file
|
||||
if (!file.parseDiagnostics.length) {
|
||||
!(node.flags & 4194304 /* JSDoc */) &&
|
||||
!ts.isIdentifierName(node)) {
|
||||
// strict mode identifiers
|
||||
if (inStrictMode &&
|
||||
node.originalKeywordKind >= 116 /* FirstFutureReservedWord */ &&
|
||||
node.originalKeywordKind <= 124 /* LastFutureReservedWord */) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node)));
|
||||
}
|
||||
else if (node.originalKeywordKind === 130 /* AwaitKeyword */) {
|
||||
if (ts.isExternalModule(file) && ts.isInTopLevelContext(node)) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.declarationNameToString(node)));
|
||||
}
|
||||
else if (node.flags & 32768 /* AwaitContext */) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node)));
|
||||
}
|
||||
}
|
||||
else if (node.originalKeywordKind === 124 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node)));
|
||||
}
|
||||
}
|
||||
}
|
||||
function getStrictModeIdentifierMessage(node) {
|
||||
@ -40819,7 +40845,7 @@ var ts;
|
||||
if (currentFlow && (ts.isExpression(node) || parent.kind === 286 /* ShorthandPropertyAssignment */)) {
|
||||
node.flowNode = currentFlow;
|
||||
}
|
||||
return checkStrictModeIdentifier(node);
|
||||
return checkContextualIdentifier(node);
|
||||
case 105 /* SuperKeyword */:
|
||||
node.flowNode = currentFlow;
|
||||
break;
|
||||
@ -43015,7 +43041,7 @@ var ts;
|
||||
function addDuplicateDeclarationError(node, message, symbolName, relatedNodes) {
|
||||
var errorNode = (ts.getExpandoInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getNameOfExpando(node) : ts.getNameOfDeclaration(node)) || node;
|
||||
var err = lookupOrIssueError(errorNode, message, symbolName);
|
||||
var _loop_6 = function (relatedNode) {
|
||||
var _loop_7 = function (relatedNode) {
|
||||
var adjustedNode = (ts.getExpandoInitializer(relatedNode, /*isPrototypeAssignment*/ false) ? ts.getNameOfExpando(relatedNode) : ts.getNameOfDeclaration(relatedNode)) || relatedNode;
|
||||
if (adjustedNode === errorNode)
|
||||
return "continue";
|
||||
@ -43028,7 +43054,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, _a = relatedNodes || ts.emptyArray; _i < _a.length; _i++) {
|
||||
var relatedNode = _a[_i];
|
||||
_loop_6(relatedNode);
|
||||
_loop_7(relatedNode);
|
||||
}
|
||||
}
|
||||
function combineSymbolTables(first, second) {
|
||||
@ -45269,7 +45295,7 @@ var ts;
|
||||
}
|
||||
function forEachSymbolTableInScope(enclosingDeclaration, callback) {
|
||||
var result;
|
||||
var _loop_7 = function (location) {
|
||||
var _loop_8 = function (location) {
|
||||
// Locals of a source file are not in scope (because they get merged into the global symbol table)
|
||||
if (location.locals && !isGlobalSourceFile(location)) {
|
||||
if (result = callback(location.locals)) {
|
||||
@ -45315,7 +45341,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var location = enclosingDeclaration; location; location = location.parent) {
|
||||
var state_2 = _loop_7(location);
|
||||
var state_2 = _loop_8(location);
|
||||
if (typeof state_2 === "object")
|
||||
return state_2.value;
|
||||
}
|
||||
@ -47325,7 +47351,7 @@ var ts;
|
||||
if (ts.length(reexports) > 1) {
|
||||
var groups = ts.group(reexports, function (decl) { return ts.isStringLiteral(decl.moduleSpecifier) ? ">" + decl.moduleSpecifier.text : ">"; });
|
||||
if (groups.length !== reexports.length) {
|
||||
var _loop_8 = function (group_1) {
|
||||
var _loop_9 = function (group_1) {
|
||||
if (group_1.length > 1) {
|
||||
// remove group members from statements and then merge group members and add back to statements
|
||||
statements = __spreadArrays(ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), [
|
||||
@ -47338,7 +47364,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) {
|
||||
var group_1 = groups_1[_i];
|
||||
_loop_8(group_1);
|
||||
_loop_9(group_1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -50850,7 +50876,7 @@ var ts;
|
||||
// signatures from the type, whose ordering would be non-obvious)
|
||||
var masterList = signatureLists[indexWithLengthOverOne !== undefined ? indexWithLengthOverOne : 0];
|
||||
var results = masterList.slice();
|
||||
var _loop_9 = function (signatures) {
|
||||
var _loop_10 = function (signatures) {
|
||||
if (signatures !== masterList) {
|
||||
var signature_1 = signatures[0];
|
||||
ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass");
|
||||
@ -50862,7 +50888,7 @@ var ts;
|
||||
};
|
||||
for (var _b = 0, signatureLists_1 = signatureLists; _b < signatureLists_1.length; _b++) {
|
||||
var signatures = signatureLists_1[_b];
|
||||
var state_3 = _loop_9(signatures);
|
||||
var state_3 = _loop_10(signatures);
|
||||
if (state_3 === "break")
|
||||
break;
|
||||
}
|
||||
@ -50986,7 +51012,7 @@ var ts;
|
||||
var types = type.types;
|
||||
var mixinFlags = findMixins(types);
|
||||
var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; });
|
||||
var _loop_10 = function (i) {
|
||||
var _loop_11 = function (i) {
|
||||
var t = type.types[i];
|
||||
// When an intersection type contains mixin constructor types, the construct signatures from
|
||||
// those types are discarded and their return types are mixed into the return types of all
|
||||
@ -51009,19 +51035,19 @@ var ts;
|
||||
numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1 /* Number */));
|
||||
};
|
||||
for (var i = 0; i < types.length; i++) {
|
||||
_loop_10(i);
|
||||
_loop_11(i);
|
||||
}
|
||||
setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo);
|
||||
}
|
||||
function appendSignatures(signatures, newSignatures) {
|
||||
var _loop_11 = function (sig) {
|
||||
var _loop_12 = function (sig) {
|
||||
if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, compareTypesIdentical); })) {
|
||||
signatures = ts.append(signatures, sig);
|
||||
}
|
||||
};
|
||||
for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) {
|
||||
var sig = newSignatures_1[_i];
|
||||
_loop_11(sig);
|
||||
_loop_12(sig);
|
||||
}
|
||||
return signatures;
|
||||
}
|
||||
@ -53308,7 +53334,7 @@ var ts;
|
||||
var expandedDeclarations = [];
|
||||
var optionalIndex = -1;
|
||||
var restTypes;
|
||||
var _loop_12 = function (i) {
|
||||
var _loop_13 = function (i) {
|
||||
var type = elementTypes[i];
|
||||
var flags = target.elementFlags[i];
|
||||
if (flags & 8 /* Variadic */) {
|
||||
@ -53331,7 +53357,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var i = 0; i < elementTypes.length; i++) {
|
||||
_loop_12(i);
|
||||
_loop_13(i);
|
||||
}
|
||||
if (restTypes) {
|
||||
// Create a union of the collected rest element types.
|
||||
@ -54381,7 +54407,7 @@ var ts;
|
||||
function getConditionalType(root, mapper) {
|
||||
var result;
|
||||
var extraTypes;
|
||||
var _loop_13 = function () {
|
||||
var _loop_14 = function () {
|
||||
var checkType = instantiateType(root.checkType, mapper);
|
||||
var checkTypeInstantiable = isGenericObjectType(checkType) || isGenericIndexType(checkType);
|
||||
var extendsType = instantiateType(root.extendsType, mapper);
|
||||
@ -54455,7 +54481,7 @@ var ts;
|
||||
// types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
|
||||
// purposes of resolution. This means such types aren't subject to the instatiation depth limiter.
|
||||
while (true) {
|
||||
var state_4 = _loop_13();
|
||||
var state_4 = _loop_14();
|
||||
if (typeof state_4 === "object")
|
||||
return state_4.value;
|
||||
if (state_4 === "break")
|
||||
@ -56933,7 +56959,7 @@ var ts;
|
||||
reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
|
||||
checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget];
|
||||
}
|
||||
var _loop_14 = function (prop) {
|
||||
var _loop_15 = function (prop) {
|
||||
if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
|
||||
if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
|
||||
if (reportErrors) {
|
||||
@ -56996,7 +57022,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) {
|
||||
var prop = _a[_i];
|
||||
var state_5 = _loop_14(prop);
|
||||
var state_5 = _loop_15(prop);
|
||||
if (typeof state_5 === "object")
|
||||
return state_5.value;
|
||||
}
|
||||
@ -57669,11 +57695,11 @@ var ts;
|
||||
// constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
|
||||
var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
|
||||
var matchingTypes = [];
|
||||
var _loop_15 = function (combination) {
|
||||
var _loop_16 = function (combination) {
|
||||
var hasMatch = false;
|
||||
outer: for (var _i = 0, _a = target.types; _i < _a.length; _i++) {
|
||||
var type = _a[_i];
|
||||
var _loop_16 = function (i) {
|
||||
var _loop_17 = function (i) {
|
||||
var sourceProperty = sourcePropertiesFiltered[i];
|
||||
var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
|
||||
if (!targetProperty)
|
||||
@ -57689,7 +57715,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
|
||||
var state_7 = _loop_16(i);
|
||||
var state_7 = _loop_17(i);
|
||||
switch (state_7) {
|
||||
case "continue-outer": continue outer;
|
||||
}
|
||||
@ -57703,7 +57729,7 @@ var ts;
|
||||
};
|
||||
for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
|
||||
var combination = discriminantCombinations_1[_a];
|
||||
var state_6 = _loop_15(combination);
|
||||
var state_6 = _loop_16(combination);
|
||||
if (typeof state_6 === "object")
|
||||
return state_6.value;
|
||||
}
|
||||
@ -58345,7 +58371,7 @@ var ts;
|
||||
// The emptyArray singleton is used to signal a recursive invocation.
|
||||
cache.variances = ts.emptyArray;
|
||||
variances = [];
|
||||
var _loop_17 = function (tp) {
|
||||
var _loop_18 = function (tp) {
|
||||
var unmeasurable = false;
|
||||
var unreliable = false;
|
||||
var oldHandler = outofbandVarianceMarkerHandler;
|
||||
@ -58377,7 +58403,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) {
|
||||
var tp = typeParameters_1[_i];
|
||||
_loop_17(tp);
|
||||
_loop_18(tp);
|
||||
}
|
||||
cache.variances = variances;
|
||||
}
|
||||
@ -65860,7 +65886,7 @@ var ts;
|
||||
if (spreadIndex >= 0) {
|
||||
// Create synthetic arguments from spreads of tuple types.
|
||||
var effectiveArgs_1 = args.slice(0, spreadIndex);
|
||||
var _loop_18 = function (i) {
|
||||
var _loop_19 = function (i) {
|
||||
var arg = args[i];
|
||||
// We can call checkExpressionCached because spread expressions never have a contextual type.
|
||||
var spreadType = arg.kind === 217 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
|
||||
@ -65877,7 +65903,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var i = spreadIndex; i < args.length; i++) {
|
||||
_loop_18(i);
|
||||
_loop_19(i);
|
||||
}
|
||||
return effectiveArgs_1;
|
||||
}
|
||||
@ -66179,7 +66205,7 @@ var ts;
|
||||
var min_3 = Number.MAX_VALUE;
|
||||
var minIndex = 0;
|
||||
var i_1 = 0;
|
||||
var _loop_19 = function (c) {
|
||||
var _loop_20 = function (c) {
|
||||
var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
|
||||
var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2);
|
||||
if (diags_2) {
|
||||
@ -66197,7 +66223,7 @@ var ts;
|
||||
};
|
||||
for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
|
||||
var c = candidatesForArgumentError_1[_a];
|
||||
_loop_19(c);
|
||||
_loop_20(c);
|
||||
}
|
||||
var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
|
||||
ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
|
||||
@ -66331,7 +66357,7 @@ var ts;
|
||||
}
|
||||
var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
|
||||
var parameters = [];
|
||||
var _loop_20 = function (i) {
|
||||
var _loop_21 = function (i) {
|
||||
var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
|
||||
i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
|
||||
i < s.parameters.length ? s.parameters[i] : undefined; });
|
||||
@ -66339,7 +66365,7 @@ var ts;
|
||||
parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
|
||||
};
|
||||
for (var i = 0; i < maxNonRestParam; i++) {
|
||||
_loop_20(i);
|
||||
_loop_21(i);
|
||||
}
|
||||
var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
|
||||
var flags = 0 /* None */;
|
||||
@ -68091,15 +68117,11 @@ var ts;
|
||||
checkExpression(node.expression);
|
||||
return undefinedWideningType;
|
||||
}
|
||||
function isInTopLevelContext(node) {
|
||||
var container = ts.getThisContainer(node, /*includeArrowFunctions*/ true);
|
||||
return ts.isSourceFile(container);
|
||||
}
|
||||
function checkAwaitExpression(node) {
|
||||
// Grammar checking
|
||||
if (produceDiagnostics) {
|
||||
if (!(node.flags & 32768 /* AwaitContext */)) {
|
||||
if (isInTopLevelContext(node)) {
|
||||
if (ts.isInTopLevelContext(node)) {
|
||||
var sourceFile = ts.getSourceFileOfNode(node);
|
||||
if (!hasParseDiagnostics(sourceFile)) {
|
||||
var span = void 0;
|
||||
@ -73262,7 +73284,7 @@ var ts;
|
||||
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
|
||||
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
|
||||
var issuedMemberError = false;
|
||||
var _loop_21 = function (member) {
|
||||
var _loop_22 = function (member) {
|
||||
if (ts.hasStaticModifier(member)) {
|
||||
return "continue";
|
||||
}
|
||||
@ -73281,7 +73303,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
||||
var member = _a[_i];
|
||||
_loop_21(member);
|
||||
_loop_22(member);
|
||||
}
|
||||
if (!issuedMemberError) {
|
||||
// check again with diagnostics to generate a less-specific error
|
||||
@ -74054,7 +74076,6 @@ var ts;
|
||||
}
|
||||
}
|
||||
function checkImportBinding(node) {
|
||||
checkGrammarAwaitIdentifier(node.name);
|
||||
checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
|
||||
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
|
||||
checkAliasSymbol(node);
|
||||
@ -75225,10 +75246,10 @@ var ts;
|
||||
// If this is from nested object binding pattern
|
||||
// for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) {
|
||||
if (expr.parent.kind === 285 /* PropertyAssignment */) {
|
||||
var node_1 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
|
||||
var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_1) || errorType;
|
||||
var propertyIndex = ts.indexOfNode(node_1.properties, expr.parent);
|
||||
return checkObjectLiteralDestructuringPropertyAssignment(node_1, typeOfParentObjectLiteral, propertyIndex);
|
||||
var node_2 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
|
||||
var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_2) || errorType;
|
||||
var propertyIndex = ts.indexOfNode(node_2.properties, expr.parent);
|
||||
return checkObjectLiteralDestructuringPropertyAssignment(node_2, typeOfParentObjectLiteral, propertyIndex);
|
||||
}
|
||||
// Array literal assignment - array destructuring pattern
|
||||
var node = ts.cast(expr.parent, ts.isArrayLiteralExpression);
|
||||
@ -76585,29 +76606,18 @@ var ts;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function checkGrammarAwaitIdentifier(name) {
|
||||
if (name && ts.isIdentifier(name) && name.originalKeywordKind === 130 /* AwaitKeyword */ && isInTopLevelContext(name.parent)) {
|
||||
var file = ts.getSourceFileOfNode(name);
|
||||
if (!file.isDeclarationFile && ts.isExternalModule(file)) {
|
||||
return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.idText(name));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function checkGrammarFunctionLikeDeclaration(node) {
|
||||
// Prevent cascading error by short-circuit
|
||||
var file = ts.getSourceFileOfNode(node);
|
||||
return checkGrammarDecoratorsAndModifiers(node) ||
|
||||
checkGrammarTypeParameterList(node.typeParameters, file) ||
|
||||
(ts.isFunctionDeclaration(node) && checkGrammarAwaitIdentifier(node.name)) ||
|
||||
checkGrammarParameterList(node.parameters) ||
|
||||
checkGrammarArrowFunction(node, file) ||
|
||||
(ts.isFunctionLikeDeclaration(node) && checkGrammarForUseStrictSimpleParameterList(node));
|
||||
}
|
||||
function checkGrammarClassLikeDeclaration(node) {
|
||||
var file = ts.getSourceFileOfNode(node);
|
||||
return (ts.isClassDeclaration(node) && checkGrammarAwaitIdentifier(node.name)) ||
|
||||
checkGrammarClassDeclarationHeritageClauses(node) ||
|
||||
return checkGrammarClassDeclarationHeritageClauses(node) ||
|
||||
checkGrammarTypeParameterList(node.typeParameters, file);
|
||||
}
|
||||
function checkGrammarArrowFunction(node, file) {
|
||||
@ -77177,9 +77187,6 @@ var ts;
|
||||
return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_have_a_property_name);
|
||||
}
|
||||
}
|
||||
if (ts.isIdentifier(node.name) && checkGrammarAwaitIdentifier(node.name)) {
|
||||
return true;
|
||||
}
|
||||
if (node.dotDotDotToken && node.initializer) {
|
||||
// Error on equals token which immediately precedes the initializer
|
||||
return grammarErrorAtPos(node, node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer);
|
||||
@ -77236,9 +77243,6 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ts.isIdentifier(node.name) && checkGrammarAwaitIdentifier(node.name)) {
|
||||
return true;
|
||||
}
|
||||
if (node.exclamationToken && (node.parent.parent.kind !== 229 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) {
|
||||
return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation);
|
||||
}
|
||||
@ -107201,7 +107205,7 @@ var ts;
|
||||
});
|
||||
// Sort by paths closest to importing file Name directory
|
||||
var sortedPaths = [];
|
||||
var _loop_22 = function (directory) {
|
||||
var _loop_23 = function (directory) {
|
||||
var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
|
||||
var pathsInDirectory;
|
||||
allFileNames.forEach(function (canonicalFileName, fileName) {
|
||||
@ -107227,7 +107231,7 @@ var ts;
|
||||
};
|
||||
var out_directory_1;
|
||||
for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) {
|
||||
var state_8 = _loop_22(directory);
|
||||
var state_8 = _loop_23(directory);
|
||||
directory = out_directory_1;
|
||||
if (state_8 === "break")
|
||||
break;
|
||||
|
||||
@ -13972,6 +13972,15 @@ var ts;
|
||||
}
|
||||
}
|
||||
ts.getThisContainer = getThisContainer;
|
||||
function isInTopLevelContext(node) {
|
||||
// The name of a class or function declaration is a BindingIdentifier in its surrounding scope.
|
||||
if (ts.isIdentifier(node) && (ts.isClassDeclaration(node.parent) || ts.isFunctionDeclaration(node.parent)) && node.parent.name === node) {
|
||||
node = node.parent;
|
||||
}
|
||||
var container = getThisContainer(node, /*includeArrowFunctions*/ true);
|
||||
return ts.isSourceFile(container);
|
||||
}
|
||||
ts.isInTopLevelContext = isInTopLevelContext;
|
||||
function getNewTargetContainer(node) {
|
||||
var container = getThisContainer(node, /*includeArrowFunctions*/ false);
|
||||
if (container) {
|
||||
@ -15169,13 +15178,7 @@ var ts;
|
||||
return parent.name === node;
|
||||
case 156 /* QualifiedName */:
|
||||
// Name on right hand side of dot in a type query or type reference
|
||||
if (parent.right === node) {
|
||||
while (parent.kind === 156 /* QualifiedName */) {
|
||||
parent = parent.parent;
|
||||
}
|
||||
return parent.kind === 175 /* TypeQuery */ || parent.kind === 172 /* TypeReference */;
|
||||
}
|
||||
return false;
|
||||
return parent.right === node;
|
||||
case 195 /* BindingElement */:
|
||||
case 262 /* ImportSpecifier */:
|
||||
// Property name in binding element or import specifier
|
||||
@ -27532,31 +27535,6 @@ var ts;
|
||||
createBaseNode: function (kind) { return countNode(new NodeConstructor(kind, /*pos*/ 0, /*end*/ 0)); }
|
||||
};
|
||||
var factory = ts.createNodeFactory(1 /* NoParenthesizerRules */ | 2 /* NoNodeConverters */ | 8 /* NoOriginalNode */, baseNodeFactory);
|
||||
var reparseContext = {
|
||||
get factory() { return factory; },
|
||||
enableEmitNotification: ts.notImplemented,
|
||||
enableSubstitution: ts.notImplemented,
|
||||
endLexicalEnvironment: ts.returnUndefined,
|
||||
getCompilerOptions: ts.notImplemented,
|
||||
getEmitHost: ts.notImplemented,
|
||||
getEmitResolver: ts.notImplemented,
|
||||
getEmitHelperFactory: ts.notImplemented,
|
||||
setLexicalEnvironmentFlags: ts.noop,
|
||||
getLexicalEnvironmentFlags: function () { return 0; },
|
||||
hoistFunctionDeclaration: ts.notImplemented,
|
||||
hoistVariableDeclaration: ts.notImplemented,
|
||||
addInitializationStatement: ts.notImplemented,
|
||||
isEmitNotificationEnabled: ts.notImplemented,
|
||||
isSubstitutionEnabled: ts.notImplemented,
|
||||
onEmitNode: ts.notImplemented,
|
||||
onSubstituteNode: ts.notImplemented,
|
||||
readEmitHelpers: ts.notImplemented,
|
||||
requestEmitHelper: ts.notImplemented,
|
||||
resumeLexicalEnvironment: ts.noop,
|
||||
startLexicalEnvironment: ts.noop,
|
||||
suspendLexicalEnvironment: ts.noop,
|
||||
addDiagnostic: ts.notImplemented,
|
||||
};
|
||||
var fileName;
|
||||
var sourceFlags;
|
||||
var sourceText;
|
||||
@ -27620,6 +27598,8 @@ var ts;
|
||||
// parsing. These context flags are naturally stored and restored through normal recursive
|
||||
// descent parsing and unwinding.
|
||||
var contextFlags;
|
||||
// Indicates whether we are currently parsing top-level statements.
|
||||
var topLevel = true;
|
||||
// Whether or not we've had a parse error since creating the last AST node. If we have
|
||||
// encountered an error, it will be stored on the next AST node we create. Parse errors
|
||||
// can be broken down into three categories:
|
||||
@ -27763,6 +27743,7 @@ var ts;
|
||||
identifierCount = 0;
|
||||
nodeCount = 0;
|
||||
sourceFlags = 0;
|
||||
topLevel = true;
|
||||
switch (scriptKind) {
|
||||
case 1 /* JS */:
|
||||
case 2 /* JSX */:
|
||||
@ -27799,6 +27780,7 @@ var ts;
|
||||
parsingContext = 0;
|
||||
identifiers = undefined;
|
||||
notParenthesizedArrow = undefined;
|
||||
topLevel = true;
|
||||
}
|
||||
function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind) {
|
||||
var isDeclarationFile = isDeclarationFileName(fileName);
|
||||
@ -27847,108 +27829,98 @@ var ts;
|
||||
return node;
|
||||
}
|
||||
function reparseTopLevelAwait(sourceFile) {
|
||||
return ts.visitEachChild(sourceFile, visitor, reparseContext);
|
||||
function visitor(node) {
|
||||
if (!(node.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */)) {
|
||||
return node;
|
||||
var savedSyntaxCursor = syntaxCursor;
|
||||
var baseSyntaxCursor = IncrementalParser.createSyntaxCursor(sourceFile);
|
||||
syntaxCursor = { currentNode: currentNode };
|
||||
var statements = [];
|
||||
var savedParseDiagnostics = parseDiagnostics;
|
||||
parseDiagnostics = [];
|
||||
var pos = 0;
|
||||
var start = findNextStatementWithAwait(sourceFile.statements, 0);
|
||||
var _loop_3 = function () {
|
||||
// append all statements between pos and start
|
||||
var prevStatement = sourceFile.statements[pos];
|
||||
var nextStatement = sourceFile.statements[start];
|
||||
ts.addRange(statements, sourceFile.statements, pos, start);
|
||||
pos = findNextStatementWithoutAwait(sourceFile.statements, start);
|
||||
// append all diagnostics associated with the copied range
|
||||
var diagnosticStart = ts.findIndex(savedParseDiagnostics, function (diagnostic) { return diagnostic.start >= prevStatement.pos; });
|
||||
var diagnosticEnd = diagnosticStart >= 0 ? ts.findIndex(savedParseDiagnostics, function (diagnostic) { return diagnostic.start >= nextStatement.pos; }, diagnosticStart) : -1;
|
||||
if (diagnosticStart >= 0) {
|
||||
ts.addRange(parseDiagnostics, savedParseDiagnostics, diagnosticStart, diagnosticEnd >= 0 ? diagnosticEnd : undefined);
|
||||
}
|
||||
// We explicitly visit each non-Expression node that has an immediate Expression child so that
|
||||
// we can reparse the Expression in an Await context
|
||||
switch (node.kind) {
|
||||
case 160 /* Decorator */: return reparseDecorator(node);
|
||||
case 157 /* ComputedPropertyName */: return reparseComputedPropertyName(node);
|
||||
case 220 /* ExpressionWithTypeArguments */: return reparseExpressionWithTypeArguments(node);
|
||||
case 230 /* ExpressionStatement */: return reparseExpressionStatement(node);
|
||||
case 231 /* IfStatement */: return reparseIfStatement(node);
|
||||
case 241 /* SwitchStatement */: return reparseSwitchStatement(node);
|
||||
case 240 /* WithStatement */: return reparseWithStatement(node);
|
||||
case 232 /* DoStatement */: return reparseDoStatement(node);
|
||||
case 233 /* WhileStatement */: return reparseWhileStatement(node);
|
||||
case 234 /* ForStatement */: return reparseForStatement(node);
|
||||
case 235 /* ForInStatement */: return reparseForInStatement(node);
|
||||
case 236 /* ForOfStatement */: return reparseForOfStatement(node);
|
||||
case 239 /* ReturnStatement */: return reparseReturnStatement(node);
|
||||
case 243 /* ThrowStatement */: return reparseThrowStatement(node);
|
||||
case 263 /* ExportAssignment */: return reparseExportAssignment(node);
|
||||
case 246 /* VariableDeclaration */: return reparseVariableDeclaration(node);
|
||||
case 195 /* BindingElement */: return reparseBindingElement(node);
|
||||
default: return ts.visitEachChild(node, visitor, reparseContext);
|
||||
// reparse all statements between start and pos. We skip existing diagnostics for the same range and allow the parser to generate new ones.
|
||||
speculationHelper(function () {
|
||||
var savedContextFlags = contextFlags;
|
||||
contextFlags |= 32768 /* AwaitContext */;
|
||||
scanner.setTextPos(nextStatement.pos);
|
||||
nextToken();
|
||||
while (token() !== 1 /* EndOfFileToken */) {
|
||||
var startPos = scanner.getStartPos();
|
||||
var statement = parseListElement(0 /* SourceElements */, parseStatement);
|
||||
statements.push(statement);
|
||||
if (startPos === scanner.getStartPos()) {
|
||||
nextToken();
|
||||
}
|
||||
if (pos >= 0) {
|
||||
var nonAwaitStatement = sourceFile.statements[pos];
|
||||
if (statement.end === nonAwaitStatement.pos) {
|
||||
// done reparsing this section
|
||||
break;
|
||||
}
|
||||
if (statement.end > nonAwaitStatement.pos) {
|
||||
// we ate into the next statement, so we must reparse it.
|
||||
pos = findNextStatementWithoutAwait(sourceFile.statements, pos + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
contextFlags = savedContextFlags;
|
||||
}, 2 /* Reparse */);
|
||||
// find the next statement containing an `await`
|
||||
start = pos >= 0 ? findNextStatementWithAwait(sourceFile.statements, pos) : -1;
|
||||
};
|
||||
while (start !== -1) {
|
||||
_loop_3();
|
||||
}
|
||||
// append all statements between pos and the end of the list
|
||||
if (pos >= 0) {
|
||||
var prevStatement_1 = sourceFile.statements[pos];
|
||||
ts.addRange(statements, sourceFile.statements, pos);
|
||||
// append all diagnostics associated with the copied range
|
||||
var diagnosticStart = ts.findIndex(savedParseDiagnostics, function (diagnostic) { return diagnostic.start >= prevStatement_1.pos; });
|
||||
if (diagnosticStart >= 0) {
|
||||
ts.addRange(parseDiagnostics, savedParseDiagnostics, diagnosticStart);
|
||||
}
|
||||
}
|
||||
function reparse(node, parse) {
|
||||
if (node && node.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */) {
|
||||
if (ts.isExpression(node)) {
|
||||
return speculationHelper(function () {
|
||||
scanner.setTextPos(node.pos);
|
||||
var savedContextFlags = contextFlags;
|
||||
contextFlags = node.flags & 25358336 /* ContextFlags */;
|
||||
nextToken();
|
||||
var result = doInAwaitContext(parse);
|
||||
contextFlags = savedContextFlags;
|
||||
return result;
|
||||
}, 2 /* Reparse */);
|
||||
syntaxCursor = savedSyntaxCursor;
|
||||
return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements));
|
||||
function containsPossibleTopLevelAwait(node) {
|
||||
return !(node.flags & 32768 /* AwaitContext */)
|
||||
&& !!(node.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */);
|
||||
}
|
||||
function findNextStatementWithAwait(statements, start) {
|
||||
for (var i = start; i < statements.length; i++) {
|
||||
if (containsPossibleTopLevelAwait(statements[i])) {
|
||||
return i;
|
||||
}
|
||||
return ts.visitEachChild(node, visitor, reparseContext);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
function findNextStatementWithoutAwait(statements, start) {
|
||||
for (var i = start; i < statements.length; i++) {
|
||||
if (!containsPossibleTopLevelAwait(statements[i])) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
function currentNode(position) {
|
||||
var node = baseSyntaxCursor.currentNode(position);
|
||||
if (topLevel && node && containsPossibleTopLevelAwait(node)) {
|
||||
node.intersectsChange = true;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
function update(updated, original) {
|
||||
if (updated !== original) {
|
||||
ts.setNodeFlags(updated, updated.flags | 32768 /* AwaitContext */);
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
function reparseExpressionStatement(node) {
|
||||
return update(factory.updateExpressionStatement(node, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseReturnStatement(node) {
|
||||
return update(factory.updateReturnStatement(node, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseThrowStatement(node) {
|
||||
return update(factory.updateThrowStatement(node, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseIfStatement(node) {
|
||||
return update(factory.updateIfStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.thenStatement, visitor), ts.visitNode(node.elseStatement, visitor)), node);
|
||||
}
|
||||
function reparseSwitchStatement(node) {
|
||||
return update(factory.updateSwitchStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.caseBlock, visitor)), node);
|
||||
}
|
||||
function reparseWithStatement(node) {
|
||||
return update(factory.updateWithStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
|
||||
}
|
||||
function reparseDoStatement(node) {
|
||||
return update(factory.updateDoStatement(node, ts.visitNode(node.statement, visitor), reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseWhileStatement(node) {
|
||||
return update(factory.updateWhileStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
|
||||
}
|
||||
function reparseForStatement(node) {
|
||||
return update(factory.updateForStatement(node, reparse(node.initializer, parseExpression), reparse(node.condition, parseExpression), reparse(node.incrementor, parseExpression), ts.visitNode(node, visitor)), node);
|
||||
}
|
||||
function reparseForInStatement(node) {
|
||||
return update(factory.updateForInStatement(node, reparse(node.initializer, parseExpression), reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
|
||||
}
|
||||
function reparseForOfStatement(node) {
|
||||
return update(factory.updateForOfStatement(node, node.awaitModifier, reparse(node.initializer, parseExpression), reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
|
||||
}
|
||||
function reparseExportAssignment(node) {
|
||||
return update(factory.updateExportAssignment(node, ts.visitNodes(node.decorators, visitor), node.modifiers, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseExpressionWithTypeArguments(node) {
|
||||
return update(factory.updateExpressionWithTypeArguments(node, reparse(node.expression, parseLeftHandSideExpressionOrHigher), node.typeArguments), node);
|
||||
}
|
||||
function reparseDecorator(node) {
|
||||
return update(factory.updateDecorator(node, reparse(node.expression, parseLeftHandSideExpressionOrHigher)), node);
|
||||
}
|
||||
function reparseComputedPropertyName(node) {
|
||||
return update(factory.updateComputedPropertyName(node, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseVariableDeclaration(node) {
|
||||
return update(factory.updateVariableDeclaration(node, ts.visitNode(node.name, visitor), node.exclamationToken, node.type, reparse(node.initializer, parseExpression)), node);
|
||||
}
|
||||
function reparseBindingElement(node) {
|
||||
return update(factory.updateBindingElement(node, node.dotDotDotToken, ts.visitNode(node.propertyName, visitor), ts.visitNode(node.name, visitor), reparse(node.initializer, parseExpression)), node);
|
||||
}
|
||||
}
|
||||
function fixupParentReferences(rootNode) {
|
||||
// normally parent references are set during binding. However, for clients that only need
|
||||
@ -28198,6 +28170,12 @@ var ts;
|
||||
function tryParse(callback) {
|
||||
return speculationHelper(callback, 0 /* TryParse */);
|
||||
}
|
||||
function isBindingIdentifier() {
|
||||
if (token() === 78 /* Identifier */) {
|
||||
return true;
|
||||
}
|
||||
return token() > 115 /* LastReservedWord */;
|
||||
}
|
||||
// Ignore strict mode flag because we will report an error in type checker instead.
|
||||
function isIdentifier() {
|
||||
if (token() === 78 /* Identifier */) {
|
||||
@ -28367,6 +28345,9 @@ var ts;
|
||||
ts.Diagnostics.Identifier_expected;
|
||||
return createMissingNode(78 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg);
|
||||
}
|
||||
function parseBindingIdentifier(privateIdentifierDiagnosticMessage) {
|
||||
return createIdentifier(isBindingIdentifier(), /*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage);
|
||||
}
|
||||
function parseIdentifier(diagnosticMessage, privateIdentifierDiagnosticMessage) {
|
||||
return createIdentifier(isIdentifier(), diagnosticMessage, privateIdentifierDiagnosticMessage);
|
||||
}
|
||||
@ -28544,9 +28525,9 @@ var ts;
|
||||
return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword();
|
||||
}
|
||||
case 8 /* VariableDeclarations */:
|
||||
return isIdentifierOrPrivateIdentifierOrPattern();
|
||||
return isBindingIdentifierOrPrivateIdentifierOrPattern();
|
||||
case 10 /* ArrayBindingElements */:
|
||||
return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isIdentifierOrPrivateIdentifierOrPattern();
|
||||
return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern();
|
||||
case 19 /* TypeParameters */:
|
||||
return isIdentifier();
|
||||
case 15 /* ArrayLiteralMembers */:
|
||||
@ -29388,7 +29369,7 @@ var ts;
|
||||
}
|
||||
function isStartOfParameter(isJSDocParameter) {
|
||||
return token() === 25 /* DotDotDotToken */ ||
|
||||
isIdentifierOrPrivateIdentifierOrPattern() ||
|
||||
isBindingIdentifierOrPrivateIdentifierOrPattern() ||
|
||||
ts.isModifierKind(token()) ||
|
||||
token() === 59 /* AtToken */ ||
|
||||
isStartOfType(/*inStartOfParameter*/ !isJSDocParameter);
|
||||
@ -29410,22 +29391,34 @@ var ts;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
function parseParameterInOuterAwaitContext() {
|
||||
return parseParameterWorker(/*inOuterAwaitContext*/ true);
|
||||
}
|
||||
function parseParameter() {
|
||||
return parseParameterWorker(/*inOuterAwaitContext*/ false);
|
||||
}
|
||||
function parseParameterWorker(inOuterAwaitContext) {
|
||||
var pos = getNodePos();
|
||||
var hasJSDoc = hasPrecedingJSDocComment();
|
||||
if (token() === 107 /* ThisKeyword */) {
|
||||
var node = factory.createParameterDeclaration(
|
||||
var node_1 = factory.createParameterDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
/*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true),
|
||||
/*questionToken*/ undefined, parseTypeAnnotation(),
|
||||
/*initializer*/ undefined);
|
||||
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
||||
return withJSDoc(finishNode(node_1, pos), hasJSDoc);
|
||||
}
|
||||
// FormalParameter [Yield,Await]:
|
||||
// BindingElement[?Yield,?Await]
|
||||
var modifiers;
|
||||
return withJSDoc(finishNode(factory.createParameterDeclaration(parseDecorators(), modifiers = parseModifiers(), parseOptionalToken(25 /* DotDotDotToken */), parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc);
|
||||
// Decorators are parsed in the outer [Await] context, the rest of the parameter is parsed in the function's [Await] context.
|
||||
var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators();
|
||||
var savedTopLevel = topLevel;
|
||||
topLevel = false;
|
||||
var modifiers = parseModifiers();
|
||||
var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, parseOptionalToken(25 /* DotDotDotToken */), parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc);
|
||||
topLevel = savedTopLevel;
|
||||
return node;
|
||||
}
|
||||
function parseReturnType(returnToken, isType) {
|
||||
if (shouldParseReturnType(returnToken, isType)) {
|
||||
@ -29468,7 +29461,7 @@ var ts;
|
||||
setAwaitContext(!!(flags & 2 /* Await */));
|
||||
var parameters = flags & 32 /* JSDoc */ ?
|
||||
parseDelimitedList(17 /* JSDocParameters */, parseJSDocParameter) :
|
||||
parseDelimitedList(16 /* Parameters */, parseParameter);
|
||||
parseDelimitedList(16 /* Parameters */, savedAwaitContext ? parseParameterInOuterAwaitContext : parseParameter);
|
||||
setYieldContext(savedYieldContext);
|
||||
setAwaitContext(savedAwaitContext);
|
||||
return parameters;
|
||||
@ -30597,9 +30590,13 @@ var ts;
|
||||
// Note: even when 'IgnoreMissingOpenBrace' is passed, parseBody will still error.
|
||||
return parseFunctionBlock(16 /* IgnoreMissingOpenBrace */ | (isAsync ? 2 /* Await */ : 0 /* None */));
|
||||
}
|
||||
return isAsync
|
||||
var savedTopLevel = topLevel;
|
||||
topLevel = false;
|
||||
var node = isAsync
|
||||
? doInAwaitContext(parseAssignmentExpressionOrHigher)
|
||||
: doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
|
||||
topLevel = savedTopLevel;
|
||||
return node;
|
||||
}
|
||||
function parseConditionalExpressionRest(leftOperand, pos) {
|
||||
// Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher.
|
||||
@ -31590,10 +31587,10 @@ var ts;
|
||||
var asteriskToken = parseOptionalToken(41 /* AsteriskToken */);
|
||||
var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */;
|
||||
var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */;
|
||||
var name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) :
|
||||
isGenerator ? doInYieldContext(parseOptionalIdentifier) :
|
||||
isAsync ? doInAwaitContext(parseOptionalIdentifier) :
|
||||
parseOptionalIdentifier();
|
||||
var name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalBindingIdentifier) :
|
||||
isGenerator ? doInYieldContext(parseOptionalBindingIdentifier) :
|
||||
isAsync ? doInAwaitContext(parseOptionalBindingIdentifier) :
|
||||
parseOptionalBindingIdentifier();
|
||||
var typeParameters = parseTypeParameters();
|
||||
var parameters = parseParameters(isGenerator | isAsync);
|
||||
var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
|
||||
@ -31604,8 +31601,8 @@ var ts;
|
||||
var node = factory.createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body);
|
||||
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
||||
}
|
||||
function parseOptionalIdentifier() {
|
||||
return isIdentifier() ? parseIdentifier() : undefined;
|
||||
function parseOptionalBindingIdentifier() {
|
||||
return isBindingIdentifier() ? parseBindingIdentifier() : undefined;
|
||||
}
|
||||
function parseNewExpressionOrNewDotTarget() {
|
||||
var pos = getNodePos();
|
||||
@ -31661,6 +31658,8 @@ var ts;
|
||||
setYieldContext(!!(flags & 1 /* Yield */));
|
||||
var savedAwaitContext = inAwaitContext();
|
||||
setAwaitContext(!!(flags & 2 /* Await */));
|
||||
var savedTopLevel = topLevel;
|
||||
topLevel = false;
|
||||
// We may be in a [Decorator] context when parsing a function expression or
|
||||
// arrow function. The body of the function is not in [Decorator] context.
|
||||
var saveDecoratorContext = inDecoratorContext();
|
||||
@ -31671,6 +31670,7 @@ var ts;
|
||||
if (saveDecoratorContext) {
|
||||
setDecoratorContext(/*val*/ true);
|
||||
}
|
||||
topLevel = savedTopLevel;
|
||||
setYieldContext(savedYieldContext);
|
||||
setAwaitContext(savedAwaitContext);
|
||||
return block;
|
||||
@ -32229,7 +32229,7 @@ var ts;
|
||||
function parseObjectBindingElement() {
|
||||
var pos = getNodePos();
|
||||
var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */);
|
||||
var tokenIsIdentifier = isIdentifier();
|
||||
var tokenIsIdentifier = isBindingIdentifier();
|
||||
var propertyName = parsePropertyName();
|
||||
var name;
|
||||
if (tokenIsIdentifier && token() !== 58 /* ColonToken */) {
|
||||
@ -32257,11 +32257,11 @@ var ts;
|
||||
parseExpected(23 /* CloseBracketToken */);
|
||||
return finishNode(factory.createArrayBindingPattern(elements), pos);
|
||||
}
|
||||
function isIdentifierOrPrivateIdentifierOrPattern() {
|
||||
function isBindingIdentifierOrPrivateIdentifierOrPattern() {
|
||||
return token() === 18 /* OpenBraceToken */
|
||||
|| token() === 22 /* OpenBracketToken */
|
||||
|| token() === 79 /* PrivateIdentifier */
|
||||
|| isIdentifier();
|
||||
|| isBindingIdentifier();
|
||||
}
|
||||
function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) {
|
||||
if (token() === 22 /* OpenBracketToken */) {
|
||||
@ -32270,7 +32270,7 @@ var ts;
|
||||
if (token() === 18 /* OpenBraceToken */) {
|
||||
return parseObjectBindingPattern();
|
||||
}
|
||||
return parseIdentifier(/*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage);
|
||||
return parseBindingIdentifier(privateIdentifierDiagnosticMessage);
|
||||
}
|
||||
function parseVariableDeclarationAllowExclamation() {
|
||||
return parseVariableDeclaration(/*allowExclamation*/ true);
|
||||
@ -32342,7 +32342,7 @@ var ts;
|
||||
parseExpected(97 /* FunctionKeyword */);
|
||||
var asteriskToken = parseOptionalToken(41 /* AsteriskToken */);
|
||||
// We don't parse the name here in await context, instead we will report a grammar error in the checker.
|
||||
var name = modifierFlags & 512 /* Default */ ? parseOptionalIdentifier() : parseIdentifier();
|
||||
var name = modifierFlags & 512 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier();
|
||||
var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */;
|
||||
var isAsync = modifierFlags & 256 /* Async */ ? 2 /* Await */ : 0 /* None */;
|
||||
var typeParameters = parseTypeParameters();
|
||||
@ -32486,12 +32486,24 @@ var ts;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function parseDecoratorExpression() {
|
||||
if (inAwaitContext() && token() === 130 /* AwaitKeyword */) {
|
||||
// `@await` is is disallowed in an [Await] context, but can cause parsing to go off the rails
|
||||
// This simply parses the missing identifier and moves on.
|
||||
var pos = getNodePos();
|
||||
var awaitExpression = parseIdentifier(ts.Diagnostics.Expression_expected);
|
||||
nextToken();
|
||||
var memberExpression = parseMemberExpressionRest(pos, awaitExpression, /*allowOptionalChain*/ true);
|
||||
return parseCallExpressionRest(pos, memberExpression);
|
||||
}
|
||||
return parseLeftHandSideExpressionOrHigher();
|
||||
}
|
||||
function tryParseDecorator() {
|
||||
var pos = getNodePos();
|
||||
if (!parseOptional(59 /* AtToken */)) {
|
||||
return undefined;
|
||||
}
|
||||
var expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher);
|
||||
var expression = doInDecoratorContext(parseDecoratorExpression);
|
||||
return finishNode(factory.createDecorator(expression), pos);
|
||||
}
|
||||
function parseDecorators() {
|
||||
@ -32632,8 +32644,8 @@ var ts;
|
||||
// - class expression with omitted name, 'implements' starts heritage clause
|
||||
// - class with name 'implements'
|
||||
// 'isImplementsClause' helps to disambiguate between these two cases
|
||||
return isIdentifier() && !isImplementsClause()
|
||||
? parseIdentifier()
|
||||
return isBindingIdentifier() && !isImplementsClause()
|
||||
? createIdentifier(isBindingIdentifier())
|
||||
: undefined;
|
||||
}
|
||||
function isImplementsClause() {
|
||||
@ -34429,6 +34441,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
IncrementalParser.createSyntaxCursor = createSyntaxCursor;
|
||||
var InvalidPosition;
|
||||
(function (InvalidPosition) {
|
||||
InvalidPosition[InvalidPosition["Value"] = -1] = "Value";
|
||||
@ -36215,7 +36228,7 @@ var ts;
|
||||
}
|
||||
function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) {
|
||||
var result = returnValue ? {} : undefined;
|
||||
var _loop_3 = function (element) {
|
||||
var _loop_4 = function (element) {
|
||||
if (element.kind !== 285 /* PropertyAssignment */) {
|
||||
errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected));
|
||||
return "continue";
|
||||
@ -36268,7 +36281,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
|
||||
var element = _a[_i];
|
||||
_loop_3(element);
|
||||
_loop_4(element);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -36451,7 +36464,7 @@ var ts;
|
||||
var optionsNameMap = _a.optionsNameMap;
|
||||
var result = ts.createMap();
|
||||
var getCanonicalFileName = pathOptions && ts.createGetCanonicalFileName(pathOptions.useCaseSensitiveFileNames);
|
||||
var _loop_4 = function (name) {
|
||||
var _loop_5 = function (name) {
|
||||
if (ts.hasProperty(options, name)) {
|
||||
// tsconfig only options cannot be specified via command line,
|
||||
// so we can assume that only types that can appear here string | number | boolean
|
||||
@ -36485,7 +36498,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var name in options) {
|
||||
_loop_4(name);
|
||||
_loop_5(name);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -37246,7 +37259,7 @@ var ts;
|
||||
}
|
||||
var jsonOnlyIncludeRegexes;
|
||||
if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) {
|
||||
var _loop_5 = function (file) {
|
||||
var _loop_6 = function (file) {
|
||||
if (ts.fileExtensionIs(file, ".json" /* Json */)) {
|
||||
// Valid only if *.json specified
|
||||
if (!jsonOnlyIncludeRegexes) {
|
||||
@ -37284,7 +37297,7 @@ var ts;
|
||||
};
|
||||
for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensionsWithJsonIfResolveJsonModule, validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined); _a < _b.length; _a++) {
|
||||
var file = _b[_a];
|
||||
_loop_5(file);
|
||||
_loop_6(file);
|
||||
}
|
||||
}
|
||||
var literalFiles = ts.arrayFrom(literalFileMap.values());
|
||||
@ -40691,18 +40704,31 @@ var ts;
|
||||
currentFlow = saveCurrentFlow;
|
||||
}
|
||||
// The binder visits every node in the syntax tree so it is a convenient place to perform a single localized
|
||||
// check for reserved words used as identifiers in strict mode code.
|
||||
function checkStrictModeIdentifier(node) {
|
||||
if (inStrictMode &&
|
||||
node.originalKeywordKind >= 116 /* FirstFutureReservedWord */ &&
|
||||
node.originalKeywordKind <= 124 /* LastFutureReservedWord */ &&
|
||||
!ts.isIdentifierName(node) &&
|
||||
// check for reserved words used as identifiers in strict mode code, as well as `yield` or `await` in
|
||||
// [Yield] or [Await] contexts, respectively.
|
||||
function checkContextualIdentifier(node) {
|
||||
// Report error only if there are no parse errors in file
|
||||
if (!file.parseDiagnostics.length &&
|
||||
!(node.flags & 8388608 /* Ambient */) &&
|
||||
!(node.flags & 4194304 /* JSDoc */)) {
|
||||
// Report error only if there are no parse errors in file
|
||||
if (!file.parseDiagnostics.length) {
|
||||
!(node.flags & 4194304 /* JSDoc */) &&
|
||||
!ts.isIdentifierName(node)) {
|
||||
// strict mode identifiers
|
||||
if (inStrictMode &&
|
||||
node.originalKeywordKind >= 116 /* FirstFutureReservedWord */ &&
|
||||
node.originalKeywordKind <= 124 /* LastFutureReservedWord */) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node)));
|
||||
}
|
||||
else if (node.originalKeywordKind === 130 /* AwaitKeyword */) {
|
||||
if (ts.isExternalModule(file) && ts.isInTopLevelContext(node)) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.declarationNameToString(node)));
|
||||
}
|
||||
else if (node.flags & 32768 /* AwaitContext */) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node)));
|
||||
}
|
||||
}
|
||||
else if (node.originalKeywordKind === 124 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node)));
|
||||
}
|
||||
}
|
||||
}
|
||||
function getStrictModeIdentifierMessage(node) {
|
||||
@ -40969,7 +40995,7 @@ var ts;
|
||||
if (currentFlow && (ts.isExpression(node) || parent.kind === 286 /* ShorthandPropertyAssignment */)) {
|
||||
node.flowNode = currentFlow;
|
||||
}
|
||||
return checkStrictModeIdentifier(node);
|
||||
return checkContextualIdentifier(node);
|
||||
case 105 /* SuperKeyword */:
|
||||
node.flowNode = currentFlow;
|
||||
break;
|
||||
@ -43165,7 +43191,7 @@ var ts;
|
||||
function addDuplicateDeclarationError(node, message, symbolName, relatedNodes) {
|
||||
var errorNode = (ts.getExpandoInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getNameOfExpando(node) : ts.getNameOfDeclaration(node)) || node;
|
||||
var err = lookupOrIssueError(errorNode, message, symbolName);
|
||||
var _loop_6 = function (relatedNode) {
|
||||
var _loop_7 = function (relatedNode) {
|
||||
var adjustedNode = (ts.getExpandoInitializer(relatedNode, /*isPrototypeAssignment*/ false) ? ts.getNameOfExpando(relatedNode) : ts.getNameOfDeclaration(relatedNode)) || relatedNode;
|
||||
if (adjustedNode === errorNode)
|
||||
return "continue";
|
||||
@ -43178,7 +43204,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, _a = relatedNodes || ts.emptyArray; _i < _a.length; _i++) {
|
||||
var relatedNode = _a[_i];
|
||||
_loop_6(relatedNode);
|
||||
_loop_7(relatedNode);
|
||||
}
|
||||
}
|
||||
function combineSymbolTables(first, second) {
|
||||
@ -45419,7 +45445,7 @@ var ts;
|
||||
}
|
||||
function forEachSymbolTableInScope(enclosingDeclaration, callback) {
|
||||
var result;
|
||||
var _loop_7 = function (location) {
|
||||
var _loop_8 = function (location) {
|
||||
// Locals of a source file are not in scope (because they get merged into the global symbol table)
|
||||
if (location.locals && !isGlobalSourceFile(location)) {
|
||||
if (result = callback(location.locals)) {
|
||||
@ -45465,7 +45491,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var location = enclosingDeclaration; location; location = location.parent) {
|
||||
var state_2 = _loop_7(location);
|
||||
var state_2 = _loop_8(location);
|
||||
if (typeof state_2 === "object")
|
||||
return state_2.value;
|
||||
}
|
||||
@ -47475,7 +47501,7 @@ var ts;
|
||||
if (ts.length(reexports) > 1) {
|
||||
var groups = ts.group(reexports, function (decl) { return ts.isStringLiteral(decl.moduleSpecifier) ? ">" + decl.moduleSpecifier.text : ">"; });
|
||||
if (groups.length !== reexports.length) {
|
||||
var _loop_8 = function (group_1) {
|
||||
var _loop_9 = function (group_1) {
|
||||
if (group_1.length > 1) {
|
||||
// remove group members from statements and then merge group members and add back to statements
|
||||
statements = __spreadArrays(ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), [
|
||||
@ -47488,7 +47514,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) {
|
||||
var group_1 = groups_1[_i];
|
||||
_loop_8(group_1);
|
||||
_loop_9(group_1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -51000,7 +51026,7 @@ var ts;
|
||||
// signatures from the type, whose ordering would be non-obvious)
|
||||
var masterList = signatureLists[indexWithLengthOverOne !== undefined ? indexWithLengthOverOne : 0];
|
||||
var results = masterList.slice();
|
||||
var _loop_9 = function (signatures) {
|
||||
var _loop_10 = function (signatures) {
|
||||
if (signatures !== masterList) {
|
||||
var signature_1 = signatures[0];
|
||||
ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass");
|
||||
@ -51012,7 +51038,7 @@ var ts;
|
||||
};
|
||||
for (var _b = 0, signatureLists_1 = signatureLists; _b < signatureLists_1.length; _b++) {
|
||||
var signatures = signatureLists_1[_b];
|
||||
var state_3 = _loop_9(signatures);
|
||||
var state_3 = _loop_10(signatures);
|
||||
if (state_3 === "break")
|
||||
break;
|
||||
}
|
||||
@ -51136,7 +51162,7 @@ var ts;
|
||||
var types = type.types;
|
||||
var mixinFlags = findMixins(types);
|
||||
var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; });
|
||||
var _loop_10 = function (i) {
|
||||
var _loop_11 = function (i) {
|
||||
var t = type.types[i];
|
||||
// When an intersection type contains mixin constructor types, the construct signatures from
|
||||
// those types are discarded and their return types are mixed into the return types of all
|
||||
@ -51159,19 +51185,19 @@ var ts;
|
||||
numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1 /* Number */));
|
||||
};
|
||||
for (var i = 0; i < types.length; i++) {
|
||||
_loop_10(i);
|
||||
_loop_11(i);
|
||||
}
|
||||
setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo);
|
||||
}
|
||||
function appendSignatures(signatures, newSignatures) {
|
||||
var _loop_11 = function (sig) {
|
||||
var _loop_12 = function (sig) {
|
||||
if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, compareTypesIdentical); })) {
|
||||
signatures = ts.append(signatures, sig);
|
||||
}
|
||||
};
|
||||
for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) {
|
||||
var sig = newSignatures_1[_i];
|
||||
_loop_11(sig);
|
||||
_loop_12(sig);
|
||||
}
|
||||
return signatures;
|
||||
}
|
||||
@ -53458,7 +53484,7 @@ var ts;
|
||||
var expandedDeclarations = [];
|
||||
var optionalIndex = -1;
|
||||
var restTypes;
|
||||
var _loop_12 = function (i) {
|
||||
var _loop_13 = function (i) {
|
||||
var type = elementTypes[i];
|
||||
var flags = target.elementFlags[i];
|
||||
if (flags & 8 /* Variadic */) {
|
||||
@ -53481,7 +53507,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var i = 0; i < elementTypes.length; i++) {
|
||||
_loop_12(i);
|
||||
_loop_13(i);
|
||||
}
|
||||
if (restTypes) {
|
||||
// Create a union of the collected rest element types.
|
||||
@ -54531,7 +54557,7 @@ var ts;
|
||||
function getConditionalType(root, mapper) {
|
||||
var result;
|
||||
var extraTypes;
|
||||
var _loop_13 = function () {
|
||||
var _loop_14 = function () {
|
||||
var checkType = instantiateType(root.checkType, mapper);
|
||||
var checkTypeInstantiable = isGenericObjectType(checkType) || isGenericIndexType(checkType);
|
||||
var extendsType = instantiateType(root.extendsType, mapper);
|
||||
@ -54605,7 +54631,7 @@ var ts;
|
||||
// types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
|
||||
// purposes of resolution. This means such types aren't subject to the instatiation depth limiter.
|
||||
while (true) {
|
||||
var state_4 = _loop_13();
|
||||
var state_4 = _loop_14();
|
||||
if (typeof state_4 === "object")
|
||||
return state_4.value;
|
||||
if (state_4 === "break")
|
||||
@ -57083,7 +57109,7 @@ var ts;
|
||||
reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
|
||||
checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget];
|
||||
}
|
||||
var _loop_14 = function (prop) {
|
||||
var _loop_15 = function (prop) {
|
||||
if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
|
||||
if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
|
||||
if (reportErrors) {
|
||||
@ -57146,7 +57172,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) {
|
||||
var prop = _a[_i];
|
||||
var state_5 = _loop_14(prop);
|
||||
var state_5 = _loop_15(prop);
|
||||
if (typeof state_5 === "object")
|
||||
return state_5.value;
|
||||
}
|
||||
@ -57819,11 +57845,11 @@ var ts;
|
||||
// constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
|
||||
var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
|
||||
var matchingTypes = [];
|
||||
var _loop_15 = function (combination) {
|
||||
var _loop_16 = function (combination) {
|
||||
var hasMatch = false;
|
||||
outer: for (var _i = 0, _a = target.types; _i < _a.length; _i++) {
|
||||
var type = _a[_i];
|
||||
var _loop_16 = function (i) {
|
||||
var _loop_17 = function (i) {
|
||||
var sourceProperty = sourcePropertiesFiltered[i];
|
||||
var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
|
||||
if (!targetProperty)
|
||||
@ -57839,7 +57865,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
|
||||
var state_7 = _loop_16(i);
|
||||
var state_7 = _loop_17(i);
|
||||
switch (state_7) {
|
||||
case "continue-outer": continue outer;
|
||||
}
|
||||
@ -57853,7 +57879,7 @@ var ts;
|
||||
};
|
||||
for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
|
||||
var combination = discriminantCombinations_1[_a];
|
||||
var state_6 = _loop_15(combination);
|
||||
var state_6 = _loop_16(combination);
|
||||
if (typeof state_6 === "object")
|
||||
return state_6.value;
|
||||
}
|
||||
@ -58495,7 +58521,7 @@ var ts;
|
||||
// The emptyArray singleton is used to signal a recursive invocation.
|
||||
cache.variances = ts.emptyArray;
|
||||
variances = [];
|
||||
var _loop_17 = function (tp) {
|
||||
var _loop_18 = function (tp) {
|
||||
var unmeasurable = false;
|
||||
var unreliable = false;
|
||||
var oldHandler = outofbandVarianceMarkerHandler;
|
||||
@ -58527,7 +58553,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) {
|
||||
var tp = typeParameters_1[_i];
|
||||
_loop_17(tp);
|
||||
_loop_18(tp);
|
||||
}
|
||||
cache.variances = variances;
|
||||
}
|
||||
@ -66010,7 +66036,7 @@ var ts;
|
||||
if (spreadIndex >= 0) {
|
||||
// Create synthetic arguments from spreads of tuple types.
|
||||
var effectiveArgs_1 = args.slice(0, spreadIndex);
|
||||
var _loop_18 = function (i) {
|
||||
var _loop_19 = function (i) {
|
||||
var arg = args[i];
|
||||
// We can call checkExpressionCached because spread expressions never have a contextual type.
|
||||
var spreadType = arg.kind === 217 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
|
||||
@ -66027,7 +66053,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var i = spreadIndex; i < args.length; i++) {
|
||||
_loop_18(i);
|
||||
_loop_19(i);
|
||||
}
|
||||
return effectiveArgs_1;
|
||||
}
|
||||
@ -66329,7 +66355,7 @@ var ts;
|
||||
var min_3 = Number.MAX_VALUE;
|
||||
var minIndex = 0;
|
||||
var i_1 = 0;
|
||||
var _loop_19 = function (c) {
|
||||
var _loop_20 = function (c) {
|
||||
var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
|
||||
var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2);
|
||||
if (diags_2) {
|
||||
@ -66347,7 +66373,7 @@ var ts;
|
||||
};
|
||||
for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
|
||||
var c = candidatesForArgumentError_1[_a];
|
||||
_loop_19(c);
|
||||
_loop_20(c);
|
||||
}
|
||||
var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
|
||||
ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
|
||||
@ -66481,7 +66507,7 @@ var ts;
|
||||
}
|
||||
var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
|
||||
var parameters = [];
|
||||
var _loop_20 = function (i) {
|
||||
var _loop_21 = function (i) {
|
||||
var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
|
||||
i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
|
||||
i < s.parameters.length ? s.parameters[i] : undefined; });
|
||||
@ -66489,7 +66515,7 @@ var ts;
|
||||
parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
|
||||
};
|
||||
for (var i = 0; i < maxNonRestParam; i++) {
|
||||
_loop_20(i);
|
||||
_loop_21(i);
|
||||
}
|
||||
var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
|
||||
var flags = 0 /* None */;
|
||||
@ -68241,15 +68267,11 @@ var ts;
|
||||
checkExpression(node.expression);
|
||||
return undefinedWideningType;
|
||||
}
|
||||
function isInTopLevelContext(node) {
|
||||
var container = ts.getThisContainer(node, /*includeArrowFunctions*/ true);
|
||||
return ts.isSourceFile(container);
|
||||
}
|
||||
function checkAwaitExpression(node) {
|
||||
// Grammar checking
|
||||
if (produceDiagnostics) {
|
||||
if (!(node.flags & 32768 /* AwaitContext */)) {
|
||||
if (isInTopLevelContext(node)) {
|
||||
if (ts.isInTopLevelContext(node)) {
|
||||
var sourceFile = ts.getSourceFileOfNode(node);
|
||||
if (!hasParseDiagnostics(sourceFile)) {
|
||||
var span = void 0;
|
||||
@ -73412,7 +73434,7 @@ var ts;
|
||||
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
|
||||
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
|
||||
var issuedMemberError = false;
|
||||
var _loop_21 = function (member) {
|
||||
var _loop_22 = function (member) {
|
||||
if (ts.hasStaticModifier(member)) {
|
||||
return "continue";
|
||||
}
|
||||
@ -73431,7 +73453,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
||||
var member = _a[_i];
|
||||
_loop_21(member);
|
||||
_loop_22(member);
|
||||
}
|
||||
if (!issuedMemberError) {
|
||||
// check again with diagnostics to generate a less-specific error
|
||||
@ -74204,7 +74226,6 @@ var ts;
|
||||
}
|
||||
}
|
||||
function checkImportBinding(node) {
|
||||
checkGrammarAwaitIdentifier(node.name);
|
||||
checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
|
||||
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
|
||||
checkAliasSymbol(node);
|
||||
@ -75375,10 +75396,10 @@ var ts;
|
||||
// If this is from nested object binding pattern
|
||||
// for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) {
|
||||
if (expr.parent.kind === 285 /* PropertyAssignment */) {
|
||||
var node_1 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
|
||||
var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_1) || errorType;
|
||||
var propertyIndex = ts.indexOfNode(node_1.properties, expr.parent);
|
||||
return checkObjectLiteralDestructuringPropertyAssignment(node_1, typeOfParentObjectLiteral, propertyIndex);
|
||||
var node_2 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
|
||||
var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_2) || errorType;
|
||||
var propertyIndex = ts.indexOfNode(node_2.properties, expr.parent);
|
||||
return checkObjectLiteralDestructuringPropertyAssignment(node_2, typeOfParentObjectLiteral, propertyIndex);
|
||||
}
|
||||
// Array literal assignment - array destructuring pattern
|
||||
var node = ts.cast(expr.parent, ts.isArrayLiteralExpression);
|
||||
@ -76735,29 +76756,18 @@ var ts;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function checkGrammarAwaitIdentifier(name) {
|
||||
if (name && ts.isIdentifier(name) && name.originalKeywordKind === 130 /* AwaitKeyword */ && isInTopLevelContext(name.parent)) {
|
||||
var file = ts.getSourceFileOfNode(name);
|
||||
if (!file.isDeclarationFile && ts.isExternalModule(file)) {
|
||||
return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.idText(name));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function checkGrammarFunctionLikeDeclaration(node) {
|
||||
// Prevent cascading error by short-circuit
|
||||
var file = ts.getSourceFileOfNode(node);
|
||||
return checkGrammarDecoratorsAndModifiers(node) ||
|
||||
checkGrammarTypeParameterList(node.typeParameters, file) ||
|
||||
(ts.isFunctionDeclaration(node) && checkGrammarAwaitIdentifier(node.name)) ||
|
||||
checkGrammarParameterList(node.parameters) ||
|
||||
checkGrammarArrowFunction(node, file) ||
|
||||
(ts.isFunctionLikeDeclaration(node) && checkGrammarForUseStrictSimpleParameterList(node));
|
||||
}
|
||||
function checkGrammarClassLikeDeclaration(node) {
|
||||
var file = ts.getSourceFileOfNode(node);
|
||||
return (ts.isClassDeclaration(node) && checkGrammarAwaitIdentifier(node.name)) ||
|
||||
checkGrammarClassDeclarationHeritageClauses(node) ||
|
||||
return checkGrammarClassDeclarationHeritageClauses(node) ||
|
||||
checkGrammarTypeParameterList(node.typeParameters, file);
|
||||
}
|
||||
function checkGrammarArrowFunction(node, file) {
|
||||
@ -77327,9 +77337,6 @@ var ts;
|
||||
return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_have_a_property_name);
|
||||
}
|
||||
}
|
||||
if (ts.isIdentifier(node.name) && checkGrammarAwaitIdentifier(node.name)) {
|
||||
return true;
|
||||
}
|
||||
if (node.dotDotDotToken && node.initializer) {
|
||||
// Error on equals token which immediately precedes the initializer
|
||||
return grammarErrorAtPos(node, node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer);
|
||||
@ -77386,9 +77393,6 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ts.isIdentifier(node.name) && checkGrammarAwaitIdentifier(node.name)) {
|
||||
return true;
|
||||
}
|
||||
if (node.exclamationToken && (node.parent.parent.kind !== 229 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) {
|
||||
return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation);
|
||||
}
|
||||
@ -107351,7 +107355,7 @@ var ts;
|
||||
});
|
||||
// Sort by paths closest to importing file Name directory
|
||||
var sortedPaths = [];
|
||||
var _loop_22 = function (directory) {
|
||||
var _loop_23 = function (directory) {
|
||||
var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
|
||||
var pathsInDirectory;
|
||||
allFileNames.forEach(function (canonicalFileName, fileName) {
|
||||
@ -107377,7 +107381,7 @@ var ts;
|
||||
};
|
||||
var out_directory_1;
|
||||
for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) {
|
||||
var state_8 = _loop_22(directory);
|
||||
var state_8 = _loop_23(directory);
|
||||
directory = out_directory_1;
|
||||
if (state_8 === "break")
|
||||
break;
|
||||
|
||||
@ -13972,6 +13972,15 @@ var ts;
|
||||
}
|
||||
}
|
||||
ts.getThisContainer = getThisContainer;
|
||||
function isInTopLevelContext(node) {
|
||||
// The name of a class or function declaration is a BindingIdentifier in its surrounding scope.
|
||||
if (ts.isIdentifier(node) && (ts.isClassDeclaration(node.parent) || ts.isFunctionDeclaration(node.parent)) && node.parent.name === node) {
|
||||
node = node.parent;
|
||||
}
|
||||
var container = getThisContainer(node, /*includeArrowFunctions*/ true);
|
||||
return ts.isSourceFile(container);
|
||||
}
|
||||
ts.isInTopLevelContext = isInTopLevelContext;
|
||||
function getNewTargetContainer(node) {
|
||||
var container = getThisContainer(node, /*includeArrowFunctions*/ false);
|
||||
if (container) {
|
||||
@ -15169,13 +15178,7 @@ var ts;
|
||||
return parent.name === node;
|
||||
case 156 /* QualifiedName */:
|
||||
// Name on right hand side of dot in a type query or type reference
|
||||
if (parent.right === node) {
|
||||
while (parent.kind === 156 /* QualifiedName */) {
|
||||
parent = parent.parent;
|
||||
}
|
||||
return parent.kind === 175 /* TypeQuery */ || parent.kind === 172 /* TypeReference */;
|
||||
}
|
||||
return false;
|
||||
return parent.right === node;
|
||||
case 195 /* BindingElement */:
|
||||
case 262 /* ImportSpecifier */:
|
||||
// Property name in binding element or import specifier
|
||||
@ -27532,31 +27535,6 @@ var ts;
|
||||
createBaseNode: function (kind) { return countNode(new NodeConstructor(kind, /*pos*/ 0, /*end*/ 0)); }
|
||||
};
|
||||
var factory = ts.createNodeFactory(1 /* NoParenthesizerRules */ | 2 /* NoNodeConverters */ | 8 /* NoOriginalNode */, baseNodeFactory);
|
||||
var reparseContext = {
|
||||
get factory() { return factory; },
|
||||
enableEmitNotification: ts.notImplemented,
|
||||
enableSubstitution: ts.notImplemented,
|
||||
endLexicalEnvironment: ts.returnUndefined,
|
||||
getCompilerOptions: ts.notImplemented,
|
||||
getEmitHost: ts.notImplemented,
|
||||
getEmitResolver: ts.notImplemented,
|
||||
getEmitHelperFactory: ts.notImplemented,
|
||||
setLexicalEnvironmentFlags: ts.noop,
|
||||
getLexicalEnvironmentFlags: function () { return 0; },
|
||||
hoistFunctionDeclaration: ts.notImplemented,
|
||||
hoistVariableDeclaration: ts.notImplemented,
|
||||
addInitializationStatement: ts.notImplemented,
|
||||
isEmitNotificationEnabled: ts.notImplemented,
|
||||
isSubstitutionEnabled: ts.notImplemented,
|
||||
onEmitNode: ts.notImplemented,
|
||||
onSubstituteNode: ts.notImplemented,
|
||||
readEmitHelpers: ts.notImplemented,
|
||||
requestEmitHelper: ts.notImplemented,
|
||||
resumeLexicalEnvironment: ts.noop,
|
||||
startLexicalEnvironment: ts.noop,
|
||||
suspendLexicalEnvironment: ts.noop,
|
||||
addDiagnostic: ts.notImplemented,
|
||||
};
|
||||
var fileName;
|
||||
var sourceFlags;
|
||||
var sourceText;
|
||||
@ -27620,6 +27598,8 @@ var ts;
|
||||
// parsing. These context flags are naturally stored and restored through normal recursive
|
||||
// descent parsing and unwinding.
|
||||
var contextFlags;
|
||||
// Indicates whether we are currently parsing top-level statements.
|
||||
var topLevel = true;
|
||||
// Whether or not we've had a parse error since creating the last AST node. If we have
|
||||
// encountered an error, it will be stored on the next AST node we create. Parse errors
|
||||
// can be broken down into three categories:
|
||||
@ -27763,6 +27743,7 @@ var ts;
|
||||
identifierCount = 0;
|
||||
nodeCount = 0;
|
||||
sourceFlags = 0;
|
||||
topLevel = true;
|
||||
switch (scriptKind) {
|
||||
case 1 /* JS */:
|
||||
case 2 /* JSX */:
|
||||
@ -27799,6 +27780,7 @@ var ts;
|
||||
parsingContext = 0;
|
||||
identifiers = undefined;
|
||||
notParenthesizedArrow = undefined;
|
||||
topLevel = true;
|
||||
}
|
||||
function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind) {
|
||||
var isDeclarationFile = isDeclarationFileName(fileName);
|
||||
@ -27847,108 +27829,98 @@ var ts;
|
||||
return node;
|
||||
}
|
||||
function reparseTopLevelAwait(sourceFile) {
|
||||
return ts.visitEachChild(sourceFile, visitor, reparseContext);
|
||||
function visitor(node) {
|
||||
if (!(node.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */)) {
|
||||
return node;
|
||||
var savedSyntaxCursor = syntaxCursor;
|
||||
var baseSyntaxCursor = IncrementalParser.createSyntaxCursor(sourceFile);
|
||||
syntaxCursor = { currentNode: currentNode };
|
||||
var statements = [];
|
||||
var savedParseDiagnostics = parseDiagnostics;
|
||||
parseDiagnostics = [];
|
||||
var pos = 0;
|
||||
var start = findNextStatementWithAwait(sourceFile.statements, 0);
|
||||
var _loop_3 = function () {
|
||||
// append all statements between pos and start
|
||||
var prevStatement = sourceFile.statements[pos];
|
||||
var nextStatement = sourceFile.statements[start];
|
||||
ts.addRange(statements, sourceFile.statements, pos, start);
|
||||
pos = findNextStatementWithoutAwait(sourceFile.statements, start);
|
||||
// append all diagnostics associated with the copied range
|
||||
var diagnosticStart = ts.findIndex(savedParseDiagnostics, function (diagnostic) { return diagnostic.start >= prevStatement.pos; });
|
||||
var diagnosticEnd = diagnosticStart >= 0 ? ts.findIndex(savedParseDiagnostics, function (diagnostic) { return diagnostic.start >= nextStatement.pos; }, diagnosticStart) : -1;
|
||||
if (diagnosticStart >= 0) {
|
||||
ts.addRange(parseDiagnostics, savedParseDiagnostics, diagnosticStart, diagnosticEnd >= 0 ? diagnosticEnd : undefined);
|
||||
}
|
||||
// We explicitly visit each non-Expression node that has an immediate Expression child so that
|
||||
// we can reparse the Expression in an Await context
|
||||
switch (node.kind) {
|
||||
case 160 /* Decorator */: return reparseDecorator(node);
|
||||
case 157 /* ComputedPropertyName */: return reparseComputedPropertyName(node);
|
||||
case 220 /* ExpressionWithTypeArguments */: return reparseExpressionWithTypeArguments(node);
|
||||
case 230 /* ExpressionStatement */: return reparseExpressionStatement(node);
|
||||
case 231 /* IfStatement */: return reparseIfStatement(node);
|
||||
case 241 /* SwitchStatement */: return reparseSwitchStatement(node);
|
||||
case 240 /* WithStatement */: return reparseWithStatement(node);
|
||||
case 232 /* DoStatement */: return reparseDoStatement(node);
|
||||
case 233 /* WhileStatement */: return reparseWhileStatement(node);
|
||||
case 234 /* ForStatement */: return reparseForStatement(node);
|
||||
case 235 /* ForInStatement */: return reparseForInStatement(node);
|
||||
case 236 /* ForOfStatement */: return reparseForOfStatement(node);
|
||||
case 239 /* ReturnStatement */: return reparseReturnStatement(node);
|
||||
case 243 /* ThrowStatement */: return reparseThrowStatement(node);
|
||||
case 263 /* ExportAssignment */: return reparseExportAssignment(node);
|
||||
case 246 /* VariableDeclaration */: return reparseVariableDeclaration(node);
|
||||
case 195 /* BindingElement */: return reparseBindingElement(node);
|
||||
default: return ts.visitEachChild(node, visitor, reparseContext);
|
||||
// reparse all statements between start and pos. We skip existing diagnostics for the same range and allow the parser to generate new ones.
|
||||
speculationHelper(function () {
|
||||
var savedContextFlags = contextFlags;
|
||||
contextFlags |= 32768 /* AwaitContext */;
|
||||
scanner.setTextPos(nextStatement.pos);
|
||||
nextToken();
|
||||
while (token() !== 1 /* EndOfFileToken */) {
|
||||
var startPos = scanner.getStartPos();
|
||||
var statement = parseListElement(0 /* SourceElements */, parseStatement);
|
||||
statements.push(statement);
|
||||
if (startPos === scanner.getStartPos()) {
|
||||
nextToken();
|
||||
}
|
||||
if (pos >= 0) {
|
||||
var nonAwaitStatement = sourceFile.statements[pos];
|
||||
if (statement.end === nonAwaitStatement.pos) {
|
||||
// done reparsing this section
|
||||
break;
|
||||
}
|
||||
if (statement.end > nonAwaitStatement.pos) {
|
||||
// we ate into the next statement, so we must reparse it.
|
||||
pos = findNextStatementWithoutAwait(sourceFile.statements, pos + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
contextFlags = savedContextFlags;
|
||||
}, 2 /* Reparse */);
|
||||
// find the next statement containing an `await`
|
||||
start = pos >= 0 ? findNextStatementWithAwait(sourceFile.statements, pos) : -1;
|
||||
};
|
||||
while (start !== -1) {
|
||||
_loop_3();
|
||||
}
|
||||
// append all statements between pos and the end of the list
|
||||
if (pos >= 0) {
|
||||
var prevStatement_1 = sourceFile.statements[pos];
|
||||
ts.addRange(statements, sourceFile.statements, pos);
|
||||
// append all diagnostics associated with the copied range
|
||||
var diagnosticStart = ts.findIndex(savedParseDiagnostics, function (diagnostic) { return diagnostic.start >= prevStatement_1.pos; });
|
||||
if (diagnosticStart >= 0) {
|
||||
ts.addRange(parseDiagnostics, savedParseDiagnostics, diagnosticStart);
|
||||
}
|
||||
}
|
||||
function reparse(node, parse) {
|
||||
if (node && node.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */) {
|
||||
if (ts.isExpression(node)) {
|
||||
return speculationHelper(function () {
|
||||
scanner.setTextPos(node.pos);
|
||||
var savedContextFlags = contextFlags;
|
||||
contextFlags = node.flags & 25358336 /* ContextFlags */;
|
||||
nextToken();
|
||||
var result = doInAwaitContext(parse);
|
||||
contextFlags = savedContextFlags;
|
||||
return result;
|
||||
}, 2 /* Reparse */);
|
||||
syntaxCursor = savedSyntaxCursor;
|
||||
return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements));
|
||||
function containsPossibleTopLevelAwait(node) {
|
||||
return !(node.flags & 32768 /* AwaitContext */)
|
||||
&& !!(node.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */);
|
||||
}
|
||||
function findNextStatementWithAwait(statements, start) {
|
||||
for (var i = start; i < statements.length; i++) {
|
||||
if (containsPossibleTopLevelAwait(statements[i])) {
|
||||
return i;
|
||||
}
|
||||
return ts.visitEachChild(node, visitor, reparseContext);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
function findNextStatementWithoutAwait(statements, start) {
|
||||
for (var i = start; i < statements.length; i++) {
|
||||
if (!containsPossibleTopLevelAwait(statements[i])) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
function currentNode(position) {
|
||||
var node = baseSyntaxCursor.currentNode(position);
|
||||
if (topLevel && node && containsPossibleTopLevelAwait(node)) {
|
||||
node.intersectsChange = true;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
function update(updated, original) {
|
||||
if (updated !== original) {
|
||||
ts.setNodeFlags(updated, updated.flags | 32768 /* AwaitContext */);
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
function reparseExpressionStatement(node) {
|
||||
return update(factory.updateExpressionStatement(node, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseReturnStatement(node) {
|
||||
return update(factory.updateReturnStatement(node, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseThrowStatement(node) {
|
||||
return update(factory.updateThrowStatement(node, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseIfStatement(node) {
|
||||
return update(factory.updateIfStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.thenStatement, visitor), ts.visitNode(node.elseStatement, visitor)), node);
|
||||
}
|
||||
function reparseSwitchStatement(node) {
|
||||
return update(factory.updateSwitchStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.caseBlock, visitor)), node);
|
||||
}
|
||||
function reparseWithStatement(node) {
|
||||
return update(factory.updateWithStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
|
||||
}
|
||||
function reparseDoStatement(node) {
|
||||
return update(factory.updateDoStatement(node, ts.visitNode(node.statement, visitor), reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseWhileStatement(node) {
|
||||
return update(factory.updateWhileStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
|
||||
}
|
||||
function reparseForStatement(node) {
|
||||
return update(factory.updateForStatement(node, reparse(node.initializer, parseExpression), reparse(node.condition, parseExpression), reparse(node.incrementor, parseExpression), ts.visitNode(node, visitor)), node);
|
||||
}
|
||||
function reparseForInStatement(node) {
|
||||
return update(factory.updateForInStatement(node, reparse(node.initializer, parseExpression), reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
|
||||
}
|
||||
function reparseForOfStatement(node) {
|
||||
return update(factory.updateForOfStatement(node, node.awaitModifier, reparse(node.initializer, parseExpression), reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
|
||||
}
|
||||
function reparseExportAssignment(node) {
|
||||
return update(factory.updateExportAssignment(node, ts.visitNodes(node.decorators, visitor), node.modifiers, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseExpressionWithTypeArguments(node) {
|
||||
return update(factory.updateExpressionWithTypeArguments(node, reparse(node.expression, parseLeftHandSideExpressionOrHigher), node.typeArguments), node);
|
||||
}
|
||||
function reparseDecorator(node) {
|
||||
return update(factory.updateDecorator(node, reparse(node.expression, parseLeftHandSideExpressionOrHigher)), node);
|
||||
}
|
||||
function reparseComputedPropertyName(node) {
|
||||
return update(factory.updateComputedPropertyName(node, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseVariableDeclaration(node) {
|
||||
return update(factory.updateVariableDeclaration(node, ts.visitNode(node.name, visitor), node.exclamationToken, node.type, reparse(node.initializer, parseExpression)), node);
|
||||
}
|
||||
function reparseBindingElement(node) {
|
||||
return update(factory.updateBindingElement(node, node.dotDotDotToken, ts.visitNode(node.propertyName, visitor), ts.visitNode(node.name, visitor), reparse(node.initializer, parseExpression)), node);
|
||||
}
|
||||
}
|
||||
function fixupParentReferences(rootNode) {
|
||||
// normally parent references are set during binding. However, for clients that only need
|
||||
@ -28198,6 +28170,12 @@ var ts;
|
||||
function tryParse(callback) {
|
||||
return speculationHelper(callback, 0 /* TryParse */);
|
||||
}
|
||||
function isBindingIdentifier() {
|
||||
if (token() === 78 /* Identifier */) {
|
||||
return true;
|
||||
}
|
||||
return token() > 115 /* LastReservedWord */;
|
||||
}
|
||||
// Ignore strict mode flag because we will report an error in type checker instead.
|
||||
function isIdentifier() {
|
||||
if (token() === 78 /* Identifier */) {
|
||||
@ -28367,6 +28345,9 @@ var ts;
|
||||
ts.Diagnostics.Identifier_expected;
|
||||
return createMissingNode(78 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg);
|
||||
}
|
||||
function parseBindingIdentifier(privateIdentifierDiagnosticMessage) {
|
||||
return createIdentifier(isBindingIdentifier(), /*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage);
|
||||
}
|
||||
function parseIdentifier(diagnosticMessage, privateIdentifierDiagnosticMessage) {
|
||||
return createIdentifier(isIdentifier(), diagnosticMessage, privateIdentifierDiagnosticMessage);
|
||||
}
|
||||
@ -28544,9 +28525,9 @@ var ts;
|
||||
return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword();
|
||||
}
|
||||
case 8 /* VariableDeclarations */:
|
||||
return isIdentifierOrPrivateIdentifierOrPattern();
|
||||
return isBindingIdentifierOrPrivateIdentifierOrPattern();
|
||||
case 10 /* ArrayBindingElements */:
|
||||
return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isIdentifierOrPrivateIdentifierOrPattern();
|
||||
return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern();
|
||||
case 19 /* TypeParameters */:
|
||||
return isIdentifier();
|
||||
case 15 /* ArrayLiteralMembers */:
|
||||
@ -29388,7 +29369,7 @@ var ts;
|
||||
}
|
||||
function isStartOfParameter(isJSDocParameter) {
|
||||
return token() === 25 /* DotDotDotToken */ ||
|
||||
isIdentifierOrPrivateIdentifierOrPattern() ||
|
||||
isBindingIdentifierOrPrivateIdentifierOrPattern() ||
|
||||
ts.isModifierKind(token()) ||
|
||||
token() === 59 /* AtToken */ ||
|
||||
isStartOfType(/*inStartOfParameter*/ !isJSDocParameter);
|
||||
@ -29410,22 +29391,34 @@ var ts;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
function parseParameterInOuterAwaitContext() {
|
||||
return parseParameterWorker(/*inOuterAwaitContext*/ true);
|
||||
}
|
||||
function parseParameter() {
|
||||
return parseParameterWorker(/*inOuterAwaitContext*/ false);
|
||||
}
|
||||
function parseParameterWorker(inOuterAwaitContext) {
|
||||
var pos = getNodePos();
|
||||
var hasJSDoc = hasPrecedingJSDocComment();
|
||||
if (token() === 107 /* ThisKeyword */) {
|
||||
var node = factory.createParameterDeclaration(
|
||||
var node_1 = factory.createParameterDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
/*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true),
|
||||
/*questionToken*/ undefined, parseTypeAnnotation(),
|
||||
/*initializer*/ undefined);
|
||||
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
||||
return withJSDoc(finishNode(node_1, pos), hasJSDoc);
|
||||
}
|
||||
// FormalParameter [Yield,Await]:
|
||||
// BindingElement[?Yield,?Await]
|
||||
var modifiers;
|
||||
return withJSDoc(finishNode(factory.createParameterDeclaration(parseDecorators(), modifiers = parseModifiers(), parseOptionalToken(25 /* DotDotDotToken */), parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc);
|
||||
// Decorators are parsed in the outer [Await] context, the rest of the parameter is parsed in the function's [Await] context.
|
||||
var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators();
|
||||
var savedTopLevel = topLevel;
|
||||
topLevel = false;
|
||||
var modifiers = parseModifiers();
|
||||
var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, parseOptionalToken(25 /* DotDotDotToken */), parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc);
|
||||
topLevel = savedTopLevel;
|
||||
return node;
|
||||
}
|
||||
function parseReturnType(returnToken, isType) {
|
||||
if (shouldParseReturnType(returnToken, isType)) {
|
||||
@ -29468,7 +29461,7 @@ var ts;
|
||||
setAwaitContext(!!(flags & 2 /* Await */));
|
||||
var parameters = flags & 32 /* JSDoc */ ?
|
||||
parseDelimitedList(17 /* JSDocParameters */, parseJSDocParameter) :
|
||||
parseDelimitedList(16 /* Parameters */, parseParameter);
|
||||
parseDelimitedList(16 /* Parameters */, savedAwaitContext ? parseParameterInOuterAwaitContext : parseParameter);
|
||||
setYieldContext(savedYieldContext);
|
||||
setAwaitContext(savedAwaitContext);
|
||||
return parameters;
|
||||
@ -30597,9 +30590,13 @@ var ts;
|
||||
// Note: even when 'IgnoreMissingOpenBrace' is passed, parseBody will still error.
|
||||
return parseFunctionBlock(16 /* IgnoreMissingOpenBrace */ | (isAsync ? 2 /* Await */ : 0 /* None */));
|
||||
}
|
||||
return isAsync
|
||||
var savedTopLevel = topLevel;
|
||||
topLevel = false;
|
||||
var node = isAsync
|
||||
? doInAwaitContext(parseAssignmentExpressionOrHigher)
|
||||
: doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
|
||||
topLevel = savedTopLevel;
|
||||
return node;
|
||||
}
|
||||
function parseConditionalExpressionRest(leftOperand, pos) {
|
||||
// Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher.
|
||||
@ -31590,10 +31587,10 @@ var ts;
|
||||
var asteriskToken = parseOptionalToken(41 /* AsteriskToken */);
|
||||
var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */;
|
||||
var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */;
|
||||
var name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) :
|
||||
isGenerator ? doInYieldContext(parseOptionalIdentifier) :
|
||||
isAsync ? doInAwaitContext(parseOptionalIdentifier) :
|
||||
parseOptionalIdentifier();
|
||||
var name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalBindingIdentifier) :
|
||||
isGenerator ? doInYieldContext(parseOptionalBindingIdentifier) :
|
||||
isAsync ? doInAwaitContext(parseOptionalBindingIdentifier) :
|
||||
parseOptionalBindingIdentifier();
|
||||
var typeParameters = parseTypeParameters();
|
||||
var parameters = parseParameters(isGenerator | isAsync);
|
||||
var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
|
||||
@ -31604,8 +31601,8 @@ var ts;
|
||||
var node = factory.createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body);
|
||||
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
||||
}
|
||||
function parseOptionalIdentifier() {
|
||||
return isIdentifier() ? parseIdentifier() : undefined;
|
||||
function parseOptionalBindingIdentifier() {
|
||||
return isBindingIdentifier() ? parseBindingIdentifier() : undefined;
|
||||
}
|
||||
function parseNewExpressionOrNewDotTarget() {
|
||||
var pos = getNodePos();
|
||||
@ -31661,6 +31658,8 @@ var ts;
|
||||
setYieldContext(!!(flags & 1 /* Yield */));
|
||||
var savedAwaitContext = inAwaitContext();
|
||||
setAwaitContext(!!(flags & 2 /* Await */));
|
||||
var savedTopLevel = topLevel;
|
||||
topLevel = false;
|
||||
// We may be in a [Decorator] context when parsing a function expression or
|
||||
// arrow function. The body of the function is not in [Decorator] context.
|
||||
var saveDecoratorContext = inDecoratorContext();
|
||||
@ -31671,6 +31670,7 @@ var ts;
|
||||
if (saveDecoratorContext) {
|
||||
setDecoratorContext(/*val*/ true);
|
||||
}
|
||||
topLevel = savedTopLevel;
|
||||
setYieldContext(savedYieldContext);
|
||||
setAwaitContext(savedAwaitContext);
|
||||
return block;
|
||||
@ -32229,7 +32229,7 @@ var ts;
|
||||
function parseObjectBindingElement() {
|
||||
var pos = getNodePos();
|
||||
var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */);
|
||||
var tokenIsIdentifier = isIdentifier();
|
||||
var tokenIsIdentifier = isBindingIdentifier();
|
||||
var propertyName = parsePropertyName();
|
||||
var name;
|
||||
if (tokenIsIdentifier && token() !== 58 /* ColonToken */) {
|
||||
@ -32257,11 +32257,11 @@ var ts;
|
||||
parseExpected(23 /* CloseBracketToken */);
|
||||
return finishNode(factory.createArrayBindingPattern(elements), pos);
|
||||
}
|
||||
function isIdentifierOrPrivateIdentifierOrPattern() {
|
||||
function isBindingIdentifierOrPrivateIdentifierOrPattern() {
|
||||
return token() === 18 /* OpenBraceToken */
|
||||
|| token() === 22 /* OpenBracketToken */
|
||||
|| token() === 79 /* PrivateIdentifier */
|
||||
|| isIdentifier();
|
||||
|| isBindingIdentifier();
|
||||
}
|
||||
function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) {
|
||||
if (token() === 22 /* OpenBracketToken */) {
|
||||
@ -32270,7 +32270,7 @@ var ts;
|
||||
if (token() === 18 /* OpenBraceToken */) {
|
||||
return parseObjectBindingPattern();
|
||||
}
|
||||
return parseIdentifier(/*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage);
|
||||
return parseBindingIdentifier(privateIdentifierDiagnosticMessage);
|
||||
}
|
||||
function parseVariableDeclarationAllowExclamation() {
|
||||
return parseVariableDeclaration(/*allowExclamation*/ true);
|
||||
@ -32342,7 +32342,7 @@ var ts;
|
||||
parseExpected(97 /* FunctionKeyword */);
|
||||
var asteriskToken = parseOptionalToken(41 /* AsteriskToken */);
|
||||
// We don't parse the name here in await context, instead we will report a grammar error in the checker.
|
||||
var name = modifierFlags & 512 /* Default */ ? parseOptionalIdentifier() : parseIdentifier();
|
||||
var name = modifierFlags & 512 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier();
|
||||
var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */;
|
||||
var isAsync = modifierFlags & 256 /* Async */ ? 2 /* Await */ : 0 /* None */;
|
||||
var typeParameters = parseTypeParameters();
|
||||
@ -32486,12 +32486,24 @@ var ts;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function parseDecoratorExpression() {
|
||||
if (inAwaitContext() && token() === 130 /* AwaitKeyword */) {
|
||||
// `@await` is is disallowed in an [Await] context, but can cause parsing to go off the rails
|
||||
// This simply parses the missing identifier and moves on.
|
||||
var pos = getNodePos();
|
||||
var awaitExpression = parseIdentifier(ts.Diagnostics.Expression_expected);
|
||||
nextToken();
|
||||
var memberExpression = parseMemberExpressionRest(pos, awaitExpression, /*allowOptionalChain*/ true);
|
||||
return parseCallExpressionRest(pos, memberExpression);
|
||||
}
|
||||
return parseLeftHandSideExpressionOrHigher();
|
||||
}
|
||||
function tryParseDecorator() {
|
||||
var pos = getNodePos();
|
||||
if (!parseOptional(59 /* AtToken */)) {
|
||||
return undefined;
|
||||
}
|
||||
var expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher);
|
||||
var expression = doInDecoratorContext(parseDecoratorExpression);
|
||||
return finishNode(factory.createDecorator(expression), pos);
|
||||
}
|
||||
function parseDecorators() {
|
||||
@ -32632,8 +32644,8 @@ var ts;
|
||||
// - class expression with omitted name, 'implements' starts heritage clause
|
||||
// - class with name 'implements'
|
||||
// 'isImplementsClause' helps to disambiguate between these two cases
|
||||
return isIdentifier() && !isImplementsClause()
|
||||
? parseIdentifier()
|
||||
return isBindingIdentifier() && !isImplementsClause()
|
||||
? createIdentifier(isBindingIdentifier())
|
||||
: undefined;
|
||||
}
|
||||
function isImplementsClause() {
|
||||
@ -34429,6 +34441,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
IncrementalParser.createSyntaxCursor = createSyntaxCursor;
|
||||
var InvalidPosition;
|
||||
(function (InvalidPosition) {
|
||||
InvalidPosition[InvalidPosition["Value"] = -1] = "Value";
|
||||
@ -36215,7 +36228,7 @@ var ts;
|
||||
}
|
||||
function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) {
|
||||
var result = returnValue ? {} : undefined;
|
||||
var _loop_3 = function (element) {
|
||||
var _loop_4 = function (element) {
|
||||
if (element.kind !== 285 /* PropertyAssignment */) {
|
||||
errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected));
|
||||
return "continue";
|
||||
@ -36268,7 +36281,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
|
||||
var element = _a[_i];
|
||||
_loop_3(element);
|
||||
_loop_4(element);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -36451,7 +36464,7 @@ var ts;
|
||||
var optionsNameMap = _a.optionsNameMap;
|
||||
var result = ts.createMap();
|
||||
var getCanonicalFileName = pathOptions && ts.createGetCanonicalFileName(pathOptions.useCaseSensitiveFileNames);
|
||||
var _loop_4 = function (name) {
|
||||
var _loop_5 = function (name) {
|
||||
if (ts.hasProperty(options, name)) {
|
||||
// tsconfig only options cannot be specified via command line,
|
||||
// so we can assume that only types that can appear here string | number | boolean
|
||||
@ -36485,7 +36498,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var name in options) {
|
||||
_loop_4(name);
|
||||
_loop_5(name);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -37246,7 +37259,7 @@ var ts;
|
||||
}
|
||||
var jsonOnlyIncludeRegexes;
|
||||
if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) {
|
||||
var _loop_5 = function (file) {
|
||||
var _loop_6 = function (file) {
|
||||
if (ts.fileExtensionIs(file, ".json" /* Json */)) {
|
||||
// Valid only if *.json specified
|
||||
if (!jsonOnlyIncludeRegexes) {
|
||||
@ -37284,7 +37297,7 @@ var ts;
|
||||
};
|
||||
for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensionsWithJsonIfResolveJsonModule, validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined); _a < _b.length; _a++) {
|
||||
var file = _b[_a];
|
||||
_loop_5(file);
|
||||
_loop_6(file);
|
||||
}
|
||||
}
|
||||
var literalFiles = ts.arrayFrom(literalFileMap.values());
|
||||
@ -40691,18 +40704,31 @@ var ts;
|
||||
currentFlow = saveCurrentFlow;
|
||||
}
|
||||
// The binder visits every node in the syntax tree so it is a convenient place to perform a single localized
|
||||
// check for reserved words used as identifiers in strict mode code.
|
||||
function checkStrictModeIdentifier(node) {
|
||||
if (inStrictMode &&
|
||||
node.originalKeywordKind >= 116 /* FirstFutureReservedWord */ &&
|
||||
node.originalKeywordKind <= 124 /* LastFutureReservedWord */ &&
|
||||
!ts.isIdentifierName(node) &&
|
||||
// check for reserved words used as identifiers in strict mode code, as well as `yield` or `await` in
|
||||
// [Yield] or [Await] contexts, respectively.
|
||||
function checkContextualIdentifier(node) {
|
||||
// Report error only if there are no parse errors in file
|
||||
if (!file.parseDiagnostics.length &&
|
||||
!(node.flags & 8388608 /* Ambient */) &&
|
||||
!(node.flags & 4194304 /* JSDoc */)) {
|
||||
// Report error only if there are no parse errors in file
|
||||
if (!file.parseDiagnostics.length) {
|
||||
!(node.flags & 4194304 /* JSDoc */) &&
|
||||
!ts.isIdentifierName(node)) {
|
||||
// strict mode identifiers
|
||||
if (inStrictMode &&
|
||||
node.originalKeywordKind >= 116 /* FirstFutureReservedWord */ &&
|
||||
node.originalKeywordKind <= 124 /* LastFutureReservedWord */) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node)));
|
||||
}
|
||||
else if (node.originalKeywordKind === 130 /* AwaitKeyword */) {
|
||||
if (ts.isExternalModule(file) && ts.isInTopLevelContext(node)) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.declarationNameToString(node)));
|
||||
}
|
||||
else if (node.flags & 32768 /* AwaitContext */) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node)));
|
||||
}
|
||||
}
|
||||
else if (node.originalKeywordKind === 124 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node)));
|
||||
}
|
||||
}
|
||||
}
|
||||
function getStrictModeIdentifierMessage(node) {
|
||||
@ -40969,7 +40995,7 @@ var ts;
|
||||
if (currentFlow && (ts.isExpression(node) || parent.kind === 286 /* ShorthandPropertyAssignment */)) {
|
||||
node.flowNode = currentFlow;
|
||||
}
|
||||
return checkStrictModeIdentifier(node);
|
||||
return checkContextualIdentifier(node);
|
||||
case 105 /* SuperKeyword */:
|
||||
node.flowNode = currentFlow;
|
||||
break;
|
||||
@ -43165,7 +43191,7 @@ var ts;
|
||||
function addDuplicateDeclarationError(node, message, symbolName, relatedNodes) {
|
||||
var errorNode = (ts.getExpandoInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getNameOfExpando(node) : ts.getNameOfDeclaration(node)) || node;
|
||||
var err = lookupOrIssueError(errorNode, message, symbolName);
|
||||
var _loop_6 = function (relatedNode) {
|
||||
var _loop_7 = function (relatedNode) {
|
||||
var adjustedNode = (ts.getExpandoInitializer(relatedNode, /*isPrototypeAssignment*/ false) ? ts.getNameOfExpando(relatedNode) : ts.getNameOfDeclaration(relatedNode)) || relatedNode;
|
||||
if (adjustedNode === errorNode)
|
||||
return "continue";
|
||||
@ -43178,7 +43204,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, _a = relatedNodes || ts.emptyArray; _i < _a.length; _i++) {
|
||||
var relatedNode = _a[_i];
|
||||
_loop_6(relatedNode);
|
||||
_loop_7(relatedNode);
|
||||
}
|
||||
}
|
||||
function combineSymbolTables(first, second) {
|
||||
@ -45419,7 +45445,7 @@ var ts;
|
||||
}
|
||||
function forEachSymbolTableInScope(enclosingDeclaration, callback) {
|
||||
var result;
|
||||
var _loop_7 = function (location) {
|
||||
var _loop_8 = function (location) {
|
||||
// Locals of a source file are not in scope (because they get merged into the global symbol table)
|
||||
if (location.locals && !isGlobalSourceFile(location)) {
|
||||
if (result = callback(location.locals)) {
|
||||
@ -45465,7 +45491,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var location = enclosingDeclaration; location; location = location.parent) {
|
||||
var state_2 = _loop_7(location);
|
||||
var state_2 = _loop_8(location);
|
||||
if (typeof state_2 === "object")
|
||||
return state_2.value;
|
||||
}
|
||||
@ -47475,7 +47501,7 @@ var ts;
|
||||
if (ts.length(reexports) > 1) {
|
||||
var groups = ts.group(reexports, function (decl) { return ts.isStringLiteral(decl.moduleSpecifier) ? ">" + decl.moduleSpecifier.text : ">"; });
|
||||
if (groups.length !== reexports.length) {
|
||||
var _loop_8 = function (group_1) {
|
||||
var _loop_9 = function (group_1) {
|
||||
if (group_1.length > 1) {
|
||||
// remove group members from statements and then merge group members and add back to statements
|
||||
statements = __spreadArrays(ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), [
|
||||
@ -47488,7 +47514,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) {
|
||||
var group_1 = groups_1[_i];
|
||||
_loop_8(group_1);
|
||||
_loop_9(group_1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -51000,7 +51026,7 @@ var ts;
|
||||
// signatures from the type, whose ordering would be non-obvious)
|
||||
var masterList = signatureLists[indexWithLengthOverOne !== undefined ? indexWithLengthOverOne : 0];
|
||||
var results = masterList.slice();
|
||||
var _loop_9 = function (signatures) {
|
||||
var _loop_10 = function (signatures) {
|
||||
if (signatures !== masterList) {
|
||||
var signature_1 = signatures[0];
|
||||
ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass");
|
||||
@ -51012,7 +51038,7 @@ var ts;
|
||||
};
|
||||
for (var _b = 0, signatureLists_1 = signatureLists; _b < signatureLists_1.length; _b++) {
|
||||
var signatures = signatureLists_1[_b];
|
||||
var state_3 = _loop_9(signatures);
|
||||
var state_3 = _loop_10(signatures);
|
||||
if (state_3 === "break")
|
||||
break;
|
||||
}
|
||||
@ -51136,7 +51162,7 @@ var ts;
|
||||
var types = type.types;
|
||||
var mixinFlags = findMixins(types);
|
||||
var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; });
|
||||
var _loop_10 = function (i) {
|
||||
var _loop_11 = function (i) {
|
||||
var t = type.types[i];
|
||||
// When an intersection type contains mixin constructor types, the construct signatures from
|
||||
// those types are discarded and their return types are mixed into the return types of all
|
||||
@ -51159,19 +51185,19 @@ var ts;
|
||||
numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1 /* Number */));
|
||||
};
|
||||
for (var i = 0; i < types.length; i++) {
|
||||
_loop_10(i);
|
||||
_loop_11(i);
|
||||
}
|
||||
setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo);
|
||||
}
|
||||
function appendSignatures(signatures, newSignatures) {
|
||||
var _loop_11 = function (sig) {
|
||||
var _loop_12 = function (sig) {
|
||||
if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, compareTypesIdentical); })) {
|
||||
signatures = ts.append(signatures, sig);
|
||||
}
|
||||
};
|
||||
for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) {
|
||||
var sig = newSignatures_1[_i];
|
||||
_loop_11(sig);
|
||||
_loop_12(sig);
|
||||
}
|
||||
return signatures;
|
||||
}
|
||||
@ -53458,7 +53484,7 @@ var ts;
|
||||
var expandedDeclarations = [];
|
||||
var optionalIndex = -1;
|
||||
var restTypes;
|
||||
var _loop_12 = function (i) {
|
||||
var _loop_13 = function (i) {
|
||||
var type = elementTypes[i];
|
||||
var flags = target.elementFlags[i];
|
||||
if (flags & 8 /* Variadic */) {
|
||||
@ -53481,7 +53507,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var i = 0; i < elementTypes.length; i++) {
|
||||
_loop_12(i);
|
||||
_loop_13(i);
|
||||
}
|
||||
if (restTypes) {
|
||||
// Create a union of the collected rest element types.
|
||||
@ -54531,7 +54557,7 @@ var ts;
|
||||
function getConditionalType(root, mapper) {
|
||||
var result;
|
||||
var extraTypes;
|
||||
var _loop_13 = function () {
|
||||
var _loop_14 = function () {
|
||||
var checkType = instantiateType(root.checkType, mapper);
|
||||
var checkTypeInstantiable = isGenericObjectType(checkType) || isGenericIndexType(checkType);
|
||||
var extendsType = instantiateType(root.extendsType, mapper);
|
||||
@ -54605,7 +54631,7 @@ var ts;
|
||||
// types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
|
||||
// purposes of resolution. This means such types aren't subject to the instatiation depth limiter.
|
||||
while (true) {
|
||||
var state_4 = _loop_13();
|
||||
var state_4 = _loop_14();
|
||||
if (typeof state_4 === "object")
|
||||
return state_4.value;
|
||||
if (state_4 === "break")
|
||||
@ -57083,7 +57109,7 @@ var ts;
|
||||
reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
|
||||
checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget];
|
||||
}
|
||||
var _loop_14 = function (prop) {
|
||||
var _loop_15 = function (prop) {
|
||||
if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
|
||||
if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
|
||||
if (reportErrors) {
|
||||
@ -57146,7 +57172,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) {
|
||||
var prop = _a[_i];
|
||||
var state_5 = _loop_14(prop);
|
||||
var state_5 = _loop_15(prop);
|
||||
if (typeof state_5 === "object")
|
||||
return state_5.value;
|
||||
}
|
||||
@ -57819,11 +57845,11 @@ var ts;
|
||||
// constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
|
||||
var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
|
||||
var matchingTypes = [];
|
||||
var _loop_15 = function (combination) {
|
||||
var _loop_16 = function (combination) {
|
||||
var hasMatch = false;
|
||||
outer: for (var _i = 0, _a = target.types; _i < _a.length; _i++) {
|
||||
var type = _a[_i];
|
||||
var _loop_16 = function (i) {
|
||||
var _loop_17 = function (i) {
|
||||
var sourceProperty = sourcePropertiesFiltered[i];
|
||||
var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
|
||||
if (!targetProperty)
|
||||
@ -57839,7 +57865,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
|
||||
var state_7 = _loop_16(i);
|
||||
var state_7 = _loop_17(i);
|
||||
switch (state_7) {
|
||||
case "continue-outer": continue outer;
|
||||
}
|
||||
@ -57853,7 +57879,7 @@ var ts;
|
||||
};
|
||||
for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
|
||||
var combination = discriminantCombinations_1[_a];
|
||||
var state_6 = _loop_15(combination);
|
||||
var state_6 = _loop_16(combination);
|
||||
if (typeof state_6 === "object")
|
||||
return state_6.value;
|
||||
}
|
||||
@ -58495,7 +58521,7 @@ var ts;
|
||||
// The emptyArray singleton is used to signal a recursive invocation.
|
||||
cache.variances = ts.emptyArray;
|
||||
variances = [];
|
||||
var _loop_17 = function (tp) {
|
||||
var _loop_18 = function (tp) {
|
||||
var unmeasurable = false;
|
||||
var unreliable = false;
|
||||
var oldHandler = outofbandVarianceMarkerHandler;
|
||||
@ -58527,7 +58553,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) {
|
||||
var tp = typeParameters_1[_i];
|
||||
_loop_17(tp);
|
||||
_loop_18(tp);
|
||||
}
|
||||
cache.variances = variances;
|
||||
}
|
||||
@ -66010,7 +66036,7 @@ var ts;
|
||||
if (spreadIndex >= 0) {
|
||||
// Create synthetic arguments from spreads of tuple types.
|
||||
var effectiveArgs_1 = args.slice(0, spreadIndex);
|
||||
var _loop_18 = function (i) {
|
||||
var _loop_19 = function (i) {
|
||||
var arg = args[i];
|
||||
// We can call checkExpressionCached because spread expressions never have a contextual type.
|
||||
var spreadType = arg.kind === 217 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
|
||||
@ -66027,7 +66053,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var i = spreadIndex; i < args.length; i++) {
|
||||
_loop_18(i);
|
||||
_loop_19(i);
|
||||
}
|
||||
return effectiveArgs_1;
|
||||
}
|
||||
@ -66329,7 +66355,7 @@ var ts;
|
||||
var min_3 = Number.MAX_VALUE;
|
||||
var minIndex = 0;
|
||||
var i_1 = 0;
|
||||
var _loop_19 = function (c) {
|
||||
var _loop_20 = function (c) {
|
||||
var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
|
||||
var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2);
|
||||
if (diags_2) {
|
||||
@ -66347,7 +66373,7 @@ var ts;
|
||||
};
|
||||
for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
|
||||
var c = candidatesForArgumentError_1[_a];
|
||||
_loop_19(c);
|
||||
_loop_20(c);
|
||||
}
|
||||
var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
|
||||
ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
|
||||
@ -66481,7 +66507,7 @@ var ts;
|
||||
}
|
||||
var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
|
||||
var parameters = [];
|
||||
var _loop_20 = function (i) {
|
||||
var _loop_21 = function (i) {
|
||||
var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
|
||||
i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
|
||||
i < s.parameters.length ? s.parameters[i] : undefined; });
|
||||
@ -66489,7 +66515,7 @@ var ts;
|
||||
parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
|
||||
};
|
||||
for (var i = 0; i < maxNonRestParam; i++) {
|
||||
_loop_20(i);
|
||||
_loop_21(i);
|
||||
}
|
||||
var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
|
||||
var flags = 0 /* None */;
|
||||
@ -68241,15 +68267,11 @@ var ts;
|
||||
checkExpression(node.expression);
|
||||
return undefinedWideningType;
|
||||
}
|
||||
function isInTopLevelContext(node) {
|
||||
var container = ts.getThisContainer(node, /*includeArrowFunctions*/ true);
|
||||
return ts.isSourceFile(container);
|
||||
}
|
||||
function checkAwaitExpression(node) {
|
||||
// Grammar checking
|
||||
if (produceDiagnostics) {
|
||||
if (!(node.flags & 32768 /* AwaitContext */)) {
|
||||
if (isInTopLevelContext(node)) {
|
||||
if (ts.isInTopLevelContext(node)) {
|
||||
var sourceFile = ts.getSourceFileOfNode(node);
|
||||
if (!hasParseDiagnostics(sourceFile)) {
|
||||
var span = void 0;
|
||||
@ -73412,7 +73434,7 @@ var ts;
|
||||
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
|
||||
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
|
||||
var issuedMemberError = false;
|
||||
var _loop_21 = function (member) {
|
||||
var _loop_22 = function (member) {
|
||||
if (ts.hasStaticModifier(member)) {
|
||||
return "continue";
|
||||
}
|
||||
@ -73431,7 +73453,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
||||
var member = _a[_i];
|
||||
_loop_21(member);
|
||||
_loop_22(member);
|
||||
}
|
||||
if (!issuedMemberError) {
|
||||
// check again with diagnostics to generate a less-specific error
|
||||
@ -74204,7 +74226,6 @@ var ts;
|
||||
}
|
||||
}
|
||||
function checkImportBinding(node) {
|
||||
checkGrammarAwaitIdentifier(node.name);
|
||||
checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
|
||||
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
|
||||
checkAliasSymbol(node);
|
||||
@ -75375,10 +75396,10 @@ var ts;
|
||||
// If this is from nested object binding pattern
|
||||
// for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) {
|
||||
if (expr.parent.kind === 285 /* PropertyAssignment */) {
|
||||
var node_1 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
|
||||
var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_1) || errorType;
|
||||
var propertyIndex = ts.indexOfNode(node_1.properties, expr.parent);
|
||||
return checkObjectLiteralDestructuringPropertyAssignment(node_1, typeOfParentObjectLiteral, propertyIndex);
|
||||
var node_2 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
|
||||
var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_2) || errorType;
|
||||
var propertyIndex = ts.indexOfNode(node_2.properties, expr.parent);
|
||||
return checkObjectLiteralDestructuringPropertyAssignment(node_2, typeOfParentObjectLiteral, propertyIndex);
|
||||
}
|
||||
// Array literal assignment - array destructuring pattern
|
||||
var node = ts.cast(expr.parent, ts.isArrayLiteralExpression);
|
||||
@ -76735,29 +76756,18 @@ var ts;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function checkGrammarAwaitIdentifier(name) {
|
||||
if (name && ts.isIdentifier(name) && name.originalKeywordKind === 130 /* AwaitKeyword */ && isInTopLevelContext(name.parent)) {
|
||||
var file = ts.getSourceFileOfNode(name);
|
||||
if (!file.isDeclarationFile && ts.isExternalModule(file)) {
|
||||
return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.idText(name));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function checkGrammarFunctionLikeDeclaration(node) {
|
||||
// Prevent cascading error by short-circuit
|
||||
var file = ts.getSourceFileOfNode(node);
|
||||
return checkGrammarDecoratorsAndModifiers(node) ||
|
||||
checkGrammarTypeParameterList(node.typeParameters, file) ||
|
||||
(ts.isFunctionDeclaration(node) && checkGrammarAwaitIdentifier(node.name)) ||
|
||||
checkGrammarParameterList(node.parameters) ||
|
||||
checkGrammarArrowFunction(node, file) ||
|
||||
(ts.isFunctionLikeDeclaration(node) && checkGrammarForUseStrictSimpleParameterList(node));
|
||||
}
|
||||
function checkGrammarClassLikeDeclaration(node) {
|
||||
var file = ts.getSourceFileOfNode(node);
|
||||
return (ts.isClassDeclaration(node) && checkGrammarAwaitIdentifier(node.name)) ||
|
||||
checkGrammarClassDeclarationHeritageClauses(node) ||
|
||||
return checkGrammarClassDeclarationHeritageClauses(node) ||
|
||||
checkGrammarTypeParameterList(node.typeParameters, file);
|
||||
}
|
||||
function checkGrammarArrowFunction(node, file) {
|
||||
@ -77327,9 +77337,6 @@ var ts;
|
||||
return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_have_a_property_name);
|
||||
}
|
||||
}
|
||||
if (ts.isIdentifier(node.name) && checkGrammarAwaitIdentifier(node.name)) {
|
||||
return true;
|
||||
}
|
||||
if (node.dotDotDotToken && node.initializer) {
|
||||
// Error on equals token which immediately precedes the initializer
|
||||
return grammarErrorAtPos(node, node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer);
|
||||
@ -77386,9 +77393,6 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ts.isIdentifier(node.name) && checkGrammarAwaitIdentifier(node.name)) {
|
||||
return true;
|
||||
}
|
||||
if (node.exclamationToken && (node.parent.parent.kind !== 229 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) {
|
||||
return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation);
|
||||
}
|
||||
@ -107351,7 +107355,7 @@ var ts;
|
||||
});
|
||||
// Sort by paths closest to importing file Name directory
|
||||
var sortedPaths = [];
|
||||
var _loop_22 = function (directory) {
|
||||
var _loop_23 = function (directory) {
|
||||
var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
|
||||
var pathsInDirectory;
|
||||
allFileNames.forEach(function (canonicalFileName, fileName) {
|
||||
@ -107377,7 +107381,7 @@ var ts;
|
||||
};
|
||||
var out_directory_1;
|
||||
for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) {
|
||||
var state_8 = _loop_22(directory);
|
||||
var state_8 = _loop_23(directory);
|
||||
directory = out_directory_1;
|
||||
if (state_8 === "break")
|
||||
break;
|
||||
|
||||
@ -13972,6 +13972,15 @@ var ts;
|
||||
}
|
||||
}
|
||||
ts.getThisContainer = getThisContainer;
|
||||
function isInTopLevelContext(node) {
|
||||
// The name of a class or function declaration is a BindingIdentifier in its surrounding scope.
|
||||
if (ts.isIdentifier(node) && (ts.isClassDeclaration(node.parent) || ts.isFunctionDeclaration(node.parent)) && node.parent.name === node) {
|
||||
node = node.parent;
|
||||
}
|
||||
var container = getThisContainer(node, /*includeArrowFunctions*/ true);
|
||||
return ts.isSourceFile(container);
|
||||
}
|
||||
ts.isInTopLevelContext = isInTopLevelContext;
|
||||
function getNewTargetContainer(node) {
|
||||
var container = getThisContainer(node, /*includeArrowFunctions*/ false);
|
||||
if (container) {
|
||||
@ -15169,13 +15178,7 @@ var ts;
|
||||
return parent.name === node;
|
||||
case 156 /* QualifiedName */:
|
||||
// Name on right hand side of dot in a type query or type reference
|
||||
if (parent.right === node) {
|
||||
while (parent.kind === 156 /* QualifiedName */) {
|
||||
parent = parent.parent;
|
||||
}
|
||||
return parent.kind === 175 /* TypeQuery */ || parent.kind === 172 /* TypeReference */;
|
||||
}
|
||||
return false;
|
||||
return parent.right === node;
|
||||
case 195 /* BindingElement */:
|
||||
case 262 /* ImportSpecifier */:
|
||||
// Property name in binding element or import specifier
|
||||
@ -27532,31 +27535,6 @@ var ts;
|
||||
createBaseNode: function (kind) { return countNode(new NodeConstructor(kind, /*pos*/ 0, /*end*/ 0)); }
|
||||
};
|
||||
var factory = ts.createNodeFactory(1 /* NoParenthesizerRules */ | 2 /* NoNodeConverters */ | 8 /* NoOriginalNode */, baseNodeFactory);
|
||||
var reparseContext = {
|
||||
get factory() { return factory; },
|
||||
enableEmitNotification: ts.notImplemented,
|
||||
enableSubstitution: ts.notImplemented,
|
||||
endLexicalEnvironment: ts.returnUndefined,
|
||||
getCompilerOptions: ts.notImplemented,
|
||||
getEmitHost: ts.notImplemented,
|
||||
getEmitResolver: ts.notImplemented,
|
||||
getEmitHelperFactory: ts.notImplemented,
|
||||
setLexicalEnvironmentFlags: ts.noop,
|
||||
getLexicalEnvironmentFlags: function () { return 0; },
|
||||
hoistFunctionDeclaration: ts.notImplemented,
|
||||
hoistVariableDeclaration: ts.notImplemented,
|
||||
addInitializationStatement: ts.notImplemented,
|
||||
isEmitNotificationEnabled: ts.notImplemented,
|
||||
isSubstitutionEnabled: ts.notImplemented,
|
||||
onEmitNode: ts.notImplemented,
|
||||
onSubstituteNode: ts.notImplemented,
|
||||
readEmitHelpers: ts.notImplemented,
|
||||
requestEmitHelper: ts.notImplemented,
|
||||
resumeLexicalEnvironment: ts.noop,
|
||||
startLexicalEnvironment: ts.noop,
|
||||
suspendLexicalEnvironment: ts.noop,
|
||||
addDiagnostic: ts.notImplemented,
|
||||
};
|
||||
var fileName;
|
||||
var sourceFlags;
|
||||
var sourceText;
|
||||
@ -27620,6 +27598,8 @@ var ts;
|
||||
// parsing. These context flags are naturally stored and restored through normal recursive
|
||||
// descent parsing and unwinding.
|
||||
var contextFlags;
|
||||
// Indicates whether we are currently parsing top-level statements.
|
||||
var topLevel = true;
|
||||
// Whether or not we've had a parse error since creating the last AST node. If we have
|
||||
// encountered an error, it will be stored on the next AST node we create. Parse errors
|
||||
// can be broken down into three categories:
|
||||
@ -27763,6 +27743,7 @@ var ts;
|
||||
identifierCount = 0;
|
||||
nodeCount = 0;
|
||||
sourceFlags = 0;
|
||||
topLevel = true;
|
||||
switch (scriptKind) {
|
||||
case 1 /* JS */:
|
||||
case 2 /* JSX */:
|
||||
@ -27799,6 +27780,7 @@ var ts;
|
||||
parsingContext = 0;
|
||||
identifiers = undefined;
|
||||
notParenthesizedArrow = undefined;
|
||||
topLevel = true;
|
||||
}
|
||||
function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind) {
|
||||
var isDeclarationFile = isDeclarationFileName(fileName);
|
||||
@ -27847,108 +27829,98 @@ var ts;
|
||||
return node;
|
||||
}
|
||||
function reparseTopLevelAwait(sourceFile) {
|
||||
return ts.visitEachChild(sourceFile, visitor, reparseContext);
|
||||
function visitor(node) {
|
||||
if (!(node.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */)) {
|
||||
return node;
|
||||
var savedSyntaxCursor = syntaxCursor;
|
||||
var baseSyntaxCursor = IncrementalParser.createSyntaxCursor(sourceFile);
|
||||
syntaxCursor = { currentNode: currentNode };
|
||||
var statements = [];
|
||||
var savedParseDiagnostics = parseDiagnostics;
|
||||
parseDiagnostics = [];
|
||||
var pos = 0;
|
||||
var start = findNextStatementWithAwait(sourceFile.statements, 0);
|
||||
var _loop_3 = function () {
|
||||
// append all statements between pos and start
|
||||
var prevStatement = sourceFile.statements[pos];
|
||||
var nextStatement = sourceFile.statements[start];
|
||||
ts.addRange(statements, sourceFile.statements, pos, start);
|
||||
pos = findNextStatementWithoutAwait(sourceFile.statements, start);
|
||||
// append all diagnostics associated with the copied range
|
||||
var diagnosticStart = ts.findIndex(savedParseDiagnostics, function (diagnostic) { return diagnostic.start >= prevStatement.pos; });
|
||||
var diagnosticEnd = diagnosticStart >= 0 ? ts.findIndex(savedParseDiagnostics, function (diagnostic) { return diagnostic.start >= nextStatement.pos; }, diagnosticStart) : -1;
|
||||
if (diagnosticStart >= 0) {
|
||||
ts.addRange(parseDiagnostics, savedParseDiagnostics, diagnosticStart, diagnosticEnd >= 0 ? diagnosticEnd : undefined);
|
||||
}
|
||||
// We explicitly visit each non-Expression node that has an immediate Expression child so that
|
||||
// we can reparse the Expression in an Await context
|
||||
switch (node.kind) {
|
||||
case 160 /* Decorator */: return reparseDecorator(node);
|
||||
case 157 /* ComputedPropertyName */: return reparseComputedPropertyName(node);
|
||||
case 220 /* ExpressionWithTypeArguments */: return reparseExpressionWithTypeArguments(node);
|
||||
case 230 /* ExpressionStatement */: return reparseExpressionStatement(node);
|
||||
case 231 /* IfStatement */: return reparseIfStatement(node);
|
||||
case 241 /* SwitchStatement */: return reparseSwitchStatement(node);
|
||||
case 240 /* WithStatement */: return reparseWithStatement(node);
|
||||
case 232 /* DoStatement */: return reparseDoStatement(node);
|
||||
case 233 /* WhileStatement */: return reparseWhileStatement(node);
|
||||
case 234 /* ForStatement */: return reparseForStatement(node);
|
||||
case 235 /* ForInStatement */: return reparseForInStatement(node);
|
||||
case 236 /* ForOfStatement */: return reparseForOfStatement(node);
|
||||
case 239 /* ReturnStatement */: return reparseReturnStatement(node);
|
||||
case 243 /* ThrowStatement */: return reparseThrowStatement(node);
|
||||
case 263 /* ExportAssignment */: return reparseExportAssignment(node);
|
||||
case 246 /* VariableDeclaration */: return reparseVariableDeclaration(node);
|
||||
case 195 /* BindingElement */: return reparseBindingElement(node);
|
||||
default: return ts.visitEachChild(node, visitor, reparseContext);
|
||||
// reparse all statements between start and pos. We skip existing diagnostics for the same range and allow the parser to generate new ones.
|
||||
speculationHelper(function () {
|
||||
var savedContextFlags = contextFlags;
|
||||
contextFlags |= 32768 /* AwaitContext */;
|
||||
scanner.setTextPos(nextStatement.pos);
|
||||
nextToken();
|
||||
while (token() !== 1 /* EndOfFileToken */) {
|
||||
var startPos = scanner.getStartPos();
|
||||
var statement = parseListElement(0 /* SourceElements */, parseStatement);
|
||||
statements.push(statement);
|
||||
if (startPos === scanner.getStartPos()) {
|
||||
nextToken();
|
||||
}
|
||||
if (pos >= 0) {
|
||||
var nonAwaitStatement = sourceFile.statements[pos];
|
||||
if (statement.end === nonAwaitStatement.pos) {
|
||||
// done reparsing this section
|
||||
break;
|
||||
}
|
||||
if (statement.end > nonAwaitStatement.pos) {
|
||||
// we ate into the next statement, so we must reparse it.
|
||||
pos = findNextStatementWithoutAwait(sourceFile.statements, pos + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
contextFlags = savedContextFlags;
|
||||
}, 2 /* Reparse */);
|
||||
// find the next statement containing an `await`
|
||||
start = pos >= 0 ? findNextStatementWithAwait(sourceFile.statements, pos) : -1;
|
||||
};
|
||||
while (start !== -1) {
|
||||
_loop_3();
|
||||
}
|
||||
// append all statements between pos and the end of the list
|
||||
if (pos >= 0) {
|
||||
var prevStatement_1 = sourceFile.statements[pos];
|
||||
ts.addRange(statements, sourceFile.statements, pos);
|
||||
// append all diagnostics associated with the copied range
|
||||
var diagnosticStart = ts.findIndex(savedParseDiagnostics, function (diagnostic) { return diagnostic.start >= prevStatement_1.pos; });
|
||||
if (diagnosticStart >= 0) {
|
||||
ts.addRange(parseDiagnostics, savedParseDiagnostics, diagnosticStart);
|
||||
}
|
||||
}
|
||||
function reparse(node, parse) {
|
||||
if (node && node.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */) {
|
||||
if (ts.isExpression(node)) {
|
||||
return speculationHelper(function () {
|
||||
scanner.setTextPos(node.pos);
|
||||
var savedContextFlags = contextFlags;
|
||||
contextFlags = node.flags & 25358336 /* ContextFlags */;
|
||||
nextToken();
|
||||
var result = doInAwaitContext(parse);
|
||||
contextFlags = savedContextFlags;
|
||||
return result;
|
||||
}, 2 /* Reparse */);
|
||||
syntaxCursor = savedSyntaxCursor;
|
||||
return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements));
|
||||
function containsPossibleTopLevelAwait(node) {
|
||||
return !(node.flags & 32768 /* AwaitContext */)
|
||||
&& !!(node.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */);
|
||||
}
|
||||
function findNextStatementWithAwait(statements, start) {
|
||||
for (var i = start; i < statements.length; i++) {
|
||||
if (containsPossibleTopLevelAwait(statements[i])) {
|
||||
return i;
|
||||
}
|
||||
return ts.visitEachChild(node, visitor, reparseContext);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
function findNextStatementWithoutAwait(statements, start) {
|
||||
for (var i = start; i < statements.length; i++) {
|
||||
if (!containsPossibleTopLevelAwait(statements[i])) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
function currentNode(position) {
|
||||
var node = baseSyntaxCursor.currentNode(position);
|
||||
if (topLevel && node && containsPossibleTopLevelAwait(node)) {
|
||||
node.intersectsChange = true;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
function update(updated, original) {
|
||||
if (updated !== original) {
|
||||
ts.setNodeFlags(updated, updated.flags | 32768 /* AwaitContext */);
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
function reparseExpressionStatement(node) {
|
||||
return update(factory.updateExpressionStatement(node, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseReturnStatement(node) {
|
||||
return update(factory.updateReturnStatement(node, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseThrowStatement(node) {
|
||||
return update(factory.updateThrowStatement(node, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseIfStatement(node) {
|
||||
return update(factory.updateIfStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.thenStatement, visitor), ts.visitNode(node.elseStatement, visitor)), node);
|
||||
}
|
||||
function reparseSwitchStatement(node) {
|
||||
return update(factory.updateSwitchStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.caseBlock, visitor)), node);
|
||||
}
|
||||
function reparseWithStatement(node) {
|
||||
return update(factory.updateWithStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
|
||||
}
|
||||
function reparseDoStatement(node) {
|
||||
return update(factory.updateDoStatement(node, ts.visitNode(node.statement, visitor), reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseWhileStatement(node) {
|
||||
return update(factory.updateWhileStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
|
||||
}
|
||||
function reparseForStatement(node) {
|
||||
return update(factory.updateForStatement(node, reparse(node.initializer, parseExpression), reparse(node.condition, parseExpression), reparse(node.incrementor, parseExpression), ts.visitNode(node, visitor)), node);
|
||||
}
|
||||
function reparseForInStatement(node) {
|
||||
return update(factory.updateForInStatement(node, reparse(node.initializer, parseExpression), reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
|
||||
}
|
||||
function reparseForOfStatement(node) {
|
||||
return update(factory.updateForOfStatement(node, node.awaitModifier, reparse(node.initializer, parseExpression), reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
|
||||
}
|
||||
function reparseExportAssignment(node) {
|
||||
return update(factory.updateExportAssignment(node, ts.visitNodes(node.decorators, visitor), node.modifiers, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseExpressionWithTypeArguments(node) {
|
||||
return update(factory.updateExpressionWithTypeArguments(node, reparse(node.expression, parseLeftHandSideExpressionOrHigher), node.typeArguments), node);
|
||||
}
|
||||
function reparseDecorator(node) {
|
||||
return update(factory.updateDecorator(node, reparse(node.expression, parseLeftHandSideExpressionOrHigher)), node);
|
||||
}
|
||||
function reparseComputedPropertyName(node) {
|
||||
return update(factory.updateComputedPropertyName(node, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseVariableDeclaration(node) {
|
||||
return update(factory.updateVariableDeclaration(node, ts.visitNode(node.name, visitor), node.exclamationToken, node.type, reparse(node.initializer, parseExpression)), node);
|
||||
}
|
||||
function reparseBindingElement(node) {
|
||||
return update(factory.updateBindingElement(node, node.dotDotDotToken, ts.visitNode(node.propertyName, visitor), ts.visitNode(node.name, visitor), reparse(node.initializer, parseExpression)), node);
|
||||
}
|
||||
}
|
||||
function fixupParentReferences(rootNode) {
|
||||
// normally parent references are set during binding. However, for clients that only need
|
||||
@ -28198,6 +28170,12 @@ var ts;
|
||||
function tryParse(callback) {
|
||||
return speculationHelper(callback, 0 /* TryParse */);
|
||||
}
|
||||
function isBindingIdentifier() {
|
||||
if (token() === 78 /* Identifier */) {
|
||||
return true;
|
||||
}
|
||||
return token() > 115 /* LastReservedWord */;
|
||||
}
|
||||
// Ignore strict mode flag because we will report an error in type checker instead.
|
||||
function isIdentifier() {
|
||||
if (token() === 78 /* Identifier */) {
|
||||
@ -28367,6 +28345,9 @@ var ts;
|
||||
ts.Diagnostics.Identifier_expected;
|
||||
return createMissingNode(78 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg);
|
||||
}
|
||||
function parseBindingIdentifier(privateIdentifierDiagnosticMessage) {
|
||||
return createIdentifier(isBindingIdentifier(), /*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage);
|
||||
}
|
||||
function parseIdentifier(diagnosticMessage, privateIdentifierDiagnosticMessage) {
|
||||
return createIdentifier(isIdentifier(), diagnosticMessage, privateIdentifierDiagnosticMessage);
|
||||
}
|
||||
@ -28544,9 +28525,9 @@ var ts;
|
||||
return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword();
|
||||
}
|
||||
case 8 /* VariableDeclarations */:
|
||||
return isIdentifierOrPrivateIdentifierOrPattern();
|
||||
return isBindingIdentifierOrPrivateIdentifierOrPattern();
|
||||
case 10 /* ArrayBindingElements */:
|
||||
return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isIdentifierOrPrivateIdentifierOrPattern();
|
||||
return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern();
|
||||
case 19 /* TypeParameters */:
|
||||
return isIdentifier();
|
||||
case 15 /* ArrayLiteralMembers */:
|
||||
@ -29388,7 +29369,7 @@ var ts;
|
||||
}
|
||||
function isStartOfParameter(isJSDocParameter) {
|
||||
return token() === 25 /* DotDotDotToken */ ||
|
||||
isIdentifierOrPrivateIdentifierOrPattern() ||
|
||||
isBindingIdentifierOrPrivateIdentifierOrPattern() ||
|
||||
ts.isModifierKind(token()) ||
|
||||
token() === 59 /* AtToken */ ||
|
||||
isStartOfType(/*inStartOfParameter*/ !isJSDocParameter);
|
||||
@ -29410,22 +29391,34 @@ var ts;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
function parseParameterInOuterAwaitContext() {
|
||||
return parseParameterWorker(/*inOuterAwaitContext*/ true);
|
||||
}
|
||||
function parseParameter() {
|
||||
return parseParameterWorker(/*inOuterAwaitContext*/ false);
|
||||
}
|
||||
function parseParameterWorker(inOuterAwaitContext) {
|
||||
var pos = getNodePos();
|
||||
var hasJSDoc = hasPrecedingJSDocComment();
|
||||
if (token() === 107 /* ThisKeyword */) {
|
||||
var node = factory.createParameterDeclaration(
|
||||
var node_1 = factory.createParameterDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
/*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true),
|
||||
/*questionToken*/ undefined, parseTypeAnnotation(),
|
||||
/*initializer*/ undefined);
|
||||
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
||||
return withJSDoc(finishNode(node_1, pos), hasJSDoc);
|
||||
}
|
||||
// FormalParameter [Yield,Await]:
|
||||
// BindingElement[?Yield,?Await]
|
||||
var modifiers;
|
||||
return withJSDoc(finishNode(factory.createParameterDeclaration(parseDecorators(), modifiers = parseModifiers(), parseOptionalToken(25 /* DotDotDotToken */), parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc);
|
||||
// Decorators are parsed in the outer [Await] context, the rest of the parameter is parsed in the function's [Await] context.
|
||||
var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators();
|
||||
var savedTopLevel = topLevel;
|
||||
topLevel = false;
|
||||
var modifiers = parseModifiers();
|
||||
var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, parseOptionalToken(25 /* DotDotDotToken */), parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc);
|
||||
topLevel = savedTopLevel;
|
||||
return node;
|
||||
}
|
||||
function parseReturnType(returnToken, isType) {
|
||||
if (shouldParseReturnType(returnToken, isType)) {
|
||||
@ -29468,7 +29461,7 @@ var ts;
|
||||
setAwaitContext(!!(flags & 2 /* Await */));
|
||||
var parameters = flags & 32 /* JSDoc */ ?
|
||||
parseDelimitedList(17 /* JSDocParameters */, parseJSDocParameter) :
|
||||
parseDelimitedList(16 /* Parameters */, parseParameter);
|
||||
parseDelimitedList(16 /* Parameters */, savedAwaitContext ? parseParameterInOuterAwaitContext : parseParameter);
|
||||
setYieldContext(savedYieldContext);
|
||||
setAwaitContext(savedAwaitContext);
|
||||
return parameters;
|
||||
@ -30597,9 +30590,13 @@ var ts;
|
||||
// Note: even when 'IgnoreMissingOpenBrace' is passed, parseBody will still error.
|
||||
return parseFunctionBlock(16 /* IgnoreMissingOpenBrace */ | (isAsync ? 2 /* Await */ : 0 /* None */));
|
||||
}
|
||||
return isAsync
|
||||
var savedTopLevel = topLevel;
|
||||
topLevel = false;
|
||||
var node = isAsync
|
||||
? doInAwaitContext(parseAssignmentExpressionOrHigher)
|
||||
: doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
|
||||
topLevel = savedTopLevel;
|
||||
return node;
|
||||
}
|
||||
function parseConditionalExpressionRest(leftOperand, pos) {
|
||||
// Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher.
|
||||
@ -31590,10 +31587,10 @@ var ts;
|
||||
var asteriskToken = parseOptionalToken(41 /* AsteriskToken */);
|
||||
var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */;
|
||||
var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */;
|
||||
var name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) :
|
||||
isGenerator ? doInYieldContext(parseOptionalIdentifier) :
|
||||
isAsync ? doInAwaitContext(parseOptionalIdentifier) :
|
||||
parseOptionalIdentifier();
|
||||
var name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalBindingIdentifier) :
|
||||
isGenerator ? doInYieldContext(parseOptionalBindingIdentifier) :
|
||||
isAsync ? doInAwaitContext(parseOptionalBindingIdentifier) :
|
||||
parseOptionalBindingIdentifier();
|
||||
var typeParameters = parseTypeParameters();
|
||||
var parameters = parseParameters(isGenerator | isAsync);
|
||||
var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
|
||||
@ -31604,8 +31601,8 @@ var ts;
|
||||
var node = factory.createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body);
|
||||
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
||||
}
|
||||
function parseOptionalIdentifier() {
|
||||
return isIdentifier() ? parseIdentifier() : undefined;
|
||||
function parseOptionalBindingIdentifier() {
|
||||
return isBindingIdentifier() ? parseBindingIdentifier() : undefined;
|
||||
}
|
||||
function parseNewExpressionOrNewDotTarget() {
|
||||
var pos = getNodePos();
|
||||
@ -31661,6 +31658,8 @@ var ts;
|
||||
setYieldContext(!!(flags & 1 /* Yield */));
|
||||
var savedAwaitContext = inAwaitContext();
|
||||
setAwaitContext(!!(flags & 2 /* Await */));
|
||||
var savedTopLevel = topLevel;
|
||||
topLevel = false;
|
||||
// We may be in a [Decorator] context when parsing a function expression or
|
||||
// arrow function. The body of the function is not in [Decorator] context.
|
||||
var saveDecoratorContext = inDecoratorContext();
|
||||
@ -31671,6 +31670,7 @@ var ts;
|
||||
if (saveDecoratorContext) {
|
||||
setDecoratorContext(/*val*/ true);
|
||||
}
|
||||
topLevel = savedTopLevel;
|
||||
setYieldContext(savedYieldContext);
|
||||
setAwaitContext(savedAwaitContext);
|
||||
return block;
|
||||
@ -32229,7 +32229,7 @@ var ts;
|
||||
function parseObjectBindingElement() {
|
||||
var pos = getNodePos();
|
||||
var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */);
|
||||
var tokenIsIdentifier = isIdentifier();
|
||||
var tokenIsIdentifier = isBindingIdentifier();
|
||||
var propertyName = parsePropertyName();
|
||||
var name;
|
||||
if (tokenIsIdentifier && token() !== 58 /* ColonToken */) {
|
||||
@ -32257,11 +32257,11 @@ var ts;
|
||||
parseExpected(23 /* CloseBracketToken */);
|
||||
return finishNode(factory.createArrayBindingPattern(elements), pos);
|
||||
}
|
||||
function isIdentifierOrPrivateIdentifierOrPattern() {
|
||||
function isBindingIdentifierOrPrivateIdentifierOrPattern() {
|
||||
return token() === 18 /* OpenBraceToken */
|
||||
|| token() === 22 /* OpenBracketToken */
|
||||
|| token() === 79 /* PrivateIdentifier */
|
||||
|| isIdentifier();
|
||||
|| isBindingIdentifier();
|
||||
}
|
||||
function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) {
|
||||
if (token() === 22 /* OpenBracketToken */) {
|
||||
@ -32270,7 +32270,7 @@ var ts;
|
||||
if (token() === 18 /* OpenBraceToken */) {
|
||||
return parseObjectBindingPattern();
|
||||
}
|
||||
return parseIdentifier(/*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage);
|
||||
return parseBindingIdentifier(privateIdentifierDiagnosticMessage);
|
||||
}
|
||||
function parseVariableDeclarationAllowExclamation() {
|
||||
return parseVariableDeclaration(/*allowExclamation*/ true);
|
||||
@ -32342,7 +32342,7 @@ var ts;
|
||||
parseExpected(97 /* FunctionKeyword */);
|
||||
var asteriskToken = parseOptionalToken(41 /* AsteriskToken */);
|
||||
// We don't parse the name here in await context, instead we will report a grammar error in the checker.
|
||||
var name = modifierFlags & 512 /* Default */ ? parseOptionalIdentifier() : parseIdentifier();
|
||||
var name = modifierFlags & 512 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier();
|
||||
var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */;
|
||||
var isAsync = modifierFlags & 256 /* Async */ ? 2 /* Await */ : 0 /* None */;
|
||||
var typeParameters = parseTypeParameters();
|
||||
@ -32486,12 +32486,24 @@ var ts;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function parseDecoratorExpression() {
|
||||
if (inAwaitContext() && token() === 130 /* AwaitKeyword */) {
|
||||
// `@await` is is disallowed in an [Await] context, but can cause parsing to go off the rails
|
||||
// This simply parses the missing identifier and moves on.
|
||||
var pos = getNodePos();
|
||||
var awaitExpression = parseIdentifier(ts.Diagnostics.Expression_expected);
|
||||
nextToken();
|
||||
var memberExpression = parseMemberExpressionRest(pos, awaitExpression, /*allowOptionalChain*/ true);
|
||||
return parseCallExpressionRest(pos, memberExpression);
|
||||
}
|
||||
return parseLeftHandSideExpressionOrHigher();
|
||||
}
|
||||
function tryParseDecorator() {
|
||||
var pos = getNodePos();
|
||||
if (!parseOptional(59 /* AtToken */)) {
|
||||
return undefined;
|
||||
}
|
||||
var expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher);
|
||||
var expression = doInDecoratorContext(parseDecoratorExpression);
|
||||
return finishNode(factory.createDecorator(expression), pos);
|
||||
}
|
||||
function parseDecorators() {
|
||||
@ -32632,8 +32644,8 @@ var ts;
|
||||
// - class expression with omitted name, 'implements' starts heritage clause
|
||||
// - class with name 'implements'
|
||||
// 'isImplementsClause' helps to disambiguate between these two cases
|
||||
return isIdentifier() && !isImplementsClause()
|
||||
? parseIdentifier()
|
||||
return isBindingIdentifier() && !isImplementsClause()
|
||||
? createIdentifier(isBindingIdentifier())
|
||||
: undefined;
|
||||
}
|
||||
function isImplementsClause() {
|
||||
@ -34429,6 +34441,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
IncrementalParser.createSyntaxCursor = createSyntaxCursor;
|
||||
var InvalidPosition;
|
||||
(function (InvalidPosition) {
|
||||
InvalidPosition[InvalidPosition["Value"] = -1] = "Value";
|
||||
@ -36215,7 +36228,7 @@ var ts;
|
||||
}
|
||||
function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) {
|
||||
var result = returnValue ? {} : undefined;
|
||||
var _loop_3 = function (element) {
|
||||
var _loop_4 = function (element) {
|
||||
if (element.kind !== 285 /* PropertyAssignment */) {
|
||||
errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected));
|
||||
return "continue";
|
||||
@ -36268,7 +36281,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
|
||||
var element = _a[_i];
|
||||
_loop_3(element);
|
||||
_loop_4(element);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -36451,7 +36464,7 @@ var ts;
|
||||
var optionsNameMap = _a.optionsNameMap;
|
||||
var result = ts.createMap();
|
||||
var getCanonicalFileName = pathOptions && ts.createGetCanonicalFileName(pathOptions.useCaseSensitiveFileNames);
|
||||
var _loop_4 = function (name) {
|
||||
var _loop_5 = function (name) {
|
||||
if (ts.hasProperty(options, name)) {
|
||||
// tsconfig only options cannot be specified via command line,
|
||||
// so we can assume that only types that can appear here string | number | boolean
|
||||
@ -36485,7 +36498,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var name in options) {
|
||||
_loop_4(name);
|
||||
_loop_5(name);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -37246,7 +37259,7 @@ var ts;
|
||||
}
|
||||
var jsonOnlyIncludeRegexes;
|
||||
if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) {
|
||||
var _loop_5 = function (file) {
|
||||
var _loop_6 = function (file) {
|
||||
if (ts.fileExtensionIs(file, ".json" /* Json */)) {
|
||||
// Valid only if *.json specified
|
||||
if (!jsonOnlyIncludeRegexes) {
|
||||
@ -37284,7 +37297,7 @@ var ts;
|
||||
};
|
||||
for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensionsWithJsonIfResolveJsonModule, validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined); _a < _b.length; _a++) {
|
||||
var file = _b[_a];
|
||||
_loop_5(file);
|
||||
_loop_6(file);
|
||||
}
|
||||
}
|
||||
var literalFiles = ts.arrayFrom(literalFileMap.values());
|
||||
@ -40691,18 +40704,31 @@ var ts;
|
||||
currentFlow = saveCurrentFlow;
|
||||
}
|
||||
// The binder visits every node in the syntax tree so it is a convenient place to perform a single localized
|
||||
// check for reserved words used as identifiers in strict mode code.
|
||||
function checkStrictModeIdentifier(node) {
|
||||
if (inStrictMode &&
|
||||
node.originalKeywordKind >= 116 /* FirstFutureReservedWord */ &&
|
||||
node.originalKeywordKind <= 124 /* LastFutureReservedWord */ &&
|
||||
!ts.isIdentifierName(node) &&
|
||||
// check for reserved words used as identifiers in strict mode code, as well as `yield` or `await` in
|
||||
// [Yield] or [Await] contexts, respectively.
|
||||
function checkContextualIdentifier(node) {
|
||||
// Report error only if there are no parse errors in file
|
||||
if (!file.parseDiagnostics.length &&
|
||||
!(node.flags & 8388608 /* Ambient */) &&
|
||||
!(node.flags & 4194304 /* JSDoc */)) {
|
||||
// Report error only if there are no parse errors in file
|
||||
if (!file.parseDiagnostics.length) {
|
||||
!(node.flags & 4194304 /* JSDoc */) &&
|
||||
!ts.isIdentifierName(node)) {
|
||||
// strict mode identifiers
|
||||
if (inStrictMode &&
|
||||
node.originalKeywordKind >= 116 /* FirstFutureReservedWord */ &&
|
||||
node.originalKeywordKind <= 124 /* LastFutureReservedWord */) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node)));
|
||||
}
|
||||
else if (node.originalKeywordKind === 130 /* AwaitKeyword */) {
|
||||
if (ts.isExternalModule(file) && ts.isInTopLevelContext(node)) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.declarationNameToString(node)));
|
||||
}
|
||||
else if (node.flags & 32768 /* AwaitContext */) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node)));
|
||||
}
|
||||
}
|
||||
else if (node.originalKeywordKind === 124 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node)));
|
||||
}
|
||||
}
|
||||
}
|
||||
function getStrictModeIdentifierMessage(node) {
|
||||
@ -40969,7 +40995,7 @@ var ts;
|
||||
if (currentFlow && (ts.isExpression(node) || parent.kind === 286 /* ShorthandPropertyAssignment */)) {
|
||||
node.flowNode = currentFlow;
|
||||
}
|
||||
return checkStrictModeIdentifier(node);
|
||||
return checkContextualIdentifier(node);
|
||||
case 105 /* SuperKeyword */:
|
||||
node.flowNode = currentFlow;
|
||||
break;
|
||||
@ -43165,7 +43191,7 @@ var ts;
|
||||
function addDuplicateDeclarationError(node, message, symbolName, relatedNodes) {
|
||||
var errorNode = (ts.getExpandoInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getNameOfExpando(node) : ts.getNameOfDeclaration(node)) || node;
|
||||
var err = lookupOrIssueError(errorNode, message, symbolName);
|
||||
var _loop_6 = function (relatedNode) {
|
||||
var _loop_7 = function (relatedNode) {
|
||||
var adjustedNode = (ts.getExpandoInitializer(relatedNode, /*isPrototypeAssignment*/ false) ? ts.getNameOfExpando(relatedNode) : ts.getNameOfDeclaration(relatedNode)) || relatedNode;
|
||||
if (adjustedNode === errorNode)
|
||||
return "continue";
|
||||
@ -43178,7 +43204,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, _a = relatedNodes || ts.emptyArray; _i < _a.length; _i++) {
|
||||
var relatedNode = _a[_i];
|
||||
_loop_6(relatedNode);
|
||||
_loop_7(relatedNode);
|
||||
}
|
||||
}
|
||||
function combineSymbolTables(first, second) {
|
||||
@ -45419,7 +45445,7 @@ var ts;
|
||||
}
|
||||
function forEachSymbolTableInScope(enclosingDeclaration, callback) {
|
||||
var result;
|
||||
var _loop_7 = function (location) {
|
||||
var _loop_8 = function (location) {
|
||||
// Locals of a source file are not in scope (because they get merged into the global symbol table)
|
||||
if (location.locals && !isGlobalSourceFile(location)) {
|
||||
if (result = callback(location.locals)) {
|
||||
@ -45465,7 +45491,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var location = enclosingDeclaration; location; location = location.parent) {
|
||||
var state_2 = _loop_7(location);
|
||||
var state_2 = _loop_8(location);
|
||||
if (typeof state_2 === "object")
|
||||
return state_2.value;
|
||||
}
|
||||
@ -47475,7 +47501,7 @@ var ts;
|
||||
if (ts.length(reexports) > 1) {
|
||||
var groups = ts.group(reexports, function (decl) { return ts.isStringLiteral(decl.moduleSpecifier) ? ">" + decl.moduleSpecifier.text : ">"; });
|
||||
if (groups.length !== reexports.length) {
|
||||
var _loop_8 = function (group_1) {
|
||||
var _loop_9 = function (group_1) {
|
||||
if (group_1.length > 1) {
|
||||
// remove group members from statements and then merge group members and add back to statements
|
||||
statements = __spreadArrays(ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), [
|
||||
@ -47488,7 +47514,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) {
|
||||
var group_1 = groups_1[_i];
|
||||
_loop_8(group_1);
|
||||
_loop_9(group_1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -51000,7 +51026,7 @@ var ts;
|
||||
// signatures from the type, whose ordering would be non-obvious)
|
||||
var masterList = signatureLists[indexWithLengthOverOne !== undefined ? indexWithLengthOverOne : 0];
|
||||
var results = masterList.slice();
|
||||
var _loop_9 = function (signatures) {
|
||||
var _loop_10 = function (signatures) {
|
||||
if (signatures !== masterList) {
|
||||
var signature_1 = signatures[0];
|
||||
ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass");
|
||||
@ -51012,7 +51038,7 @@ var ts;
|
||||
};
|
||||
for (var _b = 0, signatureLists_1 = signatureLists; _b < signatureLists_1.length; _b++) {
|
||||
var signatures = signatureLists_1[_b];
|
||||
var state_3 = _loop_9(signatures);
|
||||
var state_3 = _loop_10(signatures);
|
||||
if (state_3 === "break")
|
||||
break;
|
||||
}
|
||||
@ -51136,7 +51162,7 @@ var ts;
|
||||
var types = type.types;
|
||||
var mixinFlags = findMixins(types);
|
||||
var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; });
|
||||
var _loop_10 = function (i) {
|
||||
var _loop_11 = function (i) {
|
||||
var t = type.types[i];
|
||||
// When an intersection type contains mixin constructor types, the construct signatures from
|
||||
// those types are discarded and their return types are mixed into the return types of all
|
||||
@ -51159,19 +51185,19 @@ var ts;
|
||||
numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1 /* Number */));
|
||||
};
|
||||
for (var i = 0; i < types.length; i++) {
|
||||
_loop_10(i);
|
||||
_loop_11(i);
|
||||
}
|
||||
setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo);
|
||||
}
|
||||
function appendSignatures(signatures, newSignatures) {
|
||||
var _loop_11 = function (sig) {
|
||||
var _loop_12 = function (sig) {
|
||||
if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, compareTypesIdentical); })) {
|
||||
signatures = ts.append(signatures, sig);
|
||||
}
|
||||
};
|
||||
for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) {
|
||||
var sig = newSignatures_1[_i];
|
||||
_loop_11(sig);
|
||||
_loop_12(sig);
|
||||
}
|
||||
return signatures;
|
||||
}
|
||||
@ -53458,7 +53484,7 @@ var ts;
|
||||
var expandedDeclarations = [];
|
||||
var optionalIndex = -1;
|
||||
var restTypes;
|
||||
var _loop_12 = function (i) {
|
||||
var _loop_13 = function (i) {
|
||||
var type = elementTypes[i];
|
||||
var flags = target.elementFlags[i];
|
||||
if (flags & 8 /* Variadic */) {
|
||||
@ -53481,7 +53507,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var i = 0; i < elementTypes.length; i++) {
|
||||
_loop_12(i);
|
||||
_loop_13(i);
|
||||
}
|
||||
if (restTypes) {
|
||||
// Create a union of the collected rest element types.
|
||||
@ -54531,7 +54557,7 @@ var ts;
|
||||
function getConditionalType(root, mapper) {
|
||||
var result;
|
||||
var extraTypes;
|
||||
var _loop_13 = function () {
|
||||
var _loop_14 = function () {
|
||||
var checkType = instantiateType(root.checkType, mapper);
|
||||
var checkTypeInstantiable = isGenericObjectType(checkType) || isGenericIndexType(checkType);
|
||||
var extendsType = instantiateType(root.extendsType, mapper);
|
||||
@ -54605,7 +54631,7 @@ var ts;
|
||||
// types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
|
||||
// purposes of resolution. This means such types aren't subject to the instatiation depth limiter.
|
||||
while (true) {
|
||||
var state_4 = _loop_13();
|
||||
var state_4 = _loop_14();
|
||||
if (typeof state_4 === "object")
|
||||
return state_4.value;
|
||||
if (state_4 === "break")
|
||||
@ -57083,7 +57109,7 @@ var ts;
|
||||
reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
|
||||
checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget];
|
||||
}
|
||||
var _loop_14 = function (prop) {
|
||||
var _loop_15 = function (prop) {
|
||||
if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
|
||||
if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
|
||||
if (reportErrors) {
|
||||
@ -57146,7 +57172,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) {
|
||||
var prop = _a[_i];
|
||||
var state_5 = _loop_14(prop);
|
||||
var state_5 = _loop_15(prop);
|
||||
if (typeof state_5 === "object")
|
||||
return state_5.value;
|
||||
}
|
||||
@ -57819,11 +57845,11 @@ var ts;
|
||||
// constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
|
||||
var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
|
||||
var matchingTypes = [];
|
||||
var _loop_15 = function (combination) {
|
||||
var _loop_16 = function (combination) {
|
||||
var hasMatch = false;
|
||||
outer: for (var _i = 0, _a = target.types; _i < _a.length; _i++) {
|
||||
var type = _a[_i];
|
||||
var _loop_16 = function (i) {
|
||||
var _loop_17 = function (i) {
|
||||
var sourceProperty = sourcePropertiesFiltered[i];
|
||||
var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
|
||||
if (!targetProperty)
|
||||
@ -57839,7 +57865,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
|
||||
var state_7 = _loop_16(i);
|
||||
var state_7 = _loop_17(i);
|
||||
switch (state_7) {
|
||||
case "continue-outer": continue outer;
|
||||
}
|
||||
@ -57853,7 +57879,7 @@ var ts;
|
||||
};
|
||||
for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
|
||||
var combination = discriminantCombinations_1[_a];
|
||||
var state_6 = _loop_15(combination);
|
||||
var state_6 = _loop_16(combination);
|
||||
if (typeof state_6 === "object")
|
||||
return state_6.value;
|
||||
}
|
||||
@ -58495,7 +58521,7 @@ var ts;
|
||||
// The emptyArray singleton is used to signal a recursive invocation.
|
||||
cache.variances = ts.emptyArray;
|
||||
variances = [];
|
||||
var _loop_17 = function (tp) {
|
||||
var _loop_18 = function (tp) {
|
||||
var unmeasurable = false;
|
||||
var unreliable = false;
|
||||
var oldHandler = outofbandVarianceMarkerHandler;
|
||||
@ -58527,7 +58553,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) {
|
||||
var tp = typeParameters_1[_i];
|
||||
_loop_17(tp);
|
||||
_loop_18(tp);
|
||||
}
|
||||
cache.variances = variances;
|
||||
}
|
||||
@ -66010,7 +66036,7 @@ var ts;
|
||||
if (spreadIndex >= 0) {
|
||||
// Create synthetic arguments from spreads of tuple types.
|
||||
var effectiveArgs_1 = args.slice(0, spreadIndex);
|
||||
var _loop_18 = function (i) {
|
||||
var _loop_19 = function (i) {
|
||||
var arg = args[i];
|
||||
// We can call checkExpressionCached because spread expressions never have a contextual type.
|
||||
var spreadType = arg.kind === 217 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
|
||||
@ -66027,7 +66053,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var i = spreadIndex; i < args.length; i++) {
|
||||
_loop_18(i);
|
||||
_loop_19(i);
|
||||
}
|
||||
return effectiveArgs_1;
|
||||
}
|
||||
@ -66329,7 +66355,7 @@ var ts;
|
||||
var min_3 = Number.MAX_VALUE;
|
||||
var minIndex = 0;
|
||||
var i_1 = 0;
|
||||
var _loop_19 = function (c) {
|
||||
var _loop_20 = function (c) {
|
||||
var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
|
||||
var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2);
|
||||
if (diags_2) {
|
||||
@ -66347,7 +66373,7 @@ var ts;
|
||||
};
|
||||
for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
|
||||
var c = candidatesForArgumentError_1[_a];
|
||||
_loop_19(c);
|
||||
_loop_20(c);
|
||||
}
|
||||
var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
|
||||
ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
|
||||
@ -66481,7 +66507,7 @@ var ts;
|
||||
}
|
||||
var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
|
||||
var parameters = [];
|
||||
var _loop_20 = function (i) {
|
||||
var _loop_21 = function (i) {
|
||||
var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
|
||||
i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
|
||||
i < s.parameters.length ? s.parameters[i] : undefined; });
|
||||
@ -66489,7 +66515,7 @@ var ts;
|
||||
parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
|
||||
};
|
||||
for (var i = 0; i < maxNonRestParam; i++) {
|
||||
_loop_20(i);
|
||||
_loop_21(i);
|
||||
}
|
||||
var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
|
||||
var flags = 0 /* None */;
|
||||
@ -68241,15 +68267,11 @@ var ts;
|
||||
checkExpression(node.expression);
|
||||
return undefinedWideningType;
|
||||
}
|
||||
function isInTopLevelContext(node) {
|
||||
var container = ts.getThisContainer(node, /*includeArrowFunctions*/ true);
|
||||
return ts.isSourceFile(container);
|
||||
}
|
||||
function checkAwaitExpression(node) {
|
||||
// Grammar checking
|
||||
if (produceDiagnostics) {
|
||||
if (!(node.flags & 32768 /* AwaitContext */)) {
|
||||
if (isInTopLevelContext(node)) {
|
||||
if (ts.isInTopLevelContext(node)) {
|
||||
var sourceFile = ts.getSourceFileOfNode(node);
|
||||
if (!hasParseDiagnostics(sourceFile)) {
|
||||
var span = void 0;
|
||||
@ -73412,7 +73434,7 @@ var ts;
|
||||
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
|
||||
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
|
||||
var issuedMemberError = false;
|
||||
var _loop_21 = function (member) {
|
||||
var _loop_22 = function (member) {
|
||||
if (ts.hasStaticModifier(member)) {
|
||||
return "continue";
|
||||
}
|
||||
@ -73431,7 +73453,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
||||
var member = _a[_i];
|
||||
_loop_21(member);
|
||||
_loop_22(member);
|
||||
}
|
||||
if (!issuedMemberError) {
|
||||
// check again with diagnostics to generate a less-specific error
|
||||
@ -74204,7 +74226,6 @@ var ts;
|
||||
}
|
||||
}
|
||||
function checkImportBinding(node) {
|
||||
checkGrammarAwaitIdentifier(node.name);
|
||||
checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
|
||||
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
|
||||
checkAliasSymbol(node);
|
||||
@ -75375,10 +75396,10 @@ var ts;
|
||||
// If this is from nested object binding pattern
|
||||
// for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) {
|
||||
if (expr.parent.kind === 285 /* PropertyAssignment */) {
|
||||
var node_1 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
|
||||
var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_1) || errorType;
|
||||
var propertyIndex = ts.indexOfNode(node_1.properties, expr.parent);
|
||||
return checkObjectLiteralDestructuringPropertyAssignment(node_1, typeOfParentObjectLiteral, propertyIndex);
|
||||
var node_2 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
|
||||
var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_2) || errorType;
|
||||
var propertyIndex = ts.indexOfNode(node_2.properties, expr.parent);
|
||||
return checkObjectLiteralDestructuringPropertyAssignment(node_2, typeOfParentObjectLiteral, propertyIndex);
|
||||
}
|
||||
// Array literal assignment - array destructuring pattern
|
||||
var node = ts.cast(expr.parent, ts.isArrayLiteralExpression);
|
||||
@ -76735,29 +76756,18 @@ var ts;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function checkGrammarAwaitIdentifier(name) {
|
||||
if (name && ts.isIdentifier(name) && name.originalKeywordKind === 130 /* AwaitKeyword */ && isInTopLevelContext(name.parent)) {
|
||||
var file = ts.getSourceFileOfNode(name);
|
||||
if (!file.isDeclarationFile && ts.isExternalModule(file)) {
|
||||
return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.idText(name));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function checkGrammarFunctionLikeDeclaration(node) {
|
||||
// Prevent cascading error by short-circuit
|
||||
var file = ts.getSourceFileOfNode(node);
|
||||
return checkGrammarDecoratorsAndModifiers(node) ||
|
||||
checkGrammarTypeParameterList(node.typeParameters, file) ||
|
||||
(ts.isFunctionDeclaration(node) && checkGrammarAwaitIdentifier(node.name)) ||
|
||||
checkGrammarParameterList(node.parameters) ||
|
||||
checkGrammarArrowFunction(node, file) ||
|
||||
(ts.isFunctionLikeDeclaration(node) && checkGrammarForUseStrictSimpleParameterList(node));
|
||||
}
|
||||
function checkGrammarClassLikeDeclaration(node) {
|
||||
var file = ts.getSourceFileOfNode(node);
|
||||
return (ts.isClassDeclaration(node) && checkGrammarAwaitIdentifier(node.name)) ||
|
||||
checkGrammarClassDeclarationHeritageClauses(node) ||
|
||||
return checkGrammarClassDeclarationHeritageClauses(node) ||
|
||||
checkGrammarTypeParameterList(node.typeParameters, file);
|
||||
}
|
||||
function checkGrammarArrowFunction(node, file) {
|
||||
@ -77327,9 +77337,6 @@ var ts;
|
||||
return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_have_a_property_name);
|
||||
}
|
||||
}
|
||||
if (ts.isIdentifier(node.name) && checkGrammarAwaitIdentifier(node.name)) {
|
||||
return true;
|
||||
}
|
||||
if (node.dotDotDotToken && node.initializer) {
|
||||
// Error on equals token which immediately precedes the initializer
|
||||
return grammarErrorAtPos(node, node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer);
|
||||
@ -77386,9 +77393,6 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ts.isIdentifier(node.name) && checkGrammarAwaitIdentifier(node.name)) {
|
||||
return true;
|
||||
}
|
||||
if (node.exclamationToken && (node.parent.parent.kind !== 229 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) {
|
||||
return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation);
|
||||
}
|
||||
@ -107351,7 +107355,7 @@ var ts;
|
||||
});
|
||||
// Sort by paths closest to importing file Name directory
|
||||
var sortedPaths = [];
|
||||
var _loop_22 = function (directory) {
|
||||
var _loop_23 = function (directory) {
|
||||
var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
|
||||
var pathsInDirectory;
|
||||
allFileNames.forEach(function (canonicalFileName, fileName) {
|
||||
@ -107377,7 +107381,7 @@ var ts;
|
||||
};
|
||||
var out_directory_1;
|
||||
for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) {
|
||||
var state_8 = _loop_22(directory);
|
||||
var state_8 = _loop_23(directory);
|
||||
directory = out_directory_1;
|
||||
if (state_8 === "break")
|
||||
break;
|
||||
|
||||
@ -13811,6 +13811,15 @@ var ts;
|
||||
}
|
||||
}
|
||||
ts.getThisContainer = getThisContainer;
|
||||
function isInTopLevelContext(node) {
|
||||
// The name of a class or function declaration is a BindingIdentifier in its surrounding scope.
|
||||
if (ts.isIdentifier(node) && (ts.isClassDeclaration(node.parent) || ts.isFunctionDeclaration(node.parent)) && node.parent.name === node) {
|
||||
node = node.parent;
|
||||
}
|
||||
var container = getThisContainer(node, /*includeArrowFunctions*/ true);
|
||||
return ts.isSourceFile(container);
|
||||
}
|
||||
ts.isInTopLevelContext = isInTopLevelContext;
|
||||
function getNewTargetContainer(node) {
|
||||
var container = getThisContainer(node, /*includeArrowFunctions*/ false);
|
||||
if (container) {
|
||||
@ -15008,13 +15017,7 @@ var ts;
|
||||
return parent.name === node;
|
||||
case 156 /* QualifiedName */:
|
||||
// Name on right hand side of dot in a type query or type reference
|
||||
if (parent.right === node) {
|
||||
while (parent.kind === 156 /* QualifiedName */) {
|
||||
parent = parent.parent;
|
||||
}
|
||||
return parent.kind === 175 /* TypeQuery */ || parent.kind === 172 /* TypeReference */;
|
||||
}
|
||||
return false;
|
||||
return parent.right === node;
|
||||
case 195 /* BindingElement */:
|
||||
case 262 /* ImportSpecifier */:
|
||||
// Property name in binding element or import specifier
|
||||
@ -27371,31 +27374,6 @@ var ts;
|
||||
createBaseNode: function (kind) { return countNode(new NodeConstructor(kind, /*pos*/ 0, /*end*/ 0)); }
|
||||
};
|
||||
var factory = ts.createNodeFactory(1 /* NoParenthesizerRules */ | 2 /* NoNodeConverters */ | 8 /* NoOriginalNode */, baseNodeFactory);
|
||||
var reparseContext = {
|
||||
get factory() { return factory; },
|
||||
enableEmitNotification: ts.notImplemented,
|
||||
enableSubstitution: ts.notImplemented,
|
||||
endLexicalEnvironment: ts.returnUndefined,
|
||||
getCompilerOptions: ts.notImplemented,
|
||||
getEmitHost: ts.notImplemented,
|
||||
getEmitResolver: ts.notImplemented,
|
||||
getEmitHelperFactory: ts.notImplemented,
|
||||
setLexicalEnvironmentFlags: ts.noop,
|
||||
getLexicalEnvironmentFlags: function () { return 0; },
|
||||
hoistFunctionDeclaration: ts.notImplemented,
|
||||
hoistVariableDeclaration: ts.notImplemented,
|
||||
addInitializationStatement: ts.notImplemented,
|
||||
isEmitNotificationEnabled: ts.notImplemented,
|
||||
isSubstitutionEnabled: ts.notImplemented,
|
||||
onEmitNode: ts.notImplemented,
|
||||
onSubstituteNode: ts.notImplemented,
|
||||
readEmitHelpers: ts.notImplemented,
|
||||
requestEmitHelper: ts.notImplemented,
|
||||
resumeLexicalEnvironment: ts.noop,
|
||||
startLexicalEnvironment: ts.noop,
|
||||
suspendLexicalEnvironment: ts.noop,
|
||||
addDiagnostic: ts.notImplemented,
|
||||
};
|
||||
var fileName;
|
||||
var sourceFlags;
|
||||
var sourceText;
|
||||
@ -27459,6 +27437,8 @@ var ts;
|
||||
// parsing. These context flags are naturally stored and restored through normal recursive
|
||||
// descent parsing and unwinding.
|
||||
var contextFlags;
|
||||
// Indicates whether we are currently parsing top-level statements.
|
||||
var topLevel = true;
|
||||
// Whether or not we've had a parse error since creating the last AST node. If we have
|
||||
// encountered an error, it will be stored on the next AST node we create. Parse errors
|
||||
// can be broken down into three categories:
|
||||
@ -27602,6 +27582,7 @@ var ts;
|
||||
identifierCount = 0;
|
||||
nodeCount = 0;
|
||||
sourceFlags = 0;
|
||||
topLevel = true;
|
||||
switch (scriptKind) {
|
||||
case 1 /* JS */:
|
||||
case 2 /* JSX */:
|
||||
@ -27638,6 +27619,7 @@ var ts;
|
||||
parsingContext = 0;
|
||||
identifiers = undefined;
|
||||
notParenthesizedArrow = undefined;
|
||||
topLevel = true;
|
||||
}
|
||||
function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind) {
|
||||
var isDeclarationFile = isDeclarationFileName(fileName);
|
||||
@ -27686,108 +27668,98 @@ var ts;
|
||||
return node;
|
||||
}
|
||||
function reparseTopLevelAwait(sourceFile) {
|
||||
return ts.visitEachChild(sourceFile, visitor, reparseContext);
|
||||
function visitor(node) {
|
||||
if (!(node.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */)) {
|
||||
return node;
|
||||
var savedSyntaxCursor = syntaxCursor;
|
||||
var baseSyntaxCursor = IncrementalParser.createSyntaxCursor(sourceFile);
|
||||
syntaxCursor = { currentNode: currentNode };
|
||||
var statements = [];
|
||||
var savedParseDiagnostics = parseDiagnostics;
|
||||
parseDiagnostics = [];
|
||||
var pos = 0;
|
||||
var start = findNextStatementWithAwait(sourceFile.statements, 0);
|
||||
var _loop_3 = function () {
|
||||
// append all statements between pos and start
|
||||
var prevStatement = sourceFile.statements[pos];
|
||||
var nextStatement = sourceFile.statements[start];
|
||||
ts.addRange(statements, sourceFile.statements, pos, start);
|
||||
pos = findNextStatementWithoutAwait(sourceFile.statements, start);
|
||||
// append all diagnostics associated with the copied range
|
||||
var diagnosticStart = ts.findIndex(savedParseDiagnostics, function (diagnostic) { return diagnostic.start >= prevStatement.pos; });
|
||||
var diagnosticEnd = diagnosticStart >= 0 ? ts.findIndex(savedParseDiagnostics, function (diagnostic) { return diagnostic.start >= nextStatement.pos; }, diagnosticStart) : -1;
|
||||
if (diagnosticStart >= 0) {
|
||||
ts.addRange(parseDiagnostics, savedParseDiagnostics, diagnosticStart, diagnosticEnd >= 0 ? diagnosticEnd : undefined);
|
||||
}
|
||||
// We explicitly visit each non-Expression node that has an immediate Expression child so that
|
||||
// we can reparse the Expression in an Await context
|
||||
switch (node.kind) {
|
||||
case 160 /* Decorator */: return reparseDecorator(node);
|
||||
case 157 /* ComputedPropertyName */: return reparseComputedPropertyName(node);
|
||||
case 220 /* ExpressionWithTypeArguments */: return reparseExpressionWithTypeArguments(node);
|
||||
case 230 /* ExpressionStatement */: return reparseExpressionStatement(node);
|
||||
case 231 /* IfStatement */: return reparseIfStatement(node);
|
||||
case 241 /* SwitchStatement */: return reparseSwitchStatement(node);
|
||||
case 240 /* WithStatement */: return reparseWithStatement(node);
|
||||
case 232 /* DoStatement */: return reparseDoStatement(node);
|
||||
case 233 /* WhileStatement */: return reparseWhileStatement(node);
|
||||
case 234 /* ForStatement */: return reparseForStatement(node);
|
||||
case 235 /* ForInStatement */: return reparseForInStatement(node);
|
||||
case 236 /* ForOfStatement */: return reparseForOfStatement(node);
|
||||
case 239 /* ReturnStatement */: return reparseReturnStatement(node);
|
||||
case 243 /* ThrowStatement */: return reparseThrowStatement(node);
|
||||
case 263 /* ExportAssignment */: return reparseExportAssignment(node);
|
||||
case 246 /* VariableDeclaration */: return reparseVariableDeclaration(node);
|
||||
case 195 /* BindingElement */: return reparseBindingElement(node);
|
||||
default: return ts.visitEachChild(node, visitor, reparseContext);
|
||||
// reparse all statements between start and pos. We skip existing diagnostics for the same range and allow the parser to generate new ones.
|
||||
speculationHelper(function () {
|
||||
var savedContextFlags = contextFlags;
|
||||
contextFlags |= 32768 /* AwaitContext */;
|
||||
scanner.setTextPos(nextStatement.pos);
|
||||
nextToken();
|
||||
while (token() !== 1 /* EndOfFileToken */) {
|
||||
var startPos = scanner.getStartPos();
|
||||
var statement = parseListElement(0 /* SourceElements */, parseStatement);
|
||||
statements.push(statement);
|
||||
if (startPos === scanner.getStartPos()) {
|
||||
nextToken();
|
||||
}
|
||||
if (pos >= 0) {
|
||||
var nonAwaitStatement = sourceFile.statements[pos];
|
||||
if (statement.end === nonAwaitStatement.pos) {
|
||||
// done reparsing this section
|
||||
break;
|
||||
}
|
||||
if (statement.end > nonAwaitStatement.pos) {
|
||||
// we ate into the next statement, so we must reparse it.
|
||||
pos = findNextStatementWithoutAwait(sourceFile.statements, pos + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
contextFlags = savedContextFlags;
|
||||
}, 2 /* Reparse */);
|
||||
// find the next statement containing an `await`
|
||||
start = pos >= 0 ? findNextStatementWithAwait(sourceFile.statements, pos) : -1;
|
||||
};
|
||||
while (start !== -1) {
|
||||
_loop_3();
|
||||
}
|
||||
// append all statements between pos and the end of the list
|
||||
if (pos >= 0) {
|
||||
var prevStatement_1 = sourceFile.statements[pos];
|
||||
ts.addRange(statements, sourceFile.statements, pos);
|
||||
// append all diagnostics associated with the copied range
|
||||
var diagnosticStart = ts.findIndex(savedParseDiagnostics, function (diagnostic) { return diagnostic.start >= prevStatement_1.pos; });
|
||||
if (diagnosticStart >= 0) {
|
||||
ts.addRange(parseDiagnostics, savedParseDiagnostics, diagnosticStart);
|
||||
}
|
||||
}
|
||||
function reparse(node, parse) {
|
||||
if (node && node.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */) {
|
||||
if (ts.isExpression(node)) {
|
||||
return speculationHelper(function () {
|
||||
scanner.setTextPos(node.pos);
|
||||
var savedContextFlags = contextFlags;
|
||||
contextFlags = node.flags & 25358336 /* ContextFlags */;
|
||||
nextToken();
|
||||
var result = doInAwaitContext(parse);
|
||||
contextFlags = savedContextFlags;
|
||||
return result;
|
||||
}, 2 /* Reparse */);
|
||||
syntaxCursor = savedSyntaxCursor;
|
||||
return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements));
|
||||
function containsPossibleTopLevelAwait(node) {
|
||||
return !(node.flags & 32768 /* AwaitContext */)
|
||||
&& !!(node.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */);
|
||||
}
|
||||
function findNextStatementWithAwait(statements, start) {
|
||||
for (var i = start; i < statements.length; i++) {
|
||||
if (containsPossibleTopLevelAwait(statements[i])) {
|
||||
return i;
|
||||
}
|
||||
return ts.visitEachChild(node, visitor, reparseContext);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
function findNextStatementWithoutAwait(statements, start) {
|
||||
for (var i = start; i < statements.length; i++) {
|
||||
if (!containsPossibleTopLevelAwait(statements[i])) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
function currentNode(position) {
|
||||
var node = baseSyntaxCursor.currentNode(position);
|
||||
if (topLevel && node && containsPossibleTopLevelAwait(node)) {
|
||||
node.intersectsChange = true;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
function update(updated, original) {
|
||||
if (updated !== original) {
|
||||
ts.setNodeFlags(updated, updated.flags | 32768 /* AwaitContext */);
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
function reparseExpressionStatement(node) {
|
||||
return update(factory.updateExpressionStatement(node, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseReturnStatement(node) {
|
||||
return update(factory.updateReturnStatement(node, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseThrowStatement(node) {
|
||||
return update(factory.updateThrowStatement(node, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseIfStatement(node) {
|
||||
return update(factory.updateIfStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.thenStatement, visitor), ts.visitNode(node.elseStatement, visitor)), node);
|
||||
}
|
||||
function reparseSwitchStatement(node) {
|
||||
return update(factory.updateSwitchStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.caseBlock, visitor)), node);
|
||||
}
|
||||
function reparseWithStatement(node) {
|
||||
return update(factory.updateWithStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
|
||||
}
|
||||
function reparseDoStatement(node) {
|
||||
return update(factory.updateDoStatement(node, ts.visitNode(node.statement, visitor), reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseWhileStatement(node) {
|
||||
return update(factory.updateWhileStatement(node, reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
|
||||
}
|
||||
function reparseForStatement(node) {
|
||||
return update(factory.updateForStatement(node, reparse(node.initializer, parseExpression), reparse(node.condition, parseExpression), reparse(node.incrementor, parseExpression), ts.visitNode(node, visitor)), node);
|
||||
}
|
||||
function reparseForInStatement(node) {
|
||||
return update(factory.updateForInStatement(node, reparse(node.initializer, parseExpression), reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
|
||||
}
|
||||
function reparseForOfStatement(node) {
|
||||
return update(factory.updateForOfStatement(node, node.awaitModifier, reparse(node.initializer, parseExpression), reparse(node.expression, parseExpression), ts.visitNode(node.statement, visitor)), node);
|
||||
}
|
||||
function reparseExportAssignment(node) {
|
||||
return update(factory.updateExportAssignment(node, ts.visitNodes(node.decorators, visitor), node.modifiers, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseExpressionWithTypeArguments(node) {
|
||||
return update(factory.updateExpressionWithTypeArguments(node, reparse(node.expression, parseLeftHandSideExpressionOrHigher), node.typeArguments), node);
|
||||
}
|
||||
function reparseDecorator(node) {
|
||||
return update(factory.updateDecorator(node, reparse(node.expression, parseLeftHandSideExpressionOrHigher)), node);
|
||||
}
|
||||
function reparseComputedPropertyName(node) {
|
||||
return update(factory.updateComputedPropertyName(node, reparse(node.expression, parseExpression)), node);
|
||||
}
|
||||
function reparseVariableDeclaration(node) {
|
||||
return update(factory.updateVariableDeclaration(node, ts.visitNode(node.name, visitor), node.exclamationToken, node.type, reparse(node.initializer, parseExpression)), node);
|
||||
}
|
||||
function reparseBindingElement(node) {
|
||||
return update(factory.updateBindingElement(node, node.dotDotDotToken, ts.visitNode(node.propertyName, visitor), ts.visitNode(node.name, visitor), reparse(node.initializer, parseExpression)), node);
|
||||
}
|
||||
}
|
||||
function fixupParentReferences(rootNode) {
|
||||
// normally parent references are set during binding. However, for clients that only need
|
||||
@ -28037,6 +28009,12 @@ var ts;
|
||||
function tryParse(callback) {
|
||||
return speculationHelper(callback, 0 /* TryParse */);
|
||||
}
|
||||
function isBindingIdentifier() {
|
||||
if (token() === 78 /* Identifier */) {
|
||||
return true;
|
||||
}
|
||||
return token() > 115 /* LastReservedWord */;
|
||||
}
|
||||
// Ignore strict mode flag because we will report an error in type checker instead.
|
||||
function isIdentifier() {
|
||||
if (token() === 78 /* Identifier */) {
|
||||
@ -28206,6 +28184,9 @@ var ts;
|
||||
ts.Diagnostics.Identifier_expected;
|
||||
return createMissingNode(78 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg);
|
||||
}
|
||||
function parseBindingIdentifier(privateIdentifierDiagnosticMessage) {
|
||||
return createIdentifier(isBindingIdentifier(), /*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage);
|
||||
}
|
||||
function parseIdentifier(diagnosticMessage, privateIdentifierDiagnosticMessage) {
|
||||
return createIdentifier(isIdentifier(), diagnosticMessage, privateIdentifierDiagnosticMessage);
|
||||
}
|
||||
@ -28383,9 +28364,9 @@ var ts;
|
||||
return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword();
|
||||
}
|
||||
case 8 /* VariableDeclarations */:
|
||||
return isIdentifierOrPrivateIdentifierOrPattern();
|
||||
return isBindingIdentifierOrPrivateIdentifierOrPattern();
|
||||
case 10 /* ArrayBindingElements */:
|
||||
return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isIdentifierOrPrivateIdentifierOrPattern();
|
||||
return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern();
|
||||
case 19 /* TypeParameters */:
|
||||
return isIdentifier();
|
||||
case 15 /* ArrayLiteralMembers */:
|
||||
@ -29227,7 +29208,7 @@ var ts;
|
||||
}
|
||||
function isStartOfParameter(isJSDocParameter) {
|
||||
return token() === 25 /* DotDotDotToken */ ||
|
||||
isIdentifierOrPrivateIdentifierOrPattern() ||
|
||||
isBindingIdentifierOrPrivateIdentifierOrPattern() ||
|
||||
ts.isModifierKind(token()) ||
|
||||
token() === 59 /* AtToken */ ||
|
||||
isStartOfType(/*inStartOfParameter*/ !isJSDocParameter);
|
||||
@ -29249,22 +29230,34 @@ var ts;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
function parseParameterInOuterAwaitContext() {
|
||||
return parseParameterWorker(/*inOuterAwaitContext*/ true);
|
||||
}
|
||||
function parseParameter() {
|
||||
return parseParameterWorker(/*inOuterAwaitContext*/ false);
|
||||
}
|
||||
function parseParameterWorker(inOuterAwaitContext) {
|
||||
var pos = getNodePos();
|
||||
var hasJSDoc = hasPrecedingJSDocComment();
|
||||
if (token() === 107 /* ThisKeyword */) {
|
||||
var node = factory.createParameterDeclaration(
|
||||
var node_1 = factory.createParameterDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
/*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true),
|
||||
/*questionToken*/ undefined, parseTypeAnnotation(),
|
||||
/*initializer*/ undefined);
|
||||
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
||||
return withJSDoc(finishNode(node_1, pos), hasJSDoc);
|
||||
}
|
||||
// FormalParameter [Yield,Await]:
|
||||
// BindingElement[?Yield,?Await]
|
||||
var modifiers;
|
||||
return withJSDoc(finishNode(factory.createParameterDeclaration(parseDecorators(), modifiers = parseModifiers(), parseOptionalToken(25 /* DotDotDotToken */), parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc);
|
||||
// Decorators are parsed in the outer [Await] context, the rest of the parameter is parsed in the function's [Await] context.
|
||||
var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators();
|
||||
var savedTopLevel = topLevel;
|
||||
topLevel = false;
|
||||
var modifiers = parseModifiers();
|
||||
var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, parseOptionalToken(25 /* DotDotDotToken */), parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc);
|
||||
topLevel = savedTopLevel;
|
||||
return node;
|
||||
}
|
||||
function parseReturnType(returnToken, isType) {
|
||||
if (shouldParseReturnType(returnToken, isType)) {
|
||||
@ -29307,7 +29300,7 @@ var ts;
|
||||
setAwaitContext(!!(flags & 2 /* Await */));
|
||||
var parameters = flags & 32 /* JSDoc */ ?
|
||||
parseDelimitedList(17 /* JSDocParameters */, parseJSDocParameter) :
|
||||
parseDelimitedList(16 /* Parameters */, parseParameter);
|
||||
parseDelimitedList(16 /* Parameters */, savedAwaitContext ? parseParameterInOuterAwaitContext : parseParameter);
|
||||
setYieldContext(savedYieldContext);
|
||||
setAwaitContext(savedAwaitContext);
|
||||
return parameters;
|
||||
@ -30436,9 +30429,13 @@ var ts;
|
||||
// Note: even when 'IgnoreMissingOpenBrace' is passed, parseBody will still error.
|
||||
return parseFunctionBlock(16 /* IgnoreMissingOpenBrace */ | (isAsync ? 2 /* Await */ : 0 /* None */));
|
||||
}
|
||||
return isAsync
|
||||
var savedTopLevel = topLevel;
|
||||
topLevel = false;
|
||||
var node = isAsync
|
||||
? doInAwaitContext(parseAssignmentExpressionOrHigher)
|
||||
: doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
|
||||
topLevel = savedTopLevel;
|
||||
return node;
|
||||
}
|
||||
function parseConditionalExpressionRest(leftOperand, pos) {
|
||||
// Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher.
|
||||
@ -31429,10 +31426,10 @@ var ts;
|
||||
var asteriskToken = parseOptionalToken(41 /* AsteriskToken */);
|
||||
var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */;
|
||||
var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */;
|
||||
var name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) :
|
||||
isGenerator ? doInYieldContext(parseOptionalIdentifier) :
|
||||
isAsync ? doInAwaitContext(parseOptionalIdentifier) :
|
||||
parseOptionalIdentifier();
|
||||
var name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalBindingIdentifier) :
|
||||
isGenerator ? doInYieldContext(parseOptionalBindingIdentifier) :
|
||||
isAsync ? doInAwaitContext(parseOptionalBindingIdentifier) :
|
||||
parseOptionalBindingIdentifier();
|
||||
var typeParameters = parseTypeParameters();
|
||||
var parameters = parseParameters(isGenerator | isAsync);
|
||||
var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
|
||||
@ -31443,8 +31440,8 @@ var ts;
|
||||
var node = factory.createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body);
|
||||
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
||||
}
|
||||
function parseOptionalIdentifier() {
|
||||
return isIdentifier() ? parseIdentifier() : undefined;
|
||||
function parseOptionalBindingIdentifier() {
|
||||
return isBindingIdentifier() ? parseBindingIdentifier() : undefined;
|
||||
}
|
||||
function parseNewExpressionOrNewDotTarget() {
|
||||
var pos = getNodePos();
|
||||
@ -31500,6 +31497,8 @@ var ts;
|
||||
setYieldContext(!!(flags & 1 /* Yield */));
|
||||
var savedAwaitContext = inAwaitContext();
|
||||
setAwaitContext(!!(flags & 2 /* Await */));
|
||||
var savedTopLevel = topLevel;
|
||||
topLevel = false;
|
||||
// We may be in a [Decorator] context when parsing a function expression or
|
||||
// arrow function. The body of the function is not in [Decorator] context.
|
||||
var saveDecoratorContext = inDecoratorContext();
|
||||
@ -31510,6 +31509,7 @@ var ts;
|
||||
if (saveDecoratorContext) {
|
||||
setDecoratorContext(/*val*/ true);
|
||||
}
|
||||
topLevel = savedTopLevel;
|
||||
setYieldContext(savedYieldContext);
|
||||
setAwaitContext(savedAwaitContext);
|
||||
return block;
|
||||
@ -32068,7 +32068,7 @@ var ts;
|
||||
function parseObjectBindingElement() {
|
||||
var pos = getNodePos();
|
||||
var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */);
|
||||
var tokenIsIdentifier = isIdentifier();
|
||||
var tokenIsIdentifier = isBindingIdentifier();
|
||||
var propertyName = parsePropertyName();
|
||||
var name;
|
||||
if (tokenIsIdentifier && token() !== 58 /* ColonToken */) {
|
||||
@ -32096,11 +32096,11 @@ var ts;
|
||||
parseExpected(23 /* CloseBracketToken */);
|
||||
return finishNode(factory.createArrayBindingPattern(elements), pos);
|
||||
}
|
||||
function isIdentifierOrPrivateIdentifierOrPattern() {
|
||||
function isBindingIdentifierOrPrivateIdentifierOrPattern() {
|
||||
return token() === 18 /* OpenBraceToken */
|
||||
|| token() === 22 /* OpenBracketToken */
|
||||
|| token() === 79 /* PrivateIdentifier */
|
||||
|| isIdentifier();
|
||||
|| isBindingIdentifier();
|
||||
}
|
||||
function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) {
|
||||
if (token() === 22 /* OpenBracketToken */) {
|
||||
@ -32109,7 +32109,7 @@ var ts;
|
||||
if (token() === 18 /* OpenBraceToken */) {
|
||||
return parseObjectBindingPattern();
|
||||
}
|
||||
return parseIdentifier(/*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage);
|
||||
return parseBindingIdentifier(privateIdentifierDiagnosticMessage);
|
||||
}
|
||||
function parseVariableDeclarationAllowExclamation() {
|
||||
return parseVariableDeclaration(/*allowExclamation*/ true);
|
||||
@ -32181,7 +32181,7 @@ var ts;
|
||||
parseExpected(97 /* FunctionKeyword */);
|
||||
var asteriskToken = parseOptionalToken(41 /* AsteriskToken */);
|
||||
// We don't parse the name here in await context, instead we will report a grammar error in the checker.
|
||||
var name = modifierFlags & 512 /* Default */ ? parseOptionalIdentifier() : parseIdentifier();
|
||||
var name = modifierFlags & 512 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier();
|
||||
var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */;
|
||||
var isAsync = modifierFlags & 256 /* Async */ ? 2 /* Await */ : 0 /* None */;
|
||||
var typeParameters = parseTypeParameters();
|
||||
@ -32325,12 +32325,24 @@ var ts;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function parseDecoratorExpression() {
|
||||
if (inAwaitContext() && token() === 130 /* AwaitKeyword */) {
|
||||
// `@await` is is disallowed in an [Await] context, but can cause parsing to go off the rails
|
||||
// This simply parses the missing identifier and moves on.
|
||||
var pos = getNodePos();
|
||||
var awaitExpression = parseIdentifier(ts.Diagnostics.Expression_expected);
|
||||
nextToken();
|
||||
var memberExpression = parseMemberExpressionRest(pos, awaitExpression, /*allowOptionalChain*/ true);
|
||||
return parseCallExpressionRest(pos, memberExpression);
|
||||
}
|
||||
return parseLeftHandSideExpressionOrHigher();
|
||||
}
|
||||
function tryParseDecorator() {
|
||||
var pos = getNodePos();
|
||||
if (!parseOptional(59 /* AtToken */)) {
|
||||
return undefined;
|
||||
}
|
||||
var expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher);
|
||||
var expression = doInDecoratorContext(parseDecoratorExpression);
|
||||
return finishNode(factory.createDecorator(expression), pos);
|
||||
}
|
||||
function parseDecorators() {
|
||||
@ -32471,8 +32483,8 @@ var ts;
|
||||
// - class expression with omitted name, 'implements' starts heritage clause
|
||||
// - class with name 'implements'
|
||||
// 'isImplementsClause' helps to disambiguate between these two cases
|
||||
return isIdentifier() && !isImplementsClause()
|
||||
? parseIdentifier()
|
||||
return isBindingIdentifier() && !isImplementsClause()
|
||||
? createIdentifier(isBindingIdentifier())
|
||||
: undefined;
|
||||
}
|
||||
function isImplementsClause() {
|
||||
@ -34268,6 +34280,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
IncrementalParser.createSyntaxCursor = createSyntaxCursor;
|
||||
var InvalidPosition;
|
||||
(function (InvalidPosition) {
|
||||
InvalidPosition[InvalidPosition["Value"] = -1] = "Value";
|
||||
@ -36054,7 +36067,7 @@ var ts;
|
||||
}
|
||||
function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) {
|
||||
var result = returnValue ? {} : undefined;
|
||||
var _loop_3 = function (element) {
|
||||
var _loop_4 = function (element) {
|
||||
if (element.kind !== 285 /* PropertyAssignment */) {
|
||||
errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected));
|
||||
return "continue";
|
||||
@ -36107,7 +36120,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
|
||||
var element = _a[_i];
|
||||
_loop_3(element);
|
||||
_loop_4(element);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -36290,7 +36303,7 @@ var ts;
|
||||
var optionsNameMap = _a.optionsNameMap;
|
||||
var result = ts.createMap();
|
||||
var getCanonicalFileName = pathOptions && ts.createGetCanonicalFileName(pathOptions.useCaseSensitiveFileNames);
|
||||
var _loop_4 = function (name) {
|
||||
var _loop_5 = function (name) {
|
||||
if (ts.hasProperty(options, name)) {
|
||||
// tsconfig only options cannot be specified via command line,
|
||||
// so we can assume that only types that can appear here string | number | boolean
|
||||
@ -36324,7 +36337,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var name in options) {
|
||||
_loop_4(name);
|
||||
_loop_5(name);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -37085,7 +37098,7 @@ var ts;
|
||||
}
|
||||
var jsonOnlyIncludeRegexes;
|
||||
if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) {
|
||||
var _loop_5 = function (file) {
|
||||
var _loop_6 = function (file) {
|
||||
if (ts.fileExtensionIs(file, ".json" /* Json */)) {
|
||||
// Valid only if *.json specified
|
||||
if (!jsonOnlyIncludeRegexes) {
|
||||
@ -37123,7 +37136,7 @@ var ts;
|
||||
};
|
||||
for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensionsWithJsonIfResolveJsonModule, validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined); _a < _b.length; _a++) {
|
||||
var file = _b[_a];
|
||||
_loop_5(file);
|
||||
_loop_6(file);
|
||||
}
|
||||
}
|
||||
var literalFiles = ts.arrayFrom(literalFileMap.values());
|
||||
@ -40530,18 +40543,31 @@ var ts;
|
||||
currentFlow = saveCurrentFlow;
|
||||
}
|
||||
// The binder visits every node in the syntax tree so it is a convenient place to perform a single localized
|
||||
// check for reserved words used as identifiers in strict mode code.
|
||||
function checkStrictModeIdentifier(node) {
|
||||
if (inStrictMode &&
|
||||
node.originalKeywordKind >= 116 /* FirstFutureReservedWord */ &&
|
||||
node.originalKeywordKind <= 124 /* LastFutureReservedWord */ &&
|
||||
!ts.isIdentifierName(node) &&
|
||||
// check for reserved words used as identifiers in strict mode code, as well as `yield` or `await` in
|
||||
// [Yield] or [Await] contexts, respectively.
|
||||
function checkContextualIdentifier(node) {
|
||||
// Report error only if there are no parse errors in file
|
||||
if (!file.parseDiagnostics.length &&
|
||||
!(node.flags & 8388608 /* Ambient */) &&
|
||||
!(node.flags & 4194304 /* JSDoc */)) {
|
||||
// Report error only if there are no parse errors in file
|
||||
if (!file.parseDiagnostics.length) {
|
||||
!(node.flags & 4194304 /* JSDoc */) &&
|
||||
!ts.isIdentifierName(node)) {
|
||||
// strict mode identifiers
|
||||
if (inStrictMode &&
|
||||
node.originalKeywordKind >= 116 /* FirstFutureReservedWord */ &&
|
||||
node.originalKeywordKind <= 124 /* LastFutureReservedWord */) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node)));
|
||||
}
|
||||
else if (node.originalKeywordKind === 130 /* AwaitKeyword */) {
|
||||
if (ts.isExternalModule(file) && ts.isInTopLevelContext(node)) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.declarationNameToString(node)));
|
||||
}
|
||||
else if (node.flags & 32768 /* AwaitContext */) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node)));
|
||||
}
|
||||
}
|
||||
else if (node.originalKeywordKind === 124 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node)));
|
||||
}
|
||||
}
|
||||
}
|
||||
function getStrictModeIdentifierMessage(node) {
|
||||
@ -40808,7 +40834,7 @@ var ts;
|
||||
if (currentFlow && (ts.isExpression(node) || parent.kind === 286 /* ShorthandPropertyAssignment */)) {
|
||||
node.flowNode = currentFlow;
|
||||
}
|
||||
return checkStrictModeIdentifier(node);
|
||||
return checkContextualIdentifier(node);
|
||||
case 105 /* SuperKeyword */:
|
||||
node.flowNode = currentFlow;
|
||||
break;
|
||||
@ -43004,7 +43030,7 @@ var ts;
|
||||
function addDuplicateDeclarationError(node, message, symbolName, relatedNodes) {
|
||||
var errorNode = (ts.getExpandoInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getNameOfExpando(node) : ts.getNameOfDeclaration(node)) || node;
|
||||
var err = lookupOrIssueError(errorNode, message, symbolName);
|
||||
var _loop_6 = function (relatedNode) {
|
||||
var _loop_7 = function (relatedNode) {
|
||||
var adjustedNode = (ts.getExpandoInitializer(relatedNode, /*isPrototypeAssignment*/ false) ? ts.getNameOfExpando(relatedNode) : ts.getNameOfDeclaration(relatedNode)) || relatedNode;
|
||||
if (adjustedNode === errorNode)
|
||||
return "continue";
|
||||
@ -43017,7 +43043,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, _a = relatedNodes || ts.emptyArray; _i < _a.length; _i++) {
|
||||
var relatedNode = _a[_i];
|
||||
_loop_6(relatedNode);
|
||||
_loop_7(relatedNode);
|
||||
}
|
||||
}
|
||||
function combineSymbolTables(first, second) {
|
||||
@ -45258,7 +45284,7 @@ var ts;
|
||||
}
|
||||
function forEachSymbolTableInScope(enclosingDeclaration, callback) {
|
||||
var result;
|
||||
var _loop_7 = function (location) {
|
||||
var _loop_8 = function (location) {
|
||||
// Locals of a source file are not in scope (because they get merged into the global symbol table)
|
||||
if (location.locals && !isGlobalSourceFile(location)) {
|
||||
if (result = callback(location.locals)) {
|
||||
@ -45304,7 +45330,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var location = enclosingDeclaration; location; location = location.parent) {
|
||||
var state_2 = _loop_7(location);
|
||||
var state_2 = _loop_8(location);
|
||||
if (typeof state_2 === "object")
|
||||
return state_2.value;
|
||||
}
|
||||
@ -47314,7 +47340,7 @@ var ts;
|
||||
if (ts.length(reexports) > 1) {
|
||||
var groups = ts.group(reexports, function (decl) { return ts.isStringLiteral(decl.moduleSpecifier) ? ">" + decl.moduleSpecifier.text : ">"; });
|
||||
if (groups.length !== reexports.length) {
|
||||
var _loop_8 = function (group_1) {
|
||||
var _loop_9 = function (group_1) {
|
||||
if (group_1.length > 1) {
|
||||
// remove group members from statements and then merge group members and add back to statements
|
||||
statements = __spreadArrays(ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), [
|
||||
@ -47327,7 +47353,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) {
|
||||
var group_1 = groups_1[_i];
|
||||
_loop_8(group_1);
|
||||
_loop_9(group_1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -50839,7 +50865,7 @@ var ts;
|
||||
// signatures from the type, whose ordering would be non-obvious)
|
||||
var masterList = signatureLists[indexWithLengthOverOne !== undefined ? indexWithLengthOverOne : 0];
|
||||
var results = masterList.slice();
|
||||
var _loop_9 = function (signatures) {
|
||||
var _loop_10 = function (signatures) {
|
||||
if (signatures !== masterList) {
|
||||
var signature_1 = signatures[0];
|
||||
ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass");
|
||||
@ -50851,7 +50877,7 @@ var ts;
|
||||
};
|
||||
for (var _b = 0, signatureLists_1 = signatureLists; _b < signatureLists_1.length; _b++) {
|
||||
var signatures = signatureLists_1[_b];
|
||||
var state_3 = _loop_9(signatures);
|
||||
var state_3 = _loop_10(signatures);
|
||||
if (state_3 === "break")
|
||||
break;
|
||||
}
|
||||
@ -50975,7 +51001,7 @@ var ts;
|
||||
var types = type.types;
|
||||
var mixinFlags = findMixins(types);
|
||||
var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; });
|
||||
var _loop_10 = function (i) {
|
||||
var _loop_11 = function (i) {
|
||||
var t = type.types[i];
|
||||
// When an intersection type contains mixin constructor types, the construct signatures from
|
||||
// those types are discarded and their return types are mixed into the return types of all
|
||||
@ -50998,19 +51024,19 @@ var ts;
|
||||
numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1 /* Number */));
|
||||
};
|
||||
for (var i = 0; i < types.length; i++) {
|
||||
_loop_10(i);
|
||||
_loop_11(i);
|
||||
}
|
||||
setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo);
|
||||
}
|
||||
function appendSignatures(signatures, newSignatures) {
|
||||
var _loop_11 = function (sig) {
|
||||
var _loop_12 = function (sig) {
|
||||
if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, compareTypesIdentical); })) {
|
||||
signatures = ts.append(signatures, sig);
|
||||
}
|
||||
};
|
||||
for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) {
|
||||
var sig = newSignatures_1[_i];
|
||||
_loop_11(sig);
|
||||
_loop_12(sig);
|
||||
}
|
||||
return signatures;
|
||||
}
|
||||
@ -53297,7 +53323,7 @@ var ts;
|
||||
var expandedDeclarations = [];
|
||||
var optionalIndex = -1;
|
||||
var restTypes;
|
||||
var _loop_12 = function (i) {
|
||||
var _loop_13 = function (i) {
|
||||
var type = elementTypes[i];
|
||||
var flags = target.elementFlags[i];
|
||||
if (flags & 8 /* Variadic */) {
|
||||
@ -53320,7 +53346,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var i = 0; i < elementTypes.length; i++) {
|
||||
_loop_12(i);
|
||||
_loop_13(i);
|
||||
}
|
||||
if (restTypes) {
|
||||
// Create a union of the collected rest element types.
|
||||
@ -54370,7 +54396,7 @@ var ts;
|
||||
function getConditionalType(root, mapper) {
|
||||
var result;
|
||||
var extraTypes;
|
||||
var _loop_13 = function () {
|
||||
var _loop_14 = function () {
|
||||
var checkType = instantiateType(root.checkType, mapper);
|
||||
var checkTypeInstantiable = isGenericObjectType(checkType) || isGenericIndexType(checkType);
|
||||
var extendsType = instantiateType(root.extendsType, mapper);
|
||||
@ -54444,7 +54470,7 @@ var ts;
|
||||
// types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
|
||||
// purposes of resolution. This means such types aren't subject to the instatiation depth limiter.
|
||||
while (true) {
|
||||
var state_4 = _loop_13();
|
||||
var state_4 = _loop_14();
|
||||
if (typeof state_4 === "object")
|
||||
return state_4.value;
|
||||
if (state_4 === "break")
|
||||
@ -56922,7 +56948,7 @@ var ts;
|
||||
reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
|
||||
checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget];
|
||||
}
|
||||
var _loop_14 = function (prop) {
|
||||
var _loop_15 = function (prop) {
|
||||
if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
|
||||
if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
|
||||
if (reportErrors) {
|
||||
@ -56985,7 +57011,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) {
|
||||
var prop = _a[_i];
|
||||
var state_5 = _loop_14(prop);
|
||||
var state_5 = _loop_15(prop);
|
||||
if (typeof state_5 === "object")
|
||||
return state_5.value;
|
||||
}
|
||||
@ -57658,11 +57684,11 @@ var ts;
|
||||
// constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
|
||||
var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
|
||||
var matchingTypes = [];
|
||||
var _loop_15 = function (combination) {
|
||||
var _loop_16 = function (combination) {
|
||||
var hasMatch = false;
|
||||
outer: for (var _i = 0, _a = target.types; _i < _a.length; _i++) {
|
||||
var type = _a[_i];
|
||||
var _loop_16 = function (i) {
|
||||
var _loop_17 = function (i) {
|
||||
var sourceProperty = sourcePropertiesFiltered[i];
|
||||
var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
|
||||
if (!targetProperty)
|
||||
@ -57678,7 +57704,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
|
||||
var state_7 = _loop_16(i);
|
||||
var state_7 = _loop_17(i);
|
||||
switch (state_7) {
|
||||
case "continue-outer": continue outer;
|
||||
}
|
||||
@ -57692,7 +57718,7 @@ var ts;
|
||||
};
|
||||
for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
|
||||
var combination = discriminantCombinations_1[_a];
|
||||
var state_6 = _loop_15(combination);
|
||||
var state_6 = _loop_16(combination);
|
||||
if (typeof state_6 === "object")
|
||||
return state_6.value;
|
||||
}
|
||||
@ -58334,7 +58360,7 @@ var ts;
|
||||
// The emptyArray singleton is used to signal a recursive invocation.
|
||||
cache.variances = ts.emptyArray;
|
||||
variances = [];
|
||||
var _loop_17 = function (tp) {
|
||||
var _loop_18 = function (tp) {
|
||||
var unmeasurable = false;
|
||||
var unreliable = false;
|
||||
var oldHandler = outofbandVarianceMarkerHandler;
|
||||
@ -58366,7 +58392,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) {
|
||||
var tp = typeParameters_1[_i];
|
||||
_loop_17(tp);
|
||||
_loop_18(tp);
|
||||
}
|
||||
cache.variances = variances;
|
||||
}
|
||||
@ -65849,7 +65875,7 @@ var ts;
|
||||
if (spreadIndex >= 0) {
|
||||
// Create synthetic arguments from spreads of tuple types.
|
||||
var effectiveArgs_1 = args.slice(0, spreadIndex);
|
||||
var _loop_18 = function (i) {
|
||||
var _loop_19 = function (i) {
|
||||
var arg = args[i];
|
||||
// We can call checkExpressionCached because spread expressions never have a contextual type.
|
||||
var spreadType = arg.kind === 217 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
|
||||
@ -65866,7 +65892,7 @@ var ts;
|
||||
}
|
||||
};
|
||||
for (var i = spreadIndex; i < args.length; i++) {
|
||||
_loop_18(i);
|
||||
_loop_19(i);
|
||||
}
|
||||
return effectiveArgs_1;
|
||||
}
|
||||
@ -66168,7 +66194,7 @@ var ts;
|
||||
var min_3 = Number.MAX_VALUE;
|
||||
var minIndex = 0;
|
||||
var i_1 = 0;
|
||||
var _loop_19 = function (c) {
|
||||
var _loop_20 = function (c) {
|
||||
var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
|
||||
var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2);
|
||||
if (diags_2) {
|
||||
@ -66186,7 +66212,7 @@ var ts;
|
||||
};
|
||||
for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
|
||||
var c = candidatesForArgumentError_1[_a];
|
||||
_loop_19(c);
|
||||
_loop_20(c);
|
||||
}
|
||||
var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
|
||||
ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
|
||||
@ -66320,7 +66346,7 @@ var ts;
|
||||
}
|
||||
var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
|
||||
var parameters = [];
|
||||
var _loop_20 = function (i) {
|
||||
var _loop_21 = function (i) {
|
||||
var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
|
||||
i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
|
||||
i < s.parameters.length ? s.parameters[i] : undefined; });
|
||||
@ -66328,7 +66354,7 @@ var ts;
|
||||
parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
|
||||
};
|
||||
for (var i = 0; i < maxNonRestParam; i++) {
|
||||
_loop_20(i);
|
||||
_loop_21(i);
|
||||
}
|
||||
var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
|
||||
var flags = 0 /* None */;
|
||||
@ -68080,15 +68106,11 @@ var ts;
|
||||
checkExpression(node.expression);
|
||||
return undefinedWideningType;
|
||||
}
|
||||
function isInTopLevelContext(node) {
|
||||
var container = ts.getThisContainer(node, /*includeArrowFunctions*/ true);
|
||||
return ts.isSourceFile(container);
|
||||
}
|
||||
function checkAwaitExpression(node) {
|
||||
// Grammar checking
|
||||
if (produceDiagnostics) {
|
||||
if (!(node.flags & 32768 /* AwaitContext */)) {
|
||||
if (isInTopLevelContext(node)) {
|
||||
if (ts.isInTopLevelContext(node)) {
|
||||
var sourceFile = ts.getSourceFileOfNode(node);
|
||||
if (!hasParseDiagnostics(sourceFile)) {
|
||||
var span = void 0;
|
||||
@ -73251,7 +73273,7 @@ var ts;
|
||||
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
|
||||
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
|
||||
var issuedMemberError = false;
|
||||
var _loop_21 = function (member) {
|
||||
var _loop_22 = function (member) {
|
||||
if (ts.hasStaticModifier(member)) {
|
||||
return "continue";
|
||||
}
|
||||
@ -73270,7 +73292,7 @@ var ts;
|
||||
};
|
||||
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
||||
var member = _a[_i];
|
||||
_loop_21(member);
|
||||
_loop_22(member);
|
||||
}
|
||||
if (!issuedMemberError) {
|
||||
// check again with diagnostics to generate a less-specific error
|
||||
@ -74043,7 +74065,6 @@ var ts;
|
||||
}
|
||||
}
|
||||
function checkImportBinding(node) {
|
||||
checkGrammarAwaitIdentifier(node.name);
|
||||
checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
|
||||
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
|
||||
checkAliasSymbol(node);
|
||||
@ -75214,10 +75235,10 @@ var ts;
|
||||
// If this is from nested object binding pattern
|
||||
// for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) {
|
||||
if (expr.parent.kind === 285 /* PropertyAssignment */) {
|
||||
var node_1 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
|
||||
var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_1) || errorType;
|
||||
var propertyIndex = ts.indexOfNode(node_1.properties, expr.parent);
|
||||
return checkObjectLiteralDestructuringPropertyAssignment(node_1, typeOfParentObjectLiteral, propertyIndex);
|
||||
var node_2 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
|
||||
var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_2) || errorType;
|
||||
var propertyIndex = ts.indexOfNode(node_2.properties, expr.parent);
|
||||
return checkObjectLiteralDestructuringPropertyAssignment(node_2, typeOfParentObjectLiteral, propertyIndex);
|
||||
}
|
||||
// Array literal assignment - array destructuring pattern
|
||||
var node = ts.cast(expr.parent, ts.isArrayLiteralExpression);
|
||||
@ -76574,29 +76595,18 @@ var ts;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function checkGrammarAwaitIdentifier(name) {
|
||||
if (name && ts.isIdentifier(name) && name.originalKeywordKind === 130 /* AwaitKeyword */ && isInTopLevelContext(name.parent)) {
|
||||
var file = ts.getSourceFileOfNode(name);
|
||||
if (!file.isDeclarationFile && ts.isExternalModule(file)) {
|
||||
return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.idText(name));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function checkGrammarFunctionLikeDeclaration(node) {
|
||||
// Prevent cascading error by short-circuit
|
||||
var file = ts.getSourceFileOfNode(node);
|
||||
return checkGrammarDecoratorsAndModifiers(node) ||
|
||||
checkGrammarTypeParameterList(node.typeParameters, file) ||
|
||||
(ts.isFunctionDeclaration(node) && checkGrammarAwaitIdentifier(node.name)) ||
|
||||
checkGrammarParameterList(node.parameters) ||
|
||||
checkGrammarArrowFunction(node, file) ||
|
||||
(ts.isFunctionLikeDeclaration(node) && checkGrammarForUseStrictSimpleParameterList(node));
|
||||
}
|
||||
function checkGrammarClassLikeDeclaration(node) {
|
||||
var file = ts.getSourceFileOfNode(node);
|
||||
return (ts.isClassDeclaration(node) && checkGrammarAwaitIdentifier(node.name)) ||
|
||||
checkGrammarClassDeclarationHeritageClauses(node) ||
|
||||
return checkGrammarClassDeclarationHeritageClauses(node) ||
|
||||
checkGrammarTypeParameterList(node.typeParameters, file);
|
||||
}
|
||||
function checkGrammarArrowFunction(node, file) {
|
||||
@ -77166,9 +77176,6 @@ var ts;
|
||||
return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_have_a_property_name);
|
||||
}
|
||||
}
|
||||
if (ts.isIdentifier(node.name) && checkGrammarAwaitIdentifier(node.name)) {
|
||||
return true;
|
||||
}
|
||||
if (node.dotDotDotToken && node.initializer) {
|
||||
// Error on equals token which immediately precedes the initializer
|
||||
return grammarErrorAtPos(node, node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer);
|
||||
@ -77225,9 +77232,6 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ts.isIdentifier(node.name) && checkGrammarAwaitIdentifier(node.name)) {
|
||||
return true;
|
||||
}
|
||||
if (node.exclamationToken && (node.parent.parent.kind !== 229 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) {
|
||||
return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation);
|
||||
}
|
||||
@ -107190,7 +107194,7 @@ var ts;
|
||||
});
|
||||
// Sort by paths closest to importing file Name directory
|
||||
var sortedPaths = [];
|
||||
var _loop_22 = function (directory) {
|
||||
var _loop_23 = function (directory) {
|
||||
var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
|
||||
var pathsInDirectory;
|
||||
allFileNames.forEach(function (canonicalFileName, fileName) {
|
||||
@ -107216,7 +107220,7 @@ var ts;
|
||||
};
|
||||
var out_directory_1;
|
||||
for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) {
|
||||
var state_8 = _loop_22(directory);
|
||||
var state_8 = _loop_23(directory);
|
||||
directory = out_directory_1;
|
||||
if (state_8 === "break")
|
||||
break;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user