Contextual typing of array literals is now based on the presence or absence

of numerically named properties and doesn't directly test for tuple types.
This commit is contained in:
Anders Hejlsberg
2014-08-16 12:06:51 -07:00
parent c0e802deb5
commit 63b83e7c3f
3 changed files with 37 additions and 30 deletions

View File

@@ -16,8 +16,8 @@
t = []; // Error
~
!!! Type '[]' is not assignable to type '[number, string]':
!!! Property '0' is missing in type '[]'.
!!! Type '{}[]' is not assignable to type '[number, string]':
!!! Property '0' is missing in type '{}[]'.
t = [1]; // Error
~
!!! Type '[number]' is not assignable to type '[number, string]':
@@ -53,7 +53,7 @@
tt = [undefined, undefined];
tt = []; // Error
~~
!!! Type '[]' is not assignable to type '[number, string]'.
!!! Type '{}[]' is not assignable to type '[number, string]'.
var a: number[];
var a1: [number, string];