TypeScript/tests/baselines/reference/arraySigChecking.errors.txt

52 lines
1.9 KiB
Plaintext
Raw Normal View History

tests/cases/compiler/arraySigChecking.ts(11,17): error TS1023: An index signature parameter type must be 'string' or 'number'.
2014-11-05 21:26:03 +01:00
tests/cases/compiler/arraySigChecking.ts(18,5): error TS2322: Type 'void[]' is not assignable to type 'string[]'.
Type 'void' is not assignable to type 'string'.
2014-11-05 21:26:03 +01:00
tests/cases/compiler/arraySigChecking.ts(22,1): error TS2322: Type 'number[][]' is not assignable to type 'number[][][]'.
Type 'number[]' is not assignable to type 'number[][]'.
Type 'number' is not assignable to type 'number[]'.
Property 'length' is missing in type 'Number'.
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
~~~~~
!!! error TS1023: An index signature parameter type must be 'string' or 'number'.
2014-07-13 01:04:16 +02:00
}
interface myInt {
voidFn(): void;
}
var myVar: myInt;
var strArray: string[] = [myVar.voidFn()];
~~~~~~~~
2014-11-05 21:26:03 +01:00
!!! error TS2322: Type 'void[]' is not assignable to type 'string[]'.
!!! error TS2322: Type 'void' is not assignable to type 'string'.
2014-07-13 01:04:16 +02:00
var myArray: number[][][];
myArray = [[1, 2]];
~~~~~~~
2014-11-05 21:26:03 +01:00
!!! error TS2322: Type 'number[][]' is not assignable to type 'number[][][]'.
!!! error TS2322: Type 'number[]' is not assignable to type 'number[][]'.
!!! error TS2322: Type 'number' is not assignable to type 'number[]'.
!!! error TS2322: 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']);