uiuniversal/ngu-carousel

Cannot find name 'HammerStatic'

avrahamwn opened this issue ยท 19 comments

Describe the bug
In my project the library version was "^7.0.0" - which automatically updates minor versions.
Today, when tryimg to build the app as usual, the build failed with the following error message:
Error: node_modules/@ngu/carousel/lib/ngu-carousel/ngu-carousel-hammer-manager.d.ts:6:24 - error TS2304: Cannot find name 'HammerStatic'.

6 load(): Observable;
~~~~~~~~~~~~

Error: node_modules/@ngu/carousel/lib/ngu-carousel/ngu-carousel-hammer-manager.d.ts:16:52 - error TS2304: Cannot find name 'HammerManager'.

16 createHammer(element: HTMLElement): Observable;
~~~~~~~~~~~~~

Error: node_modules/@ngu/carousel/lib/ngu-carousel/ngu-carousel-hammer-manager.d.ts:17:16 - error TS2304: Cannot find name 'HammerManager'.

17 on(hammer: HammerManager, event: string): Observable;
~~~~~~~~~~~~~

Error: node_modules/@ngu/carousel/lib/ngu-carousel/ngu-carousel-hammer-manager.d.ts:17:58 - error TS2304: Cannot find name 'HammerInput'.

17 on(hammer: HammerManager, event: string): Observable;
~~~~~~~~~~~

Then I realized that there was an update in the past day, to version 7.1.3.
I removed the "^" from the version specification, and with version 7.0.0 the build passed successfuly.

To Reproduce
Steps to reproduce the behavior:

Just install the new version 7.1.3

Expected behavior
A clear and concise description of what you expected to happen.

Should build app successfuly.

Additional context
Version of
Angular: 15
carousel: 7.1.3

Would you like to open a PR (Support will be provided):
[ ] Yes
[x] No

Thank you for raising it, we will check it soon.

Hello, I had the same behavior at work.

You need to install @types/hammerjs as devDependencies.

Then add "@types/hammerjs" in the "types" array of your tsconfig (where you need it, eg app, spec, server if you have one, etc)

I have the same issue

anti79 commented

Hello, I had the same behavior at work.

You need to install @types/hammerjs as devDependencies.

Then add "@types/hammerjs" in the "types" array of your tsconfig (where you need it, eg app, spec, server if you have one, etc)

Didn't work for me. Installed hammerjs with --save-dev, tried to add both "hammerjs" and "@types/hammerjs" to tsconfig, still same issue.

Angular: 15.2.9

I have the same issue

#451 (comment) this should work

Hello, I had the same behavior at work.
You need to install @types/hammerjs as devDependencies.
Then add "@types/hammerjs" in the "types" array of your tsconfig (where you need it, eg app, spec, server if you have one, etc)

Didn't work for me. Installed hammerjs with --save-dev, tried to add both "hammerjs" and "@types/hammerjs" to tsconfig, still same issue.

Angular: 15.2.9

You just need @types/hammerjs in tsconfig can you share a small repo if it is still not working

It's not working for me either exactly same issue : Can not find 'HammerStatic' , 'HammerManager' , 'HammerInput' , Angular 16 and Material 16, tried above mentioned solution but didn't work. Angular 16.1.6 exactly. @anti79 let me know if you were able to solve this. Its very urgent for me , stuck on this upgrade.

@anti79 @daansturm any way which worked for you guys?

Hey Everyone, can someone create a small reproduction to check?

above error , I have installed hammerjs 2.0.8 , types@hammerjs as well. Angular 16.1.6 . @santoshyadavdev any inputs will be appreciated.

I used ngx-slick-carousel instead of ngu-carousel.

@PreetiTiwari86 can you share a small reproduction please the image is not going to help us debug the issue, please share stackblitz with sample if possible

somq commented

Same here, works in 7.0.0 to 7.1.2 though.
First guess is that the issue comes from this commit @7.1.3.

Can you share version of hammerjs and @types/hammerjs please

Can you share version of hammerjs and @types/hammerjs please
I am facing same error

"hammerjs": "^2.0.8",
"@types/hammerjs": "^2.0.41",

And in tsconfig

"typeRoots": [
"node_modules/@types"
]

Also for me it is giving error when running ng test
Can someone pls help on this?

Hey @Yberion ,
Thank you. You saved my day.

Following are the steps I followed

  1. Installed following dependencies npm i @ngu/carousel@7.1.3, npm install hammerjs and npm install @types/hammerjs --save-dev
  2. Added "@types/hammerjs" in both of the following files tsconfig.app.json and tsconfig.server.json

Note: Adding "@types/hammerjs" only in tsconfig.app.json is not sufficient. We have to also add in tsconfig.server.json.

file: polyfills.ts

import 'hammerjs';

Hello, I had the same behavior at work.

You need to install @types/hammerjs as devDependencies.

Then add "@types/hammerjs" in the "types" array of your tsconfig (where you need it, eg app, spec, server if you have one, etc)

Installing @types/hammerjs was all that was required for me. Adding that to the tsconfig types array made my IDE complain it couldn't find the definition file for @types/hammerjs (though the app compiled and ran with or without this addition).