Merge pull request #11118 from Microsoft/fix11081

Fix11081
This commit is contained in:
Yui 2016-10-05 10:28:22 -07:00 committed by GitHub
commit f8b34c96a0
10 changed files with 229 additions and 13 deletions

View File

@ -1394,8 +1394,8 @@ namespace ts {
// Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery
return token() === SyntaxKind.CloseParenToken || token() === SyntaxKind.CloseBracketToken /*|| token === SyntaxKind.OpenBraceToken*/;
case ParsingContext.TypeArguments:
// Tokens other than '>' are here for better error recovery
return token() === SyntaxKind.GreaterThanToken || token() === SyntaxKind.OpenParenToken;
// All other tokens should cause the type-argument to terminate except comma token
return token() !== SyntaxKind.CommaToken;
case ParsingContext.HeritageClauses:
return token() === SyntaxKind.OpenBraceToken || token() === SyntaxKind.CloseBraceToken;
case ParsingContext.JsxAttributes:

View File

@ -1,10 +1,31 @@
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,1): error TS2304: Cannot find name 'Foo'.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,1): error TS2695: Left side of comma operator is unused and has no side effects.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,1): error TS2695: Left side of comma operator is unused and has no side effects.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,5): error TS2304: Cannot find name 'A'.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,7): error TS2304: Cannot find name 'B'.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,9): error TS1127: Invalid character.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,11): error TS2304: Cannot find name 'C'.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,14): error TS2695: Left side of comma operator is unused and has no side effects.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,14): error TS2695: Left side of comma operator is unused and has no side effects.
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts (2 errors) ====
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts (9 errors) ====
Foo<A,B,\ C>(4, 5, 6);
~~~
!!! error TS2304: Cannot find name 'Foo'.
~~~~~
!!! error TS2695: Left side of comma operator is unused and has no side effects.
~~~~~~~
!!! error TS2695: Left side of comma operator is unused and has no side effects.
~
!!! error TS2304: Cannot find name 'A'.
~
!!! error TS2304: Cannot find name 'B'.
!!! error TS1127: Invalid character.
!!! error TS1127: Invalid character.
~
!!! error TS2304: Cannot find name 'C'.
~
!!! error TS2695: Left side of comma operator is unused and has no side effects.
~~~~
!!! error TS2695: Left side of comma operator is unused and has no side effects.

View File

@ -2,4 +2,5 @@
Foo<A,B,\ C>(4, 5, 6);
//// [TypeArgumentList1.js]
Foo(4, 5, 6);
Foo < A, B, ;
C > (4, 5, 6);

View File

@ -1,13 +1,10 @@
tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens20.ts(1,8): error TS2304: Cannot find name 'X'.
tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens20.ts(1,12): error TS1127: Invalid character.
tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens20.ts(1,13): error TS1005: '>' expected.
==== tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens20.ts (3 errors) ====
==== tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens20.ts (2 errors) ====
var v: X<T \
~
!!! error TS2304: Cannot find name 'X'.
!!! error TS1127: Invalid character.
!!! error TS1005: '>' expected.
!!! error TS1127: Invalid character.

View File

@ -1,10 +1,31 @@
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/parserX_TypeArgumentList1.ts(1,1): error TS2304: Cannot find name 'Foo'.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/parserX_TypeArgumentList1.ts(1,1): error TS2695: Left side of comma operator is unused and has no side effects.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/parserX_TypeArgumentList1.ts(1,1): error TS2695: Left side of comma operator is unused and has no side effects.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/parserX_TypeArgumentList1.ts(1,5): error TS2304: Cannot find name 'A'.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/parserX_TypeArgumentList1.ts(1,7): error TS2304: Cannot find name 'B'.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/parserX_TypeArgumentList1.ts(1,9): error TS1127: Invalid character.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/parserX_TypeArgumentList1.ts(1,11): error TS2304: Cannot find name 'C'.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/parserX_TypeArgumentList1.ts(1,14): error TS2695: Left side of comma operator is unused and has no side effects.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/parserX_TypeArgumentList1.ts(1,14): error TS2695: Left side of comma operator is unused and has no side effects.
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/parserX_TypeArgumentList1.ts (2 errors) ====
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/parserX_TypeArgumentList1.ts (9 errors) ====
Foo<A,B,\ C>(4, 5, 6);
~~~
!!! error TS2304: Cannot find name 'Foo'.
~~~~~
!!! error TS2695: Left side of comma operator is unused and has no side effects.
~~~~~~~
!!! error TS2695: Left side of comma operator is unused and has no side effects.
~
!!! error TS2304: Cannot find name 'A'.
~
!!! error TS2304: Cannot find name 'B'.
!!! error TS1127: Invalid character.
!!! error TS1127: Invalid character.
~
!!! error TS2304: Cannot find name 'C'.
~
!!! error TS2695: Left side of comma operator is unused and has no side effects.
~~~~
!!! error TS2695: Left side of comma operator is unused and has no side effects.

View File

@ -2,4 +2,5 @@
Foo<A,B,\ C>(4, 5, 6);
//// [parserX_TypeArgumentList1.js]
Foo(4, 5, 6);
Foo < A, B, ;
C > (4, 5, 6);

View File

@ -0,0 +1,41 @@
//// [tsxCorrectlyParseLessThanComparison1.tsx]
declare module JSX {
interface Element {
div: string;
}
}
declare namespace React {
class Component<P, S> {
constructor(props?: P, context?: any);
props: P;
}
}
export class ShortDetails extends React.Component<{ id: number }, {}> {
public render(): JSX.Element {
if (this.props.id < 1) {
return (<div></div>);
}
}
}
//// [tsxCorrectlyParseLessThanComparison1.js]
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var ShortDetails = (function (_super) {
__extends(ShortDetails, _super);
function ShortDetails() {
_super.apply(this, arguments);
}
ShortDetails.prototype.render = function () {
if (this.props.id < 1) {
return (React.createElement("div", null));
}
};
return ShortDetails;
}(React.Component));
exports.ShortDetails = ShortDetails;

View File

@ -0,0 +1,55 @@
=== tests/cases/conformance/jsx/tsxCorrectlyParseLessThanComparison1.tsx ===
declare module JSX {
>JSX : Symbol(JSX, Decl(tsxCorrectlyParseLessThanComparison1.tsx, 0, 0))
interface Element {
>Element : Symbol(Element, Decl(tsxCorrectlyParseLessThanComparison1.tsx, 0, 20))
div: string;
>div : Symbol(Element.div, Decl(tsxCorrectlyParseLessThanComparison1.tsx, 1, 23))
}
}
declare namespace React {
>React : Symbol(React, Decl(tsxCorrectlyParseLessThanComparison1.tsx, 4, 1))
class Component<P, S> {
>Component : Symbol(Component, Decl(tsxCorrectlyParseLessThanComparison1.tsx, 5, 25))
>P : Symbol(P, Decl(tsxCorrectlyParseLessThanComparison1.tsx, 6, 20))
>S : Symbol(S, Decl(tsxCorrectlyParseLessThanComparison1.tsx, 6, 22))
constructor(props?: P, context?: any);
>props : Symbol(props, Decl(tsxCorrectlyParseLessThanComparison1.tsx, 7, 20))
>P : Symbol(P, Decl(tsxCorrectlyParseLessThanComparison1.tsx, 6, 20))
>context : Symbol(context, Decl(tsxCorrectlyParseLessThanComparison1.tsx, 7, 30))
props: P;
>props : Symbol(Component.props, Decl(tsxCorrectlyParseLessThanComparison1.tsx, 7, 46))
>P : Symbol(P, Decl(tsxCorrectlyParseLessThanComparison1.tsx, 6, 20))
}
}
export class ShortDetails extends React.Component<{ id: number }, {}> {
>ShortDetails : Symbol(ShortDetails, Decl(tsxCorrectlyParseLessThanComparison1.tsx, 10, 1))
>React.Component : Symbol(React.Component, Decl(tsxCorrectlyParseLessThanComparison1.tsx, 5, 25))
>React : Symbol(React, Decl(tsxCorrectlyParseLessThanComparison1.tsx, 4, 1))
>Component : Symbol(React.Component, Decl(tsxCorrectlyParseLessThanComparison1.tsx, 5, 25))
>id : Symbol(id, Decl(tsxCorrectlyParseLessThanComparison1.tsx, 12, 51))
public render(): JSX.Element {
>render : Symbol(ShortDetails.render, Decl(tsxCorrectlyParseLessThanComparison1.tsx, 12, 71))
>JSX : Symbol(JSX, Decl(tsxCorrectlyParseLessThanComparison1.tsx, 0, 0))
>Element : Symbol(JSX.Element, Decl(tsxCorrectlyParseLessThanComparison1.tsx, 0, 20))
if (this.props.id < 1) {
>this.props.id : Symbol(id, Decl(tsxCorrectlyParseLessThanComparison1.tsx, 12, 51))
>this.props : Symbol(React.Component.props, Decl(tsxCorrectlyParseLessThanComparison1.tsx, 7, 46))
>this : Symbol(ShortDetails, Decl(tsxCorrectlyParseLessThanComparison1.tsx, 10, 1))
>props : Symbol(React.Component.props, Decl(tsxCorrectlyParseLessThanComparison1.tsx, 7, 46))
>id : Symbol(id, Decl(tsxCorrectlyParseLessThanComparison1.tsx, 12, 51))
return (<div></div>);
>div : Symbol(unknown)
>div : Symbol(unknown)
}
}
}

View File

@ -0,0 +1,59 @@
=== tests/cases/conformance/jsx/tsxCorrectlyParseLessThanComparison1.tsx ===
declare module JSX {
>JSX : any
interface Element {
>Element : Element
div: string;
>div : string
}
}
declare namespace React {
>React : typeof React
class Component<P, S> {
>Component : Component<P, S>
>P : P
>S : S
constructor(props?: P, context?: any);
>props : P
>P : P
>context : any
props: P;
>props : P
>P : P
}
}
export class ShortDetails extends React.Component<{ id: number }, {}> {
>ShortDetails : ShortDetails
>React.Component : React.Component<{ id: number; }, {}>
>React : typeof React
>Component : typeof React.Component
>id : number
public render(): JSX.Element {
>render : () => JSX.Element
>JSX : any
>Element : JSX.Element
if (this.props.id < 1) {
>this.props.id < 1 : boolean
>this.props.id : number
>this.props : { id: number; }
>this : this
>props : { id: number; }
>id : number
>1 : 1
return (<div></div>);
>(<div></div>) : any
><div></div> : any
>div : any
>div : any
}
}
}

View File

@ -0,0 +1,20 @@
// @jsx: react
declare module JSX {
interface Element {
div: string;
}
}
declare namespace React {
class Component<P, S> {
constructor(props?: P, context?: any);
props: P;
}
}
export class ShortDetails extends React.Component<{ id: number }, {}> {
public render(): JSX.Element {
if (this.props.id < 1) {
return (<div></div>);
}
}
}