我正在尝试获取 Ember.js 库的定义以使用 TypeScript。每当我尝试引用 ember-1.0.d.ts 文件时,我都会收到 43 个错误实例:
The name 'Ember' does not exist in the current scope.
我正在使用安装了 TypeScript 和 Web Essentials 包的 Visual Studio 2012,我想这可能是我自己的配置有问题我试图从 DefinitiveType 项目加载不同的 .d.ts。我试图引用 Angular.js 定义文件,它没有给我任何错误,所以我假设定义文件有问题。
https://github.com/borisyankov/DefinitelyTyped/blob/master/Definitions/ember-1.0.d.ts
此错误的原因可能是什么?
这是给我错误的部分之一,Ember.* 部分被标记为错误:
export interface Enumerable extends Mixin {
// Fields
firstObject: Object;
hasEnumerableObservers: bool;
lastObject: Object;
nextObject: Object;
// Methods
addEnumerableObserver(target, opts);
compact(): any[];
contains(obj: Object): bool;
enumerableContentDidChange(removing: number, adding: number): Object;
enumerableContentDidChange(removing: Ember.Enumerable, adding: Ember.Enumerable): Object;
enumerableContentDidChange(start: Number, removing: number, adding: number): Object;
enumerableContentDidChange(start: Number, removing: Ember.Enumerable, adding: Ember.Enumerable): Object;
enumerableContentWillChange(removing: number, adding: number): Ember.Enumerable;
enumerableContentWillChange(removing: Ember.Enumerable, adding: Ember.Enumerable): Ember.Enumerable;
enumerableContentWillChange(start: Number, removing: number, adding: number): Ember.Enumerable;
enumerableContentWillChange(start: Number, removing: Ember.Enumerable, adding: Ember.Enumerable): Ember.Enumerable;
every(callback: Function, target?: Object): bool;
everyProperty(key: string, value?: string): any[];
filter(callback: Function, target?: Object): any[];
filterProperty(key: string, value?: string): any[];
find(callback: Function, target?: Object): Object;
findProperty(key: string, value?: string): Object;
/*forEach
getEach
invoke
map
mapProperty
reduce
removeEnumerableObserver
setEach
some
someProperty
toArray
uniq
without*/
}