Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1380,8 +1380,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:
Expand Down
13 changes: 11 additions & 2 deletions tests/baselines/reference/TypeArgumentList1.errors.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
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,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 (2 errors) ====
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts (5 errors) ====
Foo<A,B,\ C>(4, 5, 6);
~~~
!!! error TS2304: Cannot find name 'Foo'.
~
!!! 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'.
3 changes: 2 additions & 1 deletion tests/baselines/reference/TypeArgumentList1.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
Foo<A,B,\ C>(4, 5, 6);

//// [TypeArgumentList1.js]
Foo(4, 5, 6);
Foo < A, B, ;
C > (4, 5, 6);
7 changes: 2 additions & 5 deletions tests/baselines/reference/parserSkippedTokens20.errors.txt
Original file line number Diff line number Diff line change
@@ -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.
13 changes: 11 additions & 2 deletions tests/baselines/reference/parserX_TypeArgumentList1.errors.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
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,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 (2 errors) ====
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/parserX_TypeArgumentList1.ts (5 errors) ====
Foo<A,B,\ C>(4, 5, 6);
~~~
!!! error TS2304: Cannot find name 'Foo'.
~
!!! 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'.
3 changes: 2 additions & 1 deletion tests/baselines/reference/parserX_TypeArgumentList1.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
41 changes: 41 additions & 0 deletions tests/baselines/reference/tsxCorrectlyParseLessThanComparison1.js
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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)
}
}
}
Original file line number Diff line number Diff line change
@@ -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 : number

return (<div></div>);
>(<div></div>) : any
><div></div> : any
>div : any
>div : any
}
}
}
Original file line number Diff line number Diff line change
@@ -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>);
}
}
}