-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Woodpile37/TypeScript
#10Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code
Description
Not sure if this is an error or just me not understanding it:
interface ITestInterface
{
// this doesn't compile
myMap: {
[id:string]:string;
}
// this compiles
//myMap: {
// "1": string;
// "2": string;
// "3": string;
// "4": string;
//};
}
var testObject:ITestInterface = {
myMap: {
"1": "a",
"2": "b",
"3": "c",
"4": "d"
}
};
var testObject2 = {
myMap: {
"1": "a",
"2": "b",
"3": "c",
"4": "d"
}
};
function testFunction(testInterface:ITestInterface) {
}
// this works:
testFunction(testObject);
// this causes a compile error, why?
testFunction(testObject2);
Supplied parameters do not match any signature of call target:
Types of property 'myMap' of types '{ myMap: { "1": string; "2": string; "3": string; "4": string; }; }' and 'ITestInterface' are incompatible:
Index signatures of types '{ "1": string; "2": string; "3": string; "4": string; }' and // '{ [id: string]: string; }' are incompatible.
Could not select overload for 'call' expression.
Metadata
Metadata
Assignees
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code