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