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
82 changes: 32 additions & 50 deletions src/compiler/parser.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,20 +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,11): error TS2304: Cannot find name 'c'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts(1,22): error TS2304: Cannot find name 'e'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts(1,27): error TS2304: Cannot find name 'f'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts(2,1): error TS1005: ':' expected.


==== 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 'c'.
~
!!! error TS2304: Cannot find name 'e'.
~
!!! error TS2304: Cannot find name 'f'.



!!! error TS1005: ':' expected.
5 changes: 3 additions & 2 deletions tests/baselines/reference/parserArrowFunctionExpression10.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ a ? (b) : c => (d) : e => f


//// [parserArrowFunctionExpression10.js]
a ? (b) : function (c) { return (d); };
(function (e) { return f; });
a ? function (b) { return function (d) { return f; }; }
:
;
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
=== 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))
>b : Symbol(b, Decl(parserArrowFunctionExpression10.ts, 0, 5))
>c : Symbol(c)
>d : Symbol(d, Decl(parserArrowFunctionExpression10.ts, 0, 16))
>e : Symbol(e)

12 changes: 5 additions & 7 deletions tests/baselines/reference/parserArrowFunctionExpression10.types
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression10.ts ===
a ? (b) : c => (d) : e => f
>a ? (b) : c => (d) : any
>a ? (b) : c => (d) : e => f : any
>a : any
>(b) : any
>(b) : c => (d) : e => f : (b: any) => c
>b : any
>c => (d) : (c: any) => any
>c : any
>(d) : any
>(d) : e => f : (d: any) => e
>d : any
>e => f : (e: any) => any
>e : any
>f : any

> : any

Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
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,19): error TS2304: Cannot find name 'e'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts(1,24): error TS2304: Cannot find name 'f'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts(2,1): error TS1005: ':' expected.


==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts (5 errors) ====
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts (6 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 'e'.
~
!!! error TS2304: Cannot find name 'f'.



!!! error TS1005: ':' expected.
4 changes: 3 additions & 1 deletion tests/baselines/reference/parserArrowFunctionExpression11.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ a ? b ? c : (d) : e => f


//// [parserArrowFunctionExpression11.js]
a ? b ? c : (d) : function (e) { return f; };
a ? b ? c : function (d) { return f; }
:
;
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression11.ts ===
a ? b ? c : (d) : e => f
>e : Symbol(e, Decl(parserArrowFunctionExpression11.ts, 0, 17))
>d : Symbol(d, Decl(parserArrowFunctionExpression11.ts, 0, 13))
>e : Symbol(e)

Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
a ? b ? c : (d) : e => f
>a ? b ? c : (d) : e => f : any
>a : any
>b ? c : (d) : any
>b ? c : (d) : e => f : any
>b : any
>c : any
>(d) : any
>(d) : e => f : (d: any) => e
>d : any
>e => f : (e: any) => any
>e : any
>f : any

> : any

Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
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,17): error TS2304: Cannot find name 'd'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression12.ts(1,22): error TS2304: Cannot find name 'e'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression12.ts(2,1): error TS1005: ':' expected.


==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression12.ts (3 errors) ====
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression12.ts (4 errors) ====
a ? (b) => (c): d => e
~
!!! error TS2304: Cannot find name 'a'.
~
!!! error TS2304: Cannot find name 'c'.
~
!!! error TS2304: Cannot find name 'd'.
~
!!! error TS2304: Cannot find name 'e'.



!!! error TS1005: ':' expected.
4 changes: 3 additions & 1 deletion tests/baselines/reference/parserArrowFunctionExpression12.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ a ? (b) => (c): d => e


//// [parserArrowFunctionExpression12.js]
a ? function (b) { return (c); } : function (d) { return e; };
a ? function (b) { return function (c) { return e; }; }
:
;
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
=== 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))
>c : Symbol(c, Decl(parserArrowFunctionExpression12.ts, 0, 12))
>d : Symbol(d)

10 changes: 5 additions & 5 deletions tests/baselines/reference/parserArrowFunctionExpression12.types
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression12.ts ===
a ? (b) => (c): d => e
>a ? (b) => (c): d => e : (b: any) => any
>a ? (b) => (c): d => e : any
>a : any
>(b) => (c) : (b: any) => any
>(b) => (c): d => e : (b: any) => (c: any) => d
>b : any
>(c) : any
>(c): d => e : (c: any) => d
>c : any
>d => e : (d: any) => any
>d : any
>e : any

> : any

6 changes: 6 additions & 0 deletions tests/baselines/reference/parserArrowFunctionExpression15.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//// [parserArrowFunctionExpression15.ts]
false ? (param): string => param : null


//// [parserArrowFunctionExpression15.js]
false ? function (param) { return param; } : null;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression15.ts ===
false ? (param): string => param : null
>param : Symbol(param, Decl(parserArrowFunctionExpression15.ts, 0, 9))
>param : Symbol(param, Decl(parserArrowFunctionExpression15.ts, 0, 9))

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression15.ts ===
false ? (param): string => param : null
>false ? (param): string => param : null : (param: any) => string
>false : false
>(param): string => param : (param: any) => string
>param : any
>param : any
>null : null

6 changes: 6 additions & 0 deletions tests/baselines/reference/parserArrowFunctionExpression16.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//// [parserArrowFunctionExpression16.ts]
true ? false ? (param): string => param : null : null


//// [parserArrowFunctionExpression16.js]
true ? false ? function (param) { return param; } : null : null;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression16.ts ===
true ? false ? (param): string => param : null : null
>param : Symbol(param, Decl(parserArrowFunctionExpression16.ts, 0, 16))
>param : Symbol(param, Decl(parserArrowFunctionExpression16.ts, 0, 16))

12 changes: 12 additions & 0 deletions tests/baselines/reference/parserArrowFunctionExpression16.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression16.ts ===
true ? false ? (param): string => param : null : null
>true ? false ? (param): string => param : null : null : (param: any) => string
>true : true
>false ? (param): string => param : null : (param: any) => string
>false : false
>(param): string => param : (param: any) => string
>param : any
>param : any
>null : null
>null : null

Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
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,20): error TS2304: Cannot find name 'z'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression8.ts(1,28): error TS18004: No value exists in scope for the shorthand property 'z'. Either declare one or provide an initializer.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression8.ts(2,1): error TS1005: ':' expected.


==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression8.ts (1 errors) ====
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression8.ts (4 errors) ====
x ? y => ({ y }) : z => ({ z })
~
!!! error TS2304: Cannot find name 'x'.

~
!!! error TS2304: Cannot find name 'z'.
~
!!! error TS18004: No value exists in scope for the shorthand property 'z'. Either declare one or provide an initializer.


!!! error TS1005: ':' expected.
7 changes: 6 additions & 1 deletion tests/baselines/reference/parserArrowFunctionExpression8.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ x ? y => ({ y }) : z => ({ z })


//// [parserArrowFunctionExpression8.js]
x ? function (y) { return ({ y: y }); } : function (z) { return ({ z: z }); };
x ? function (y) { return function (_a) {
var y = _a.y;
return ({ z: z });
}; }
:
;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
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)
>z : Symbol(z, Decl(parserArrowFunctionExpression8.ts, 0, 26))

11 changes: 5 additions & 6 deletions tests/baselines/reference/parserArrowFunctionExpression8.types
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
=== 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 ? y => ({ y }) : z => ({ z }) : any
>x : any
>y => ({ y }) : (y: any) => { y: any; }
>y => ({ y }) : z => ({ z }) : (y: any) => ({ y }: { y: any; }) => z
>y : any
>({ y }) : { y: any; }
>{ y } : { y: any; }
>({ y }) : z => ({ z }) : ({ y }: { y: any; }) => z
>y : any
>z => ({ z }) : (z: any) => { z: any; }
>z : any
>({ z }) : { z: any; }
>{ z } : { z: any; }
>z : any

> : any

Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
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,20): error TS2304: Cannot find name 'z'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/file.js(1,20): error TS8010: Type annotations can only be used in TypeScript files.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/file.js(1,28): error TS18004: No value exists in scope for the shorthand property 'z'. Either declare one or provide an initializer.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/file.js(2,1): error TS1005: ':' expected.


==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/file.js (1 errors) ====
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/file.js (5 errors) ====
x ? y => ({ y }) : z => ({ z })
~
!!! error TS2304: Cannot find name 'x'.

~
!!! error TS2304: Cannot find name 'z'.
~
!!! error TS8010: Type annotations can only be used in TypeScript files.
~
!!! error TS18004: No value exists in scope for the shorthand property 'z'. Either declare one or provide an initializer.


!!! error TS1005: ':' expected.
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ x ? y => ({ y }) : z => ({ z })


//// [file.js]
x ? function (y) { return ({ y: y }); } : function (z) { return ({ z: z }); };
x ? function (y) { return function (_a) {
var y = _a.y;
return ({ z: z });
}; }
:
;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
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)
>z : Symbol(z, Decl(file.js, 0, 26))

11 changes: 5 additions & 6 deletions tests/baselines/reference/parserArrowFunctionExpression8Js.types
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
=== 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 ? y => ({ y }) : z => ({ z }) : any
>x : any
>y => ({ y }) : (y: any) => { y: any; }
>y => ({ y }) : z => ({ z }) : (y: any) => ({ y }: { y: any; }) => z
>y : any
>({ y }) : { y: any; }
>{ y } : { y: any; }
>({ y }) : z => ({ z }) : ({ y }: { y: any; }) => z
>y : any
>z => ({ z }) : (z: any) => { z: any; }
>z : any
>({ z }) : { z: any; }
>{ z } : { z: any; }
>z : any

> : any

Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
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,11): error TS2304: Cannot find name 'd'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression9.ts(1,16): error TS2304: Cannot find name 'e'.
tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression9.ts(2,1): error TS1005: ':' expected.


==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression9.ts (3 errors) ====
==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression9.ts (4 errors) ====
b ? (c) : d => e
~
!!! error TS2304: Cannot find name 'b'.
~
!!! error TS2304: Cannot find name 'c'.
~
!!! error TS2304: Cannot find name 'd'.
~
!!! error TS2304: Cannot find name 'e'.



!!! error TS1005: ':' expected.
Loading