Module 'ng' does not have exported member 'ui' when using ui-router type definition for typescript

I am trying to use this typescript definition file for ui-router :

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

Here is the code at the top of the definition file:

 // 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 { ... 

Here is how I use it:

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

This worked in Visual Studio, but now with WebStorm I get a message with the message "

module 'ng' does not have exported element 'ui'

Can someone give me some advice on this. Is this somehow related to another modular system with WebStorm?

+5
source share
2 answers

Have you tried adding a link to the source file of your module? Sort of...

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

Visual Studio does not require this because its msbuild tasks automatically tell the compiler to refer to any definition included in the project. I assume WebStorm is not using msbuild project files.

+4
source
  • Make sure the @ types / angular-ui-bootstrap npm package is installed.

    npm install @types/angular-ui-bootstrap

  • Check the tsConfig.json file, find the types array in compilerOptions . Try removing types or replacing with typeRoots . Something like that:

    "compilerOptions": { "target": "ES5", "sourceMap": true, .... .... "typeRoots": [ "node_modules/@types" ] },

0
source

Source: https://habr.com/ru/post/1208896/


All Articles