Я создал то, что, по моему мнению, должно позволить мне вызывать методы, объявленные _WidgetBase, для экземпляра класса в Typescript. Проблема в том, что компилятор не видит отношения между частями, которые я объявил. Должно быть, я что-то делаю не так.
У меня есть следующее:
/// <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 в приведенном выше источнике не компилируется. Свойство 'own' не существует для типа ConfigurationWorkItemMainFormView.
Почему компилятор не видит, что ConfigurationWorkItemMainFormView расширяет TSModelObjectMainFormView, который расширяет _Widget, который расширяет _WidgetBase, который расширяет Destroyable, который объявляет «свое»? *
Машинопись версии 2.7.2.
Очень ценю любые идеи.