I have the following class that will be the basis for the entities of the application
namespace Base {
export abstract class BaseEntity {
endpoint: string;
public abstract getId(): string;
}
}
and the implementation of this class is given in this way:
namespace Example {
export class Account extends Base.BaseEntity {
accountId?: string;
name?: string;
constructor() {
super();
this.endpoint = "accounts";
}
public getId(): string {
return this.accountId;
}
}
}
the purpose of this is to be able to obtain the value of the property endpoint
of each class to know the url of the web method defined in a Web Api.
Here the example:
namespace Base {
export class BaseService<T extends BaseEntity> {
private url: string;
constructor(
private $q: angular.IQService,
private $http: angular.IHttpService) {
this.url = 'http://localhost:81/api/${(<BaseEntity>T).endpoint}'; //ERROR: 'T' only refers to a type, but is being used as a value here.
}
}
}
but I get the following error about this ${(<BaseEntity>T).endpoint}
statement:
// ERROR: 'T' only refers to a type, but is being used as a value here.