typescript错误没有成员

时间:2015-08-04 11:31:25

标签: angularjs typescript

我用这个:

/// <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'

如何解决这个问题? 在我的视觉工作室代码我得到错误没有导出成员&#39; IPromise&#39; 这是我的代码:

///<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);
    }
}

2 个答案:

答案 0 :(得分:2)

我可以看到你在bower_components文件夹和你的打字文件夹中有多种类型的angular-ui-route定义 转到你的bower_components文件夹并删除angular-ui-router.d.ts文件。由于多个类型定义,错误正在流行。如果您的项目中有多个类型定义,并且您正在使用它编译所有内容。它会给你这个错误,其他不相关的错误也会弹出。我希望这能解决你的问题

答案 1 :(得分:1)

我认为这是由于您正在使用的TypeScript包版本。使用

检查版本
  

npm list typescript

如果您安装了1.4或更高版本,请尝试删除并安装旧版本,因为发生了一些可能导致这些冲突的更改。