23 lines
674 B
Text
23 lines
674 B
Text
|
==== tests/cases/compiler/indexSignatureTypeCheck2.ts (4 errors) ====
|
||
|
class IPropertySet {
|
||
|
[index: string]: any
|
||
|
}
|
||
|
|
||
|
var ps: IPropertySet = null;
|
||
|
var index: any = "hello";
|
||
|
ps[index] = 12;
|
||
|
|
||
|
interface indexErrors {
|
||
|
[p2?: string];
|
||
|
~~
|
||
|
!!! An index signature parameter cannot have a question mark.
|
||
|
[...p3: any[]];
|
||
|
~~
|
||
|
!!! An index signature cannot have a rest parameter.
|
||
|
[p4: string, p5?: string];
|
||
|
~~
|
||
|
!!! An index signature must have exactly one parameter.
|
||
|
[p6: string, ...p7: any[]];
|
||
|
~~
|
||
|
!!! An index signature must have exactly one parameter.
|
||
|
}
|