Build error when trying to find type definitions for 'adal'


#1

I have @types/adal in my package.json and everything works fine on my Mac, but in Windows I get the following errors:

> ionic-app-scripts serve

[11:25:01]  ionic-app-scripts 0.0.43
[11:25:02]  watch started ...
[11:25:02]  build dev started ...
[11:25:02]  clean started ...
[11:25:02]  clean finished in less than 1 ms
[11:25:02]  copy started ...
[11:25:02]  transpile started ...
[11:25:11]  typescript: C:/Users/mike/ClientApp/node_modules/ng2-adal/services/adal.service.d.ts, line: 14
            Cannot find namespace 'adal'.

      L13:  logOut(): void;
      L14:  handleWindowCallback(): void;
      L15:  getCachedToken(resource: string): string;

[11:25:11]  typescript: C:/Users/mike/ClientApp/node_modules/ng2-adal/services/adal.service.d.ts, line: 15
            Cannot find namespace 'adal'.

      L14:  handleWindowCallback(): void;
      L15:  getCachedToken(resource: string): string;
      L16:  acquireToken(resource: string): Observable<{}>;

[11:25:11]  typescript: C:/Users/mike/ClientApp/node_modules/ng2-adal/services/adal.service.d.ts, line: 23
            Cannot find namespace 'adal'.

      L22:      GetResourceForEndpoint(url: string): string;
      L23:      private updateDataFromCache(resource);

[11:25:11]  transpile failed
[11:25:11]  copy finished in 9.39 s
[11:25:11]  watch ready in 9.52 s
[11:25:11]  dev server running: http://localhost:8100/

I have an alias in my webpack.config.js:

  resolve: {
    extensions: ['.min.js','.js', '.ts', '.json'],
    alias: { 'adal': 'adal-angular' }
  },

But I don’t think it has anything to do with it. We have tried everything here to figure this out and I am still looking. I hope someone here can lead me in the right direction.

Thanks!!


#2

Well I’ve been working on this all day. I found that I can specify where to get typings definitions in my tsconfig file and if I make it point to a typings folder with type definitions like we used to do with earlier versions, it fails with the same error even on my Mac. So somehow on Windows it is not finding the type definitions under node_modules. Oh well still troubleshooting this. If anyone can help, it is much appreciated.


#3

I would take all typings-related stuff out of tsconfig. Try modeling after this example and these docs.


#4

I did add @types/adal and removed all typings related stuff. It still cannot find the namepace ‘adal’. And I then added:

declare module 'adal';

In my declarations.d.ts file.

Still I get the error. I am trying to see if the developer of ng2-adal or angular2-adal has a solution, since they are consuming the adal library directly.


#5

Ok the solution was to add this type definition to my main.dev.ts file

///<reference path="../../node_modules/ng2-adal/ts/adal/index.d.ts"/>

It references ng2-adal’s own type definitions. Hopefully they will fix it where nothing like this is needed.