相关疑难解决方法(0)

从泛型类中的type参数创建新对象

我正在尝试在我的泛型类中创建一个类型参数的新对象.在我的类中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: …
Run Code Online (Sandbox Code Playgroud)

generics typescript

121
推荐指数
6
解决办法
11万
查看次数

标签 统计

generics ×1

typescript ×1