Skip to content

Commit 0a985ee

Browse files
committed
Parse untyped object type members separated by ','
Previously if the first member was untyped and the separator was ',', then parsing would fail.
1 parent b0f7f2f commit 0a985ee

File tree

5 files changed

+46
-0
lines changed

5 files changed

+46
-0
lines changed

src/compiler/parser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,6 +2339,7 @@ namespace ts {
23392339
token() === SyntaxKind.LessThanToken ||
23402340
token() === SyntaxKind.QuestionToken ||
23412341
token() === SyntaxKind.ColonToken ||
2342+
token() === SyntaxKind.CommaToken ||
23422343
canParseSemicolon();
23432344
}
23442345
return false;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//// [parseObjectLiteralsWithoutTypes.ts]
2+
let x: { foo, bar }
3+
let y: { foo: number, bar }
4+
let z: { foo, bar: number }
5+
6+
7+
//// [parseObjectLiteralsWithoutTypes.js]
8+
var x;
9+
var y;
10+
var z;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
=== tests/cases/compiler/parseObjectLiteralsWithoutTypes.ts ===
2+
let x: { foo, bar }
3+
>x : Symbol(x, Decl(parseObjectLiteralsWithoutTypes.ts, 0, 3))
4+
>foo : Symbol(foo, Decl(parseObjectLiteralsWithoutTypes.ts, 0, 8))
5+
>bar : Symbol(bar, Decl(parseObjectLiteralsWithoutTypes.ts, 0, 13))
6+
7+
let y: { foo: number, bar }
8+
>y : Symbol(y, Decl(parseObjectLiteralsWithoutTypes.ts, 1, 3))
9+
>foo : Symbol(foo, Decl(parseObjectLiteralsWithoutTypes.ts, 1, 8))
10+
>bar : Symbol(bar, Decl(parseObjectLiteralsWithoutTypes.ts, 1, 21))
11+
12+
let z: { foo, bar: number }
13+
>z : Symbol(z, Decl(parseObjectLiteralsWithoutTypes.ts, 2, 3))
14+
>foo : Symbol(foo, Decl(parseObjectLiteralsWithoutTypes.ts, 2, 8))
15+
>bar : Symbol(bar, Decl(parseObjectLiteralsWithoutTypes.ts, 2, 13))
16+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
=== tests/cases/compiler/parseObjectLiteralsWithoutTypes.ts ===
2+
let x: { foo, bar }
3+
>x : { foo: any; bar: any; }
4+
>foo : any
5+
>bar : any
6+
7+
let y: { foo: number, bar }
8+
>y : { foo: number; bar: any; }
9+
>foo : number
10+
>bar : any
11+
12+
let z: { foo, bar: number }
13+
>z : { foo: any; bar: number; }
14+
>foo : any
15+
>bar : number
16+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let x: { foo, bar }
2+
let y: { foo: number, bar }
3+
let z: { foo, bar: number }

0 commit comments

Comments
 (0)