components icon indicating copy to clipboard operation
components copied to clipboard

Cannot find name 'HammerManager' and Cannot find name 'HammerInput'.

Open st-clair-clarke opened this issue 10 years ago • 9 comments

Bug,

I am attempting to using material2, angular-cli and angular-modules. Placing the angular2-material components including the core module into a custom shared-module. Attempting to use the shared-module always results in the following

client:49 [default] J:\workspace\angular2\ts\epimss\node_modules@angular2-material\slide-toggle\slide-toggle.d.ts:67:19 Cannot find name 'HammerInput'.

client:49 [default] J:\workspace\angular2\ts\epimss\node_modules@angular2-material\core\gestures\MdGestureConfig.d.ts:4:39 Cannot find name 'HammerManager'.

Removing the modules and the cli runs normally otherwise. I have seen many mentions of similar problems by googling and on stack overflow but none of the solutions helped.

I have saved hammerjs and @types/hammerjs to my package.json but this did not help. I tried installing hammerjs globally without resolution of the poblem either.

Hope this issue could be resolved soon.

I am using the latest angular-cli@webpack.

Thanks

st-clair-clarke avatar Aug 15 '16 03:08 st-clair-clarke

I had this same problem and fixed it an hour ago. Once hammerjs was installed, i had to make a reference to it in main.ts. Right at the top. Add:

/// <reference path="../typings/globals/hammerjs/index.d.ts" />

Be sure it's pointing to the right file in your project. Again, I don't know enough to say why it worked, but it did. Someone smarter can probably figure out why. Hope it helps.

kevinkoperski avatar Aug 15 '16 04:08 kevinkoperski

Wouldn't it be better to add the typings/index.d.ts?

/// <reference path="../typings/index.d.ts" />

I'm not sure why the webpack cli isn't adding that by default.

JSMike avatar Aug 15 '16 05:08 JSMike

Duplicate of #797

RoxKilly avatar Aug 15 '16 07:08 RoxKilly

Please have a look at below link, I think this is what you need:

https://github.com/angular/material2/issues/977#issuecomment-238946558

naveedahmed1 avatar Aug 15 '16 10:08 naveedahmed1

Solved at https://github.com/angular/material2/issues/977#issuecomment-238946558 - third comment by @adrm

st-clair-clarke avatar Aug 15 '16 11:08 st-clair-clarke

@st-clair-clarke I'm not sure why we should considered that a solution rather than a workaround? A third-party library like ng-Material should not be causing compilation errors. Ideally it would include all it needs. What do you think?

RoxKilly avatar Aug 15 '16 13:08 RoxKilly

Try installing @types/hammerjs : npm i --save-dev @types/hammerjs

Then edit tsconfig.json file and add hammerjs to the types section.

"types": [ "jasmine", "hammerjs" ]

uncledlm avatar Aug 18 '16 13:08 uncledlm

npm i --save-dev @ types/hammerjs solved problem. remove space after @

priyankaa-123 avatar Jun 15 '17 05:06 priyankaa-123

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.