Seeking assistance with an issue.
We are working with two interfaces:
interface IUserEntity {
Id: number;
FirstName: string;
LastName: string;
}
interface IUserEntityMethods {
GetFullName(): string;
}
I am trying to create an object that adheres to the IUserEntityMethods
type, but I want to access properties of the IUserEntity
interface within the GetFullName
method using this
, and have autocomplete support in Webstorm (or other IDE).
The desired outcome:
var userEntityMethods: IUserEntityMethods = {
GetFullName: function() {
return this.FirstName + " " + this.LastName; // This line should be error-free.
}
}
Is this achievable? Are there any alternative approaches?