TrilonIO/angular-application-insights

Cannot find type definition file for 'applicationinsights-js'

stas-kh opened this issue ยท 4 comments

Hey Mark,

Thank you for the work you do.

I would like to post a new bug that has appeared recently, in the latest version of the library (5.0.4)

Type: Bug
Environment:

  1. NodeJS - 8.9.0
  2. npm - 5.5.1
  3. Angular - ^6.1.6
  4. Angular CLI - ^6.1.5

Steps to recreate:

  1. Create a new project on Angular 6
  2. Include ng-application-insights library following the instructions
  3. Run ng serve
  4. Check the console
Date: 2018-09-17T16:20:02.648Z
Hash: 49ac821e4e4d98eadfa2
Time: 15821ms
chunk {main} main.js, main.js.map (main) 1.88 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 660 bytes [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 5.22 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 625 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 325 kB [initial] [rendered]

ERROR in node_modules/@markpieszak/ng-application-insights/dist/src/app-insight.service.d.ts(1,23): error TS2688: Cannot find type definition file for 'applicationinsights-js'.
node_modules/@markpieszak/ng-application-insights/dist/src/app-insight.service.d.ts(3,23): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/@markpieszak/ng-application-insights/dist/src/app-insight.service.d.ts(4,51): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/@markpieszak/ng-application-insights/dist/src/app-insight.service.d.ts(43,14): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/@markpieszak/ng-application-insights/dist/src/app-insight.service.d.ts(76,24): error TS2503: Cannot find namespace 'AI'.
node_modules/@markpieszak/ng-application-insights/dist/src/app-insight.service.d.ts(79,24): error TS2503: Cannot find namespace 'AI'.

I think the issue is that @types/applicationinsights-js is in devDependencies. It should be in regular dependencies, hence why your project isn't picking it up.

My simple workaround was to just install it manually in my project -

npm i --save-dev @types/applicationinsights-js

@AustinBrunkhorst thanks for the suggestion, I believe you are right.

I see that the author has moved the typings to peerDependencies in the scope of this commit

Waiting for a comment from @MarkPieszak.

Oh shoot did that move somehow??
I might of been trying to update it and accidentally did a --D to save-dev ๐Ÿคฆโ€โ™‚๏ธ
Let me fix that and release a minor patch release!

Sorry about that everyone!

Fixed! Published to npm as 5.0.5

npm notice ๐Ÿ“ฆ  @markpieszak/ng-application-insights@5.0.5

@stas-kh @AustinBrunkhorst
Thanks for spotting and figuring this one out guys!