Closed
Description
Currently it is not possible to set a type for a key in the object literal.
interface A {
x: number;
y: string;
}
var a = {
// I would assume the following syntax
// <A>q: { ... }
q: {
x: 1,
y: "a"
}
}
However it is possible to cast a literal value but it is not the same.
interface A {
x: number;
y: string;
}
var a = {
// q has type 'A', and we can write anything that compatible to that literal.
q: <A>{
x: 1,
y: "a"
}
}