mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
Don't treat a colon in a conditional expression branch as part of an arrow function (#47550)
This commit is contained in:
parent
dda65830de
commit
2dede207ae
@ -4134,10 +4134,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
const pos = getNodePos();
|
||||
let expr = parseAssignmentExpressionOrHigher();
|
||||
let expr = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false);
|
||||
let operatorToken: BinaryOperatorToken;
|
||||
while ((operatorToken = parseOptionalToken(SyntaxKind.CommaToken))) {
|
||||
expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(), pos);
|
||||
expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false), pos);
|
||||
}
|
||||
|
||||
if (saveDecoratorContext) {
|
||||
@ -4147,10 +4147,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
function parseInitializer(): Expression | undefined {
|
||||
return parseOptional(SyntaxKind.EqualsToken) ? parseAssignmentExpressionOrHigher() : undefined;
|
||||
return parseOptional(SyntaxKind.EqualsToken) ? parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false) : undefined;
|
||||
}
|
||||
|
||||
function parseAssignmentExpressionOrHigher(): Expression {
|
||||
function parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction: boolean): Expression {
|
||||
// AssignmentExpression[in,yield]:
|
||||
// 1) ConditionalExpression[?in,?yield]
|
||||
// 2) LeftHandSideExpression = AssignmentExpression[?in,?yield]
|
||||
@ -4178,7 +4178,7 @@ namespace ts {
|
||||
// If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is
|
||||
// not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done
|
||||
// with AssignmentExpression if we see one.
|
||||
const arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
|
||||
const arrowExpression = tryParseParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction) || tryParseAsyncSimpleArrowFunctionExpression(disallowReturnTypeInArrowFunction);
|
||||
if (arrowExpression) {
|
||||
return arrowExpression;
|
||||
}
|
||||
@ -4199,7 +4199,7 @@ namespace ts {
|
||||
// parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single
|
||||
// identifier and the current token is an arrow.
|
||||
if (expr.kind === SyntaxKind.Identifier && token() === SyntaxKind.EqualsGreaterThanToken) {
|
||||
return parseSimpleArrowFunctionExpression(pos, expr as Identifier, /*asyncModifier*/ undefined);
|
||||
return parseSimpleArrowFunctionExpression(pos, expr as Identifier, disallowReturnTypeInArrowFunction, /*asyncModifier*/ undefined);
|
||||
}
|
||||
|
||||
// Now see if we might be in cases '2' or '3'.
|
||||
@ -4209,7 +4209,7 @@ namespace ts {
|
||||
// Note: we call reScanGreaterToken so that we get an appropriately merged token
|
||||
// for cases like `> > =` becoming `>>=`
|
||||
if (isLeftHandSideExpression(expr) && isAssignmentOperator(reScanGreaterToken())) {
|
||||
return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(), pos);
|
||||
return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction), pos);
|
||||
}
|
||||
|
||||
// It wasn't an assignment or a lambda. This is a conditional expression:
|
||||
@ -4263,7 +4263,7 @@ namespace ts {
|
||||
return finishNode(
|
||||
factory.createYieldExpression(
|
||||
parseOptionalToken(SyntaxKind.AsteriskToken),
|
||||
parseAssignmentExpressionOrHigher()
|
||||
parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false)
|
||||
),
|
||||
pos
|
||||
);
|
||||
@ -4275,7 +4275,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function parseSimpleArrowFunctionExpression(pos: number, identifier: Identifier, asyncModifier?: NodeArray<Modifier> | undefined): ArrowFunction {
|
||||
function parseSimpleArrowFunctionExpression(pos: number, identifier: Identifier, disallowReturnTypeInArrowFunction: boolean, asyncModifier?: NodeArray<Modifier> | undefined): ArrowFunction {
|
||||
Debug.assert(token() === SyntaxKind.EqualsGreaterThanToken, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
|
||||
const parameter = factory.createParameterDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
@ -4290,12 +4290,12 @@ namespace ts {
|
||||
|
||||
const parameters = createNodeArray<ParameterDeclaration>([parameter], parameter.pos, parameter.end);
|
||||
const equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken);
|
||||
const body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier);
|
||||
const body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier, disallowReturnTypeInArrowFunction);
|
||||
const node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body);
|
||||
return addJSDocComment(finishNode(node, pos));
|
||||
}
|
||||
|
||||
function tryParseParenthesizedArrowFunctionExpression(): Expression | undefined {
|
||||
function tryParseParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction: boolean): Expression | undefined {
|
||||
const triState = isParenthesizedArrowFunctionExpression();
|
||||
if (triState === Tristate.False) {
|
||||
// It's definitely not a parenthesized arrow function expression.
|
||||
@ -4307,8 +4307,8 @@ namespace ts {
|
||||
// it out, but don't allow any ambiguity, and return 'undefined' if this could be an
|
||||
// expression instead.
|
||||
return triState === Tristate.True ?
|
||||
parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true) :
|
||||
tryParse(parsePossibleParenthesizedArrowFunctionExpression);
|
||||
parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, /*disallowReturnTypeInArrowFunction*/ false) :
|
||||
tryParse(() => parsePossibleParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction));
|
||||
}
|
||||
|
||||
// True -> We definitely expect a parenthesized arrow function here.
|
||||
@ -4454,13 +4454,13 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function parsePossibleParenthesizedArrowFunctionExpression(): ArrowFunction | undefined {
|
||||
function parsePossibleParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction: boolean): ArrowFunction | undefined {
|
||||
const tokenPos = scanner.getTokenPos();
|
||||
if (notParenthesizedArrow?.has(tokenPos)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false);
|
||||
const result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false, disallowReturnTypeInArrowFunction);
|
||||
if (!result) {
|
||||
(notParenthesizedArrow || (notParenthesizedArrow = new Set())).add(tokenPos);
|
||||
}
|
||||
@ -4468,14 +4468,14 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
function tryParseAsyncSimpleArrowFunctionExpression(): ArrowFunction | undefined {
|
||||
function tryParseAsyncSimpleArrowFunctionExpression(disallowReturnTypeInArrowFunction: boolean): ArrowFunction | undefined {
|
||||
// We do a check here so that we won't be doing unnecessarily call to "lookAhead"
|
||||
if (token() === SyntaxKind.AsyncKeyword) {
|
||||
if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === Tristate.True) {
|
||||
const pos = getNodePos();
|
||||
const asyncModifier = parseModifiersForArrowFunction();
|
||||
const expr = parseBinaryExpressionOrHigher(OperatorPrecedence.Lowest);
|
||||
return parseSimpleArrowFunctionExpression(pos, expr as Identifier, asyncModifier);
|
||||
return parseSimpleArrowFunctionExpression(pos, expr as Identifier, disallowReturnTypeInArrowFunction, asyncModifier);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
@ -4502,7 +4502,7 @@ namespace ts {
|
||||
return Tristate.False;
|
||||
}
|
||||
|
||||
function parseParenthesizedArrowFunctionExpression(allowAmbiguity: boolean): ArrowFunction | undefined {
|
||||
function parseParenthesizedArrowFunctionExpression(allowAmbiguity: boolean, disallowReturnTypeInArrowFunction: boolean): ArrowFunction | undefined {
|
||||
const pos = getNodePos();
|
||||
const hasJSDoc = hasPrecedingJSDocComment();
|
||||
const modifiers = parseModifiersForArrowFunction();
|
||||
@ -4530,6 +4530,24 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
// Given:
|
||||
// x ? y => ({ y }) : z => ({ z })
|
||||
// We try to parse the body of the first arrow function by looking at:
|
||||
// ({ y }) : z => ({ z })
|
||||
// This is a valid arrow function with "z" as the return type.
|
||||
//
|
||||
// But, if we're in the true side of a conditional expression, this colon
|
||||
// terminates the expression, so we cannot allow a return type if we aren't
|
||||
// certain whether or not the preceding text was parsed as a parameter list.
|
||||
//
|
||||
// For example,
|
||||
// a() ? (b: number, c?: string): void => d() : e
|
||||
// is determined by isParenthesizedArrowFunctionExpression to unambiguously
|
||||
// be an arrow expression, so we allow a return type.
|
||||
if (disallowReturnTypeInArrowFunction && token() === SyntaxKind.ColonToken) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const type = parseReturnType(SyntaxKind.ColonToken, /*isType*/ false);
|
||||
if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) {
|
||||
return undefined;
|
||||
@ -4562,14 +4580,14 @@ namespace ts {
|
||||
const lastToken = token();
|
||||
const equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken);
|
||||
const body = (lastToken === SyntaxKind.EqualsGreaterThanToken || lastToken === SyntaxKind.OpenBraceToken)
|
||||
? parseArrowFunctionExpressionBody(some(modifiers, isAsyncModifier))
|
||||
? parseArrowFunctionExpressionBody(some(modifiers, isAsyncModifier), disallowReturnTypeInArrowFunction)
|
||||
: parseIdentifier();
|
||||
|
||||
const node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body);
|
||||
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
||||
}
|
||||
|
||||
function parseArrowFunctionExpressionBody(isAsync: boolean): Block | Expression {
|
||||
function parseArrowFunctionExpressionBody(isAsync: boolean, disallowReturnTypeInArrowFunction: boolean): Block | Expression {
|
||||
if (token() === SyntaxKind.OpenBraceToken) {
|
||||
return parseFunctionBlock(isAsync ? SignatureFlags.Await : SignatureFlags.None);
|
||||
}
|
||||
@ -4599,8 +4617,8 @@ namespace ts {
|
||||
const savedTopLevel = topLevel;
|
||||
topLevel = false;
|
||||
const node = isAsync
|
||||
? doInAwaitContext(parseAssignmentExpressionOrHigher)
|
||||
: doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
|
||||
? doInAwaitContext(() => parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction))
|
||||
: doOutsideOfAwaitContext(() => parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction));
|
||||
topLevel = savedTopLevel;
|
||||
return node;
|
||||
}
|
||||
@ -4619,10 +4637,10 @@ namespace ts {
|
||||
factory.createConditionalExpression(
|
||||
leftOperand,
|
||||
questionToken,
|
||||
doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher),
|
||||
doOutsideOfContext(disallowInAndDecoratorContext, () => parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ true)),
|
||||
colonToken = parseExpectedToken(SyntaxKind.ColonToken),
|
||||
nodeIsPresent(colonToken)
|
||||
? parseAssignmentExpressionOrHigher()
|
||||
? parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ true)
|
||||
: createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ false, Diagnostics._0_expected, tokenToString(SyntaxKind.ColonToken))
|
||||
),
|
||||
pos
|
||||
@ -5644,14 +5662,14 @@ namespace ts {
|
||||
function parseSpreadElement(): Expression {
|
||||
const pos = getNodePos();
|
||||
parseExpected(SyntaxKind.DotDotDotToken);
|
||||
const expression = parseAssignmentExpressionOrHigher();
|
||||
const expression = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false);
|
||||
return finishNode(factory.createSpreadElement(expression), pos);
|
||||
}
|
||||
|
||||
function parseArgumentOrArrayLiteralElement(): Expression {
|
||||
return token() === SyntaxKind.DotDotDotToken ? parseSpreadElement() :
|
||||
token() === SyntaxKind.CommaToken ? finishNode(factory.createOmittedExpression(), getNodePos()) :
|
||||
parseAssignmentExpressionOrHigher();
|
||||
parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false);
|
||||
}
|
||||
|
||||
function parseArgumentExpression(): Expression {
|
||||
@ -5672,7 +5690,7 @@ namespace ts {
|
||||
const hasJSDoc = hasPrecedingJSDocComment();
|
||||
|
||||
if (parseOptionalToken(SyntaxKind.DotDotDotToken)) {
|
||||
const expression = parseAssignmentExpressionOrHigher();
|
||||
const expression = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false);
|
||||
return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc);
|
||||
}
|
||||
|
||||
@ -5707,7 +5725,7 @@ namespace ts {
|
||||
const isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== SyntaxKind.ColonToken);
|
||||
if (isShorthandPropertyAssignment) {
|
||||
const equalsToken = parseOptionalToken(SyntaxKind.EqualsToken);
|
||||
const objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined;
|
||||
const objectAssignmentInitializer = equalsToken ? allowInAnd(() => parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false)) : undefined;
|
||||
node = factory.createShorthandPropertyAssignment(name as Identifier, objectAssignmentInitializer);
|
||||
// Save equals token for error reporting.
|
||||
// TODO(rbuckton): Consider manufacturing this when we need to report an error as it is otherwise not useful.
|
||||
@ -5715,7 +5733,7 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
parseExpected(SyntaxKind.ColonToken);
|
||||
const initializer = allowInAnd(parseAssignmentExpressionOrHigher);
|
||||
const initializer = allowInAnd(() => parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false));
|
||||
node = factory.createPropertyAssignment(name, initializer);
|
||||
}
|
||||
// Decorators, Modifiers, questionToken, and exclamationToken are not supported by property assignments and are reported in the grammar checker
|
||||
@ -5927,7 +5945,7 @@ namespace ts {
|
||||
|
||||
let node: IterationStatement;
|
||||
if (awaitToken ? parseExpected(SyntaxKind.OfKeyword) : parseOptional(SyntaxKind.OfKeyword)) {
|
||||
const expression = allowInAnd(parseAssignmentExpressionOrHigher);
|
||||
const expression = allowInAnd(() => parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false));
|
||||
parseExpected(SyntaxKind.CloseParenToken);
|
||||
node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement());
|
||||
}
|
||||
@ -7268,7 +7286,7 @@ namespace ts {
|
||||
const pos = getNodePos();
|
||||
const name = tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(SyntaxKind.StringLiteral) as StringLiteral;
|
||||
parseExpected(SyntaxKind.ColonToken);
|
||||
const value = parseAssignmentExpressionOrHigher();
|
||||
const value = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false);
|
||||
return finishNode(factory.createAssertEntry(name, value), pos);
|
||||
}
|
||||
|
||||
@ -7532,7 +7550,7 @@ namespace ts {
|
||||
else {
|
||||
parseExpected(SyntaxKind.DefaultKeyword);
|
||||
}
|
||||
const expression = parseAssignmentExpressionOrHigher();
|
||||
const expression = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false);
|
||||
parseSemicolon();
|
||||
setAwaitContext(savedAwaitContext);
|
||||
const node = factory.createExportAssignment(decorators, modifiers, isExportEquals, expression);
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts(1,1): error TS2304: Cannot find name 'a'.
|
||||
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts(1,6): error TS2304: Cannot find name 'b'.
|
||||
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts(1,17): error TS2304: Cannot find name 'd'.
|
||||
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts(1,20): error TS1005: ';' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts(1,27): error TS2304: Cannot find name 'f'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts (5 errors) ====
|
||||
a ? (b) : c => (d) : e => f
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'a'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'b'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'd'.
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'f'.
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
//// [parserArrowFunctionExpression10.ts]
|
||||
a ? (b) : c => (d) : e => f
|
||||
|
||||
|
||||
//// [parserArrowFunctionExpression10.js]
|
||||
a ? (b) : function (c) { return (d); };
|
||||
(function (e) { return f; });
|
||||
@ -0,0 +1,5 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts ===
|
||||
a ? (b) : c => (d) : e => f
|
||||
>c : Symbol(c, Decl(parserArrowFunctionExpression10.ts, 0, 9))
|
||||
>e : Symbol(e, Decl(parserArrowFunctionExpression10.ts, 0, 20))
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts ===
|
||||
a ? (b) : c => (d) : e => f
|
||||
>a ? (b) : c => (d) : any
|
||||
>a : any
|
||||
>(b) : any
|
||||
>b : any
|
||||
>c => (d) : (c: any) => any
|
||||
>c : any
|
||||
>(d) : any
|
||||
>d : any
|
||||
>e => f : (e: any) => any
|
||||
>e : any
|
||||
>f : any
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts(1,1): error TS2304: Cannot find name 'a'.
|
||||
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts(1,5): error TS2304: Cannot find name 'b'.
|
||||
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts(1,9): error TS2304: Cannot find name 'c'.
|
||||
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts(1,14): error TS2304: Cannot find name 'd'.
|
||||
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts(1,24): error TS2304: Cannot find name 'f'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts (5 errors) ====
|
||||
a ? b ? c : (d) : e => f
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'a'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'b'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'c'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'd'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'f'.
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
//// [parserArrowFunctionExpression11.ts]
|
||||
a ? b ? c : (d) : e => f
|
||||
|
||||
|
||||
//// [parserArrowFunctionExpression11.js]
|
||||
a ? b ? c : (d) : function (e) { return f; };
|
||||
@ -0,0 +1,4 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts ===
|
||||
a ? b ? c : (d) : e => f
|
||||
>e : Symbol(e, Decl(parserArrowFunctionExpression11.ts, 0, 17))
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts ===
|
||||
a ? b ? c : (d) : e => f
|
||||
>a ? b ? c : (d) : e => f : any
|
||||
>a : any
|
||||
>b ? c : (d) : any
|
||||
>b : any
|
||||
>c : any
|
||||
>(d) : any
|
||||
>d : any
|
||||
>e => f : (e: any) => any
|
||||
>e : any
|
||||
>f : any
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression12.ts(1,1): error TS2304: Cannot find name 'a'.
|
||||
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression12.ts(1,13): error TS2304: Cannot find name 'c'.
|
||||
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression12.ts(1,22): error TS2304: Cannot find name 'e'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression12.ts (3 errors) ====
|
||||
a ? (b) => (c): d => e
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'a'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'c'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'e'.
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
//// [parserArrowFunctionExpression12.ts]
|
||||
a ? (b) => (c): d => e
|
||||
|
||||
|
||||
//// [parserArrowFunctionExpression12.js]
|
||||
a ? function (b) { return (c); } : function (d) { return e; };
|
||||
@ -0,0 +1,5 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression12.ts ===
|
||||
a ? (b) => (c): d => e
|
||||
>b : Symbol(b, Decl(parserArrowFunctionExpression12.ts, 0, 5))
|
||||
>d : Symbol(d, Decl(parserArrowFunctionExpression12.ts, 0, 15))
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression12.ts ===
|
||||
a ? (b) => (c): d => e
|
||||
>a ? (b) => (c): d => e : (b: any) => any
|
||||
>a : any
|
||||
>(b) => (c) : (b: any) => any
|
||||
>b : any
|
||||
>(c) : any
|
||||
>c : any
|
||||
>d => e : (d: any) => any
|
||||
>d : any
|
||||
>e : any
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression13.ts(1,1): error TS2304: Cannot find name 'a'.
|
||||
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression13.ts(1,11): error TS2304: Cannot find name 'a'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression13.ts (2 errors) ====
|
||||
a ? () => a() : (): any => null;
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'a'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'a'.
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
//// [parserArrowFunctionExpression13.ts]
|
||||
a ? () => a() : (): any => null;
|
||||
|
||||
|
||||
//// [parserArrowFunctionExpression13.js]
|
||||
a ? function () { return a(); } : function () { return null; };
|
||||
@ -0,0 +1,4 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression13.ts ===
|
||||
a ? () => a() : (): any => null;
|
||||
No type information for this code.
|
||||
No type information for this code.
|
||||
@ -0,0 +1,10 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression13.ts ===
|
||||
a ? () => a() : (): any => null;
|
||||
>a ? () => a() : (): any => null : () => any
|
||||
>a : any
|
||||
>() => a() : () => any
|
||||
>a() : any
|
||||
>a : any
|
||||
>(): any => null : () => any
|
||||
>null : null
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression14.ts(1,1): error TS2304: Cannot find name 'a'.
|
||||
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression14.ts(1,40): error TS2304: Cannot find name 'd'.
|
||||
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression14.ts(1,46): error TS2304: Cannot find name 'e'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression14.ts (3 errors) ====
|
||||
a() ? (b: number, c?: string): void => d() : e;
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'a'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'd'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'e'.
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
//// [parserArrowFunctionExpression14.ts]
|
||||
a() ? (b: number, c?: string): void => d() : e;
|
||||
|
||||
|
||||
//// [parserArrowFunctionExpression14.js]
|
||||
a() ? function (b, c) { return d(); } : e;
|
||||
@ -0,0 +1,5 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression14.ts ===
|
||||
a() ? (b: number, c?: string): void => d() : e;
|
||||
>b : Symbol(b, Decl(parserArrowFunctionExpression14.ts, 0, 7))
|
||||
>c : Symbol(c, Decl(parserArrowFunctionExpression14.ts, 0, 17))
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression14.ts ===
|
||||
a() ? (b: number, c?: string): void => d() : e;
|
||||
>a() ? (b: number, c?: string): void => d() : e : any
|
||||
>a() : any
|
||||
>a : any
|
||||
>(b: number, c?: string): void => d() : (b: number, c?: string) => void
|
||||
>b : number
|
||||
>c : string
|
||||
>d() : any
|
||||
>d : any
|
||||
>e : any
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression8.ts(1,1): error TS2304: Cannot find name 'x'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression8.ts (1 errors) ====
|
||||
x ? y => ({ y }) : z => ({ z })
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'x'.
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
//// [parserArrowFunctionExpression8.ts]
|
||||
x ? y => ({ y }) : z => ({ z })
|
||||
|
||||
|
||||
//// [parserArrowFunctionExpression8.js]
|
||||
x ? function (y) { return ({ y: y }); } : function (z) { return ({ z: z }); };
|
||||
@ -0,0 +1,7 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression8.ts ===
|
||||
x ? y => ({ y }) : z => ({ z })
|
||||
>y : Symbol(y, Decl(parserArrowFunctionExpression8.ts, 0, 3))
|
||||
>y : Symbol(y, Decl(parserArrowFunctionExpression8.ts, 0, 11))
|
||||
>z : Symbol(z, Decl(parserArrowFunctionExpression8.ts, 0, 18))
|
||||
>z : Symbol(z, Decl(parserArrowFunctionExpression8.ts, 0, 26))
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression8.ts ===
|
||||
x ? y => ({ y }) : z => ({ z })
|
||||
>x ? y => ({ y }) : z => ({ z }) : ((y: any) => { y: any; }) | ((z: any) => { z: any; })
|
||||
>x : any
|
||||
>y => ({ y }) : (y: any) => { y: any; }
|
||||
>y : any
|
||||
>({ y }) : { y: any; }
|
||||
>{ y } : { y: any; }
|
||||
>y : any
|
||||
>z => ({ z }) : (z: any) => { z: any; }
|
||||
>z : any
|
||||
>({ z }) : { z: any; }
|
||||
>{ z } : { z: any; }
|
||||
>z : any
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/file.js(1,1): error TS2304: Cannot find name 'x'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/file.js (1 errors) ====
|
||||
x ? y => ({ y }) : z => ({ z })
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'x'.
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
//// [file.js]
|
||||
x ? y => ({ y }) : z => ({ z })
|
||||
|
||||
|
||||
//// [file.js]
|
||||
x ? function (y) { return ({ y: y }); } : function (z) { return ({ z: z }); };
|
||||
@ -0,0 +1,7 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/file.js ===
|
||||
x ? y => ({ y }) : z => ({ z })
|
||||
>y : Symbol(y, Decl(file.js, 0, 3))
|
||||
>y : Symbol(y, Decl(file.js, 0, 11))
|
||||
>z : Symbol(z, Decl(file.js, 0, 18))
|
||||
>z : Symbol(z, Decl(file.js, 0, 26))
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/file.js ===
|
||||
x ? y => ({ y }) : z => ({ z })
|
||||
>x ? y => ({ y }) : z => ({ z }) : ((y: any) => { y: any; }) | ((z: any) => { z: any; })
|
||||
>x : any
|
||||
>y => ({ y }) : (y: any) => { y: any; }
|
||||
>y : any
|
||||
>({ y }) : { y: any; }
|
||||
>{ y } : { y: any; }
|
||||
>y : any
|
||||
>z => ({ z }) : (z: any) => { z: any; }
|
||||
>z : any
|
||||
>({ z }) : { z: any; }
|
||||
>{ z } : { z: any; }
|
||||
>z : any
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression9.ts(1,1): error TS2304: Cannot find name 'b'.
|
||||
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression9.ts(1,6): error TS2304: Cannot find name 'c'.
|
||||
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression9.ts(1,16): error TS2304: Cannot find name 'e'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression9.ts (3 errors) ====
|
||||
b ? (c) : d => e
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'b'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'c'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'e'.
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
//// [parserArrowFunctionExpression9.ts]
|
||||
b ? (c) : d => e
|
||||
|
||||
|
||||
//// [parserArrowFunctionExpression9.js]
|
||||
b ? (c) : function (d) { return e; };
|
||||
@ -0,0 +1,4 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression9.ts ===
|
||||
b ? (c) : d => e
|
||||
>d : Symbol(d, Decl(parserArrowFunctionExpression9.ts, 0, 9))
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression9.ts ===
|
||||
b ? (c) : d => e
|
||||
>b ? (c) : d => e : any
|
||||
>b : any
|
||||
>(c) : any
|
||||
>c : any
|
||||
>d => e : (d: any) => any
|
||||
>d : any
|
||||
>e : any
|
||||
|
||||
@ -0,0 +1 @@
|
||||
a ? (b) : c => (d) : e => f
|
||||
@ -0,0 +1 @@
|
||||
a ? b ? c : (d) : e => f
|
||||
@ -0,0 +1 @@
|
||||
a ? (b) => (c): d => e
|
||||
@ -0,0 +1 @@
|
||||
a ? () => a() : (): any => null;
|
||||
@ -0,0 +1 @@
|
||||
a() ? (b: number, c?: string): void => d() : e;
|
||||
@ -0,0 +1 @@
|
||||
x ? y => ({ y }) : z => ({ z })
|
||||
@ -0,0 +1,6 @@
|
||||
// @filename: file.js
|
||||
// @allowjs: true
|
||||
// @checkjs: true
|
||||
// @outdir: out
|
||||
|
||||
x ? y => ({ y }) : z => ({ z })
|
||||
@ -0,0 +1 @@
|
||||
b ? (c) : d => e
|
||||
Loading…
x
Reference in New Issue
Block a user