제 일반 클래스에서 유형 매개 변수의 새 객체를 만들려고합니다. 내 클래스 View에는 유형 매개 변수로 전달 된 일반 유형의 객체 목록이 2 개 있지만 new TGridView(), 만들려고 할 때 TypeScript는 다음과 같이 말합니다.
'TGridView 기호를 찾을 수 없습니다
이것은 코드입니다.
module AppFW {
// Represents a view
export class View<TFormView extends FormView, TGridView extends GridView> {
// The list of forms
public Forms: { [idForm: string]: TFormView; } = {};
// The list of grids
public Grids: { [idForm: string]: TGridView; } = {};
public AddForm(formElement: HTMLFormElement, dataModel: any, submitFunction?: (e: SubmitFormViewEvent) => boolean): FormView {
var newForm: TFormView = new TFormView(formElement, dataModel, submitFunction);
this.Forms[formElement.id] = newForm;
return newForm;
}
public AddGrid(element: HTMLDivElement, gridOptions: any): GridView {
var newGrid: TGridView = new TGridView(element, gridOptions);
this.Grids[element.id] = newGrid;
return newGrid;
}
}
}
제네릭 형식에서 개체를 만들 수 있습니까?
new()요구하는 경우 또는보다 일반적인 요구 사항type: {new(...args : any[]): T ;}