Parse untyped object type members separated by ','

Previously if the first member was untyped and the separator was ',',
then parsing would fail.
This commit is contained in:
Nathan Shively-Sanders 2016-08-26 13:25:19 -07:00
parent b0f7f2f99c
commit 0a985ee287
5 changed files with 46 additions and 0 deletions

View file

@ -2339,6 +2339,7 @@ namespace ts {
token() === SyntaxKind.LessThanToken ||
token() === SyntaxKind.QuestionToken ||
token() === SyntaxKind.ColonToken ||
token() === SyntaxKind.CommaToken ||
canParseSemicolon();
}
return false;

View file

@ -0,0 +1,10 @@
//// [parseObjectLiteralsWithoutTypes.ts]
let x: { foo, bar }
let y: { foo: number, bar }
let z: { foo, bar: number }
//// [parseObjectLiteralsWithoutTypes.js]
var x;
var y;
var z;

View file

@ -0,0 +1,16 @@
=== tests/cases/compiler/parseObjectLiteralsWithoutTypes.ts ===
let x: { foo, bar }
>x : Symbol(x, Decl(parseObjectLiteralsWithoutTypes.ts, 0, 3))
>foo : Symbol(foo, Decl(parseObjectLiteralsWithoutTypes.ts, 0, 8))
>bar : Symbol(bar, Decl(parseObjectLiteralsWithoutTypes.ts, 0, 13))
let y: { foo: number, bar }
>y : Symbol(y, Decl(parseObjectLiteralsWithoutTypes.ts, 1, 3))
>foo : Symbol(foo, Decl(parseObjectLiteralsWithoutTypes.ts, 1, 8))
>bar : Symbol(bar, Decl(parseObjectLiteralsWithoutTypes.ts, 1, 21))
let z: { foo, bar: number }
>z : Symbol(z, Decl(parseObjectLiteralsWithoutTypes.ts, 2, 3))
>foo : Symbol(foo, Decl(parseObjectLiteralsWithoutTypes.ts, 2, 8))
>bar : Symbol(bar, Decl(parseObjectLiteralsWithoutTypes.ts, 2, 13))

View file

@ -0,0 +1,16 @@
=== tests/cases/compiler/parseObjectLiteralsWithoutTypes.ts ===
let x: { foo, bar }
>x : { foo: any; bar: any; }
>foo : any
>bar : any
let y: { foo: number, bar }
>y : { foo: number; bar: any; }
>foo : number
>bar : any
let z: { foo, bar: number }
>z : { foo: any; bar: number; }
>foo : any
>bar : number

View file

@ -0,0 +1,3 @@
let x: { foo, bar }
let y: { foo: number, bar }
let z: { foo, bar: number }