我正在尝试获取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,认为这可能是我自己的配置问题我试图从DefinitelyType项目加载不同的.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*/
}
答案 0 :(得分:1)
我在Visual Studio中进行了两项更改以使其正常工作。
在声明中我改变了:
declare module "Ember" {
要
declare module Ember {
在你的界面中我改变了:
interface Enumerable extends Mixin {
要
interface Enumerable extends Ember.Mixin {
此后所有的警告都消失了。