35 lines
No EOL
1.2 KiB
Text
35 lines
No EOL
1.2 KiB
Text
==== tests/cases/compiler/objectLitIndexerContextualType.ts (6 errors) ====
|
|
interface I {
|
|
[s: string]: (s: string) => number;
|
|
}
|
|
|
|
interface J {
|
|
[s: number]: (s: string) => number;
|
|
}
|
|
|
|
var x: I;
|
|
var y: J;
|
|
x = {
|
|
s: t => t * t, // Should error
|
|
~
|
|
!!! The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
|
~
|
|
!!! The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
|
};
|
|
x = {
|
|
0: t => t * t, // Should error
|
|
~
|
|
!!! The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
|
~
|
|
!!! The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
|
};
|
|
y = {
|
|
s: t => t * t, // Should not error
|
|
};
|
|
y = {
|
|
0: t => t * t, // Should error
|
|
~
|
|
!!! The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
|
~
|
|
!!! The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
|
}; |