imporve conditional operator if missing colon token (#20498)

f2
This commit is contained in:
Wenlu Wang 2018-01-09 05:16:17 +08:00 committed by Mohamed Hegazy
parent a82d1f8580
commit 0ecdc876f3
3 changed files with 11 additions and 9 deletions

View file

@ -3504,7 +3504,9 @@ namespace ts {
node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher);
node.colonToken = parseExpectedToken(SyntaxKind.ColonToken, /*reportAtCurrentPosition*/ false,
Diagnostics._0_expected, tokenToString(SyntaxKind.ColonToken));
node.whenFalse = parseAssignmentExpressionOrHigher();
node.whenFalse = nodeIsPresent(node.colonToken)
? parseAssignmentExpressionOrHigher()
: createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ false, Diagnostics._0_expected, tokenToString(SyntaxKind.ColonToken));
return finishNode(node);
}

View file

@ -10,13 +10,11 @@ tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(14,45): error TS1005: '}' ex
tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(18,2): error TS17008: JSX element 'foo' has no corresponding closing tag.
tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(18,8): error TS17008: JSX element 'foo' has no corresponding closing tag.
tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(18,13): error TS17008: JSX element 'foo' has no corresponding closing tag.
tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(18,83): error TS1109: Expression expected.
tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(21,1): error TS1005: ':' expected.
tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(21,1): error TS1005: '</' expected.
tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(21,1): error TS1005: '}' expected.
==== tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx (16 errors) ====
==== tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx (14 errors) ====
declare var createElement: any;
class foo {}
@ -59,14 +57,10 @@ tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(21,1): error TS1005: '}' exp
!!! error TS17008: JSX element 'foo' has no corresponding closing tag.
~~~
!!! error TS17008: JSX element 'foo' has no corresponding closing tag.
!!! error TS1109: Expression expected.
!!! error TS1005: ':' expected.
!!! error TS1005: '</' expected.
!!! error TS1005: '}' expected.
!!! error TS1005: '</' expected.

View file

@ -0,0 +1,6 @@
/// <reference path="fourslash.ts" />
////1 ? fun/*1*/
////function func () {}
goTo.marker("1");
verify.completionListContains("func");