课程'查看'错误地扩展了基类' Backbone.View'

时间:2015-09-03 18:38:58

标签: javascript backbone.js typescript

我尝试从Backbone.View扩展的每个文件中都会出现此错误/警告。编译器仍然运行,JavaScript按预期工作。即使有一个空类,它也会抛出同样的错误:

/// <reference path="references/backbone.d.ts" />

module Test {
  export class View extends Backbone.View<Model> {

  }
}

我使用的参考文件是Boris Yankov的DefinitelyTyped库中的最新文件。 View类定义为:

class View <TModel extends Model> extends Events {

  /**
   * Do not use, prefer TypeScript's extend functionality.
   **/
  private static extend(properties: any, classProperties?: any): any;

  constructor(options?: ViewOptions<TModel>);
  initialize(options?: ViewOptions<TModel>): void;

  /**
   * Events hash or a method returning the events hash that maps events/selectors to methods on your View.
   * For assigning events as object hash, do it like this: this.events = <any>{ "event:selector": callback, ... };
   * That works only if you set it in the constructor or the initialize method.
   **/
  events(): any;

  $(selector: string): JQuery;
  model: TModel;
  collection: Collection<TModel>;
  //template: (json, options?) => string;
  setElement(element: HTMLElement, delegate?: boolean): View<TModel>;
  setElement(element: JQuery, delegate?: boolean): View<TModel>;
  id: string;
  cid: string;
  className: string;
  tagName: string;

  el: any;
  $el: JQuery;
  setElement(element: any): View<TModel>;
  attributes: any;
  $(selector: any): JQuery;
  render(): View<TModel>;
  remove(): View<TModel>;
  make(tagName: any, attributes?: any, content?: any): any;
  delegateEvents(events?: any): any;
  undelegateEvents(): any;

  _ensureElement(): void;
}

如果编译器有点冗长并告诉我 我错误地扩展了类,那会有所帮助。是否有任何强制要求延长Backbone.View课程并防止在我的每个视图中出现这种神秘的警告?

或者,我能否至少压制警告?如果我将这个View类扩展了很多次,那么在编译时很难找到真正的错误。

0 个答案:

没有答案