Skip to content

TypeScript: Invalid module name in augmentation - rzslider.d.ts #591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MiroslavKral opened this issue Nov 14, 2017 · 4 comments
Closed

Comments

@MiroslavKral
Copy link

We are upgrading our application from AngularJS 1.5 to Angular 5. With Angular 5, there is TypeScript 2.4. We are building with webpack 3.8.1 and error is:

Error:(6, 16) TS2665:Invalid module name in augmentation. Module 'angular' resolves to an untyped module at /node_modules/angular/index.js', which cannot be augmented.

We have angularjs-slider 6.4.0.

Steps to reproduce

  1. Use angularjs-slider in TypeScript 2.4 project or with Angular 5.

Expected behaviour

It is possible to fix this by moving angular import into module declaration in rzslider.d.ts:

declare module "angular" {

    import * as angular from "angular";

    export namespace RzSlider {
         ...
    }
}

Actual behaviour

Actually, angular import is outside module declaration in rzslider.d.ts:

import * as angular from "angular";

declare module "angular" {

    export namespace RzSlider {
         ...
    }
}
@trodi
Copy link
Contributor

trodi commented Nov 15, 2017

This library doesn't support Angular 2+. See #549 (comment) .

Looking at other d.ts files for angular projects (e.g., angular-toastr, angular-translate, angular-ui-bootstrap), they all follow the same pattern as done in this project. Looking at the tsc error of yours, it appears that you don't have @types/angular installed. I've not tested with typescript 2.4, but I believe everything should work in an Angular 1.x app as long as you've installed the @types/angular as well.

Hope this helps.

@MiroslavKral
Copy link
Author

MiroslavKral commented Nov 15, 2017

Thanks for reply and solution. We have hybrid application with AgularJS 1.5 and Angular 5 and angularjs-slider is used only in AngularJS part.

But I installed @types/angular and everything works now.

I found my solution there: https://stackoverflow.com/a/42702089

So this is not issue and it can be closed ;-)

@trodi
Copy link
Contributor

trodi commented Nov 17, 2017

Glad to help.

@ValentinH , can you close this? Also, should we update the installation section of the readme to indicate that typescript definitions are included and if using them, there is a peer dependency on @types/angular?

@ValentinH
Copy link
Member

Yeah sure. Would you like to update the readme ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants