javascript - 模块 'ng' 没有导出成员 'ui' 当使用 ui-router type definition for typescript

标签 javascript angularjs typescript webstorm

我正在尝试将此 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 {
    ...

下面是我的使用方法:

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(...

这在 Visual Studio 中工作,但现在使用 WebStorm 我收到一条消息说“

module 'ng' has no exported member 'ui'

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

最佳答案

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

/// <reference path="path/to/angular-ui/angular-ui-router.d.ts" />

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

关于javascript - 模块 'ng' 没有导出成员 'ui' 当使用 ui-router type definition for typescript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27447794/

相关文章:

typescript - 从 QuerySnapshot 获取数据

javascript - .then() 在传递参数时在 setInterval 函数中不起作用?

javascript - 在express.js中设置cookie出现j : prefix

javascript - 为什么这段代码没有按预期工作?

javascript - 使用单个事件处理程序更改多个文本框值

angularjs - 两个单独指令之间的通信

reactjs - Jest + Typescript 如何测试 React 组件中的方法?

typescript - 在 Typescript 中输入变量字符串

javascript - Angular ng-controller 似乎在 route 不起作用

angularjs - 如何访问 Angular 端的nodejs配置参数?