2014-07-13 01:04:16 +02:00
|
|
|
==== tests/cases/compiler/arraySigChecking.ts (3 errors) ====
|
|
|
|
declare module M {
|
|
|
|
interface iBar { t: any; }
|
|
|
|
interface iFoo extends iBar {
|
|
|
|
s: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
class cFoo {
|
|
|
|
t: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
var foo: { [index: any]; }; // expect an error here
|
|
|
|
~~~~~
|
|
|
|
!!! An index signature parameter type must be 'string' or 'number'.
|
|
|
|
}
|
|
|
|
|
|
|
|
interface myInt {
|
|
|
|
voidFn(): void;
|
|
|
|
}
|
|
|
|
var myVar: myInt;
|
|
|
|
var strArray: string[] = [myVar.voidFn()];
|
2014-07-19 02:30:06 +02:00
|
|
|
~~~~~~~~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type 'void[]' is not assignable to type 'string[]':
|
|
|
|
!!! Type 'void' is not assignable to type 'string'.
|
|
|
|
|
|
|
|
|
|
|
|
var myArray: number[][][];
|
|
|
|
myArray = [[1, 2]];
|
|
|
|
~~~~~~~
|
|
|
|
!!! Type 'number[][]' is not assignable to type 'number[][][]':
|
|
|
|
!!! Type 'number[]' is not assignable to type 'number[][]':
|
|
|
|
!!! Type 'number' is not assignable to type 'number[]':
|
2014-08-12 20:13:15 +02:00
|
|
|
!!! Property 'length' is missing in type 'Number'.
|
2014-07-13 01:04:16 +02:00
|
|
|
|
|
|
|
function isEmpty(l: { length: number }) {
|
|
|
|
return l.length === 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
isEmpty([]);
|
|
|
|
isEmpty(new Array(3));
|
|
|
|
isEmpty(new Array<string>(3));
|
|
|
|
isEmpty(['a']);
|
|
|
|
|