我用这个:
/// <reference path="typings/jquery/jquery.d.ts" />
/// <reference path="typings/angularjs/angular.d.ts" />
/// <reference path="typings/angularjs/angular-animate.d.ts" />
/// <reference path="typings/angular-ui-router/angular-ui-router.d.ts" />
/// <reference path="typings/angular-ui-bootstrap/angular-ui-bootstrap.d.ts" />
/// <reference path="typings/angular-file-upload/angular-file-upload.d.ts" />
/// <reference path="typings/selectize/selectize.d.ts" />
我收到这样的错误:
Access/Interfaces.ts(5,52): error TS2305: Module 'ng' has no exported member 'IPromise'.
Access/Interfaces.ts(6,123): error TS2305: Module 'ng' has no exported member 'IPromise'.
bower_components/angular-ui-router/api/angular-ui-router.d.ts(31,38): error TS2304: Cannot find name 'IServiceProvider'.
bower_components/angular-ui-router/api/angular-ui-router.d.ts(49,42): error TS2304: Cannot find name 'IServiceProvider'.
bower_components/angular-ui-router/api/angular-ui-router.d.ts(82,63): error TS2304: Cannot find name 'IPromise'.
typings/angularjs/angular-animate.d.ts(18,30): error TS2305: Module 'ng' has no exported member 'IAugmentedJQuery'.
typings/angularjs/angular-animate.d.ts(19,30): error TS2305: Module 'ng' has no exported member 'IAugmentedJQuery'.
typings/angularjs/angular-animate.d.ts(20,33): error TS2305: Module 'ng' has no exported member 'IAugmentedJQuery'.
typings/angularjs/angular-animate.d.ts(21,36): error TS2305: Module 'ng' has no exported member 'IAugmentedJQuery'.
typings/angularjs/angular-animate.d.ts(22,33): error TS2305: Module 'ng' has no exported member 'IAugmentedJQuery'.
typings/angularjs/angular.d.ts(17,1): error TS2440: Import declaration conflicts with local declaration of 'ng'
如何解决这个问题? 在我的 Visual Studio 代码中,我收到错误没有导出成员“IPromise” 这是我的代码:
///<reference path="../all.ts" />
module Interface{
'use strict'
export interface IAccessService {
Login(PhoneNumber: string,
Password: string): ng.IPromise<any>;
Register(Email: string,
PhoneNumber : string,
Password: string,
RePassword: string,
Fullname: string,
BirthDate: Date,
Sex: string[]): ng.IPromise<any>;
GetTokenFromCookies(): string;
Put(token: string);
}
}
最佳答案
正如我所见,您的 Bower_components 文件夹以及您的typings 文件夹中都有 Angular-ui-route 的多种类型定义 转到 Bower_components 文件夹并删除其中的 angular-ui-router.d.ts 文件。由于多种类型定义,会弹出错误。如果您的项目中有多个类型定义并且您正在用它来编译所有内容。它会给你这个错误,其他不相关的错误也会弹出。我希望这能解决您的问题
关于angularjs - typescript 错误没有成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31808152/