mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
47 lines
1.6 KiB
Plaintext
47 lines
1.6 KiB
Plaintext
arraySigChecking.ts(11,17): error TS1268: An index signature parameter type must be 'string', 'number', 'symbol', or a template literal type.
|
|
arraySigChecking.ts(18,27): error TS2322: Type 'void' is not assignable to type 'string'.
|
|
arraySigChecking.ts(22,13): error TS2322: Type 'number' is not assignable to type 'number[]'.
|
|
arraySigChecking.ts(22,16): error TS2322: Type 'number' is not assignable to type 'number[]'.
|
|
|
|
|
|
==== arraySigChecking.ts (4 errors) ====
|
|
declare namespace M {
|
|
interface iBar { t: any; }
|
|
interface iFoo extends iBar {
|
|
s: any;
|
|
}
|
|
|
|
class cFoo {
|
|
t: any;
|
|
}
|
|
|
|
var foo: { [index: any]; }; // expect an error here
|
|
~~~~~
|
|
!!! error TS1268: An index signature parameter type must be 'string', 'number', 'symbol', or a template literal type.
|
|
}
|
|
|
|
interface myInt {
|
|
voidFn(): void;
|
|
}
|
|
declare var myVar: myInt;
|
|
var strArray: string[] = [myVar.voidFn()];
|
|
~~~~~~~~~~~~~~
|
|
!!! error TS2322: Type 'void' is not assignable to type 'string'.
|
|
|
|
|
|
var myArray: number[][][];
|
|
myArray = [[1, 2]];
|
|
~
|
|
!!! error TS2322: Type 'number' is not assignable to type 'number[]'.
|
|
~
|
|
!!! error TS2322: Type 'number' is not assignable to type 'number[]'.
|
|
|
|
function isEmpty(l: { length: number }) {
|
|
return l.length === 0;
|
|
}
|
|
|
|
isEmpty([]);
|
|
isEmpty(new Array(3));
|
|
isEmpty(new Array<string>(3));
|
|
isEmpty(['a']);
|
|
|