Typescript扩展了dojo类

时间:2018-04-30 23:33:36

标签: typescript dojo

我创建了我认为应该允许我在Typescript中的类实例上调用_WidgetBase声明的方法。问题是,编译器没有看到我声明的部分之间的关​​系。我一定是做错了。

我有以下内容:

/// <reference path="../../../../../../../node_modules/dojo-typings/dojo/1.11/dojo.d.ts" />
/// <reference path="../../../../../../../node_modules/dojo-typings/dijit/1.11/dijit.d.ts" />

declare namespace com {
  namespace foo {
    namespace bar {
      namespace web {
        namespace components {
          namespace form {
            interface ModelObjectMainFormView extends dijit._Widget, dijit._TemplatedMixin, dijit._WidgetsInTemplateMixin, dojo.Evented {
              on(type: string | dojo.ExtensionEvent, func: dojo.EventListener | Function): dojo.WatchHandle;
              emit(type: string | dojo.ExtensionEvent, ...events: any[]): boolean;
            }

            interface ModelObjectFormViewConstructor {
              new (args: Array<any>);
            }

          }
        }
      }
    }
  }
}

/// <reference path="index.d.ts" />

declare module 'com/foo/bar/web/components/form/ModelObjectMainFormView' {
  type ModelObjectMainFormView = com.foo.bar.web.components.form.ModelObjectMainFormView;
  const ModelObjectMainFormView: com.foo.bar.web.components.form.ModelObjectFormViewConstructor;
  export = ModelObjectMainFormView;
}

和:

import declare = require("dojo/_base/declare");
import ModelObjectMainFormView = require("com/foo/bar/web/components/form/ModelObjectMainFormView");

class TSModelObjectMainFormView {
  templateString: string;
  inherited: (args: Object) => any;

  constructor(args?: any) {
    if (args && args.templateString) {
      this.templateString = args.templateString;
      this.inherited(arguments);
    }
  }
}

var exp = declare("com.foo.bar.web.components.form.TSModelObjectMainFormView", [ModelObjectMainFormView], new TSModelObjectMainFormView());
export = exp;

/// <amd-dependency path="dojo/text!com/foo/bar/web/workItems/configuration/forms/templates/ConfigurationWorkItemMainFormView.html" name="template" />
import * as aspect from 'dojo/aspect';
import * as lang from 'dojo/_base/lang';
import GridView = require('com/foo/bar/web/components/grid/GridView');
import * as TSModelObjectMainFormView from '../../../components/form/TSModelObjectMainFormView';
import { ConfigurationWorkItemController } from '../ConfigurationWorkItemController';
let template: string;

export class ConfigurationWorkItemMainFormView extends TSModelObjectMainFormView {
  summaryGrid: GridView;

  constructor(args: any) {
    super(lang.mixin(args, {templateString: template}));
  }

  postCreate(): void {
    this.inherited(arguments);
    this.summaryGrid.setModel(this.getSummaryGridModel());

    this.own(aspect.after(ret,"updateProperty", lang.hitch(this,function(n,v,refresh){
        if(refresh){
          this.summaryGrid.refresh();
        }
      }),true));  
    }
  }
}

这不是一段完整的代码,但它显示了问题。在上面的源代码中对this.own的调用无法编译。物业&#39;拥有&#39;在ConfigurationWorkItemMainFormView类型上不存在。

为什么编译器看不到ConfigurationWorkItemMainFormView正在扩展TSModelObjectMainFormView,它扩展了_Widget,扩展了_WidgetBase,扩展了Destroyable,声明了自己的&#39;?

打字稿版本2.7.2。

非常感谢任何见解。

0 个答案:

没有答案