It’s my understanding now that I can declare an interface like this:
interface IParams {
success: bool;
pk: string;
}
and a function like this:
function x () : IParam {
var params = {
success: true,
pk: "xx"
};
return params;
}
This works fine but is there a way that I could do this and have the
params variable only accept values of success and pk? What I want is some way that will stop me from doing the following:
function x () : IParam {
var params = {
successssssssssssss: true,
pk: "xx"
};
return params;
}
Simply putting a type annotation on the var declaration should do what you want: