typescript 打字稿错误没有成员

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31808152/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 03:03:31  来源:igfitidea点击:

typescript error has no member

angularjstypescript

提问by yozawiratama

i use this :

我用这个:

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

i get error like this :

我得到这样的错误:

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'

how to solve this? and in my visual studio code i get error has no exported member 'IPromise' this is my code :

如何解决这个问题?在我的 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);
    }
}

回答by afaayerhan

As I can see you have multiple type definations for angular-ui-route in your bower_components folder and also in you typings folder go to your bower_components folder and remove the angular-ui-router.d.ts file there. the errors are popoping up because of multiple typedefinations. if you have multiple type definitions in your project and you are compiling everything with it. it would give you this error and other unrelated errors would popup too. I hope this solves your problem

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

回答by aluriax

I believe that is due to the TypeScript package version that you are using. Check the version with

我相信这是由于您使用的 TypeScript 包版本。检查版本

npm list typescript

npm 列表打字稿

If you have installed version 1.4 or higher, try to remove and install an older version, since some changes happened that may be causing those conflicts.

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