当使用用于打字稿的ui-router类型定义时,模块'ng'没有导出的成员'ui'

Sam*_*tar 5 javascript webstorm angularjs typescript

我正在尝试使用此打字稿定义文件ui-router:

https://github.com/borisyankov/DefinitelyTyped/blob/master/angular-ui/angular-ui-router.d.ts

以下是定义文件顶部的代码:

// Type definitions for Angular JS 1.1.5+ (ui.router module)
// Project: https://github.com/angular-ui/ui-router
// Definitions by: Michel Salib <https://github.com/michelsalib>
// Definitions: https://github.com/borisyankov/DefinitelyTyped

/// <reference path="../angularjs/angular.d.ts" />

declare module ng.ui {

    interface IState {
    ...
Run Code Online (Sandbox Code Playgroud)

这是我如何使用它:

module MyModule
{
    export class MyStateConfig
    {
        constructor(
            //                     -> error on the word ng.ui on next line
            private $stateProvider: ng.ui.IStateProvider, 
            private $urlRouterProvider: ng.ui.IUrlRouterProvider
            ...)
        {
            this.$stateProvider.state(...
Run Code Online (Sandbox Code Playgroud)

这是在Visual Studio中工作但现在使用WebStorm我得到一条消息说"

模块'ng'没有导出成员'ui'

有人可以给我这方面的建议.这与使用WebStorm的不同模块系统有关吗?

cur*_*rpa 5

您是否尝试在模块源文件中添加引用注释?就像是...

/// <reference path="path/to/angular-ui/angular-ui-router.d.ts" />
Run Code Online (Sandbox Code Playgroud)

Visual Studio不需要这个,因为它的msbuild任务会自动告诉编译器引用项目中包含的任何定义.我猜测WebStorm不使用msbuild项目文件.