components icon indicating copy to clipboard operation
components copied to clipboard

Slide Toggle Doesn't Seem to be working in Alpha 7 Error: Cannot find name 'HammerInput'

Open naveedahmed1 opened this issue 10 years ago • 17 comments

HI,

I just upgraded to Alpha 7 and after upgrade Slide Toggle seems to be broken.

When I compile my project in Visual Studio 2015 I receive the below errors:

Error       Build:Cannot find name 'HammerInput'.   node_modules\@angular2-material\slide-toggle\slide-toggle.d.ts  67  

Error   TS2304  Cannot find name 'HammerInput'. TypeScript Virtual Projects node_modules\@angular2-material\slide-toggle\slide-toggle.d.ts  67

Apparently it seems that the below line is causing the problem in slide-toggle.d.ts:

_onDrag(event: HammerInput): void;

naveedahmed1 avatar Aug 09 '16 22:08 naveedahmed1

I guess you didn't install the typings for HammerJS?

https://github.com/angular/material2/blob/master/GETTING_STARTED.md#additional-setup-for-md-slide-toggle-and-md-slider

typings i dt~hammerjs --global --save

devversion avatar Aug 09 '16 23:08 devversion

Install hammerjs and its typings. With alpha7, angular2 rc5, typescript 2.0 and webpack (through angular-cli) this worked for me:

npm install --save hammerjs @types/hammerjs

And then import 'hammerjs' in your main component.

adrm avatar Aug 10 '16 10:08 adrm

@naveedahmed1 installing the typings for HammerJS should resolve this.

jelbourn avatar Aug 10 '16 17:08 jelbourn

Thank you everyone installing typings through command:

npm install --save hammerjs @types/hammerjs

and then importing it in main file solved the issue.:

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

naveedahmed1 avatar Aug 10 '16 17:08 naveedahmed1

For those finding this issue that have a similar configuration to mine: angular-material: 2.0.0-alpha.7-3 angular-cli: 1.0.0-beta.11-webpack.2

Just doing the following: $ npm install --save hammerjs @types/hammerjs

Was all that was needed. Since my tsconfig.json file contains this line: "typeRoots": [ "../node_modules/@types" ]

I did not have to make any changes to main.ts

ctkdev avatar Aug 17 '16 14:08 ctkdev

In addition to ctkdev's solution I had to add hammerjs to the "types" section in tsconfig.json

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

uncledlm avatar Aug 17 '16 18:08 uncledlm

I had to use @ctkdev and @uncledlm solutions. Now everything is working fine :+1:

Kosmonaft avatar Aug 17 '16 23:08 Kosmonaft

Seems like you didn't load the HammerJS library

import 'hammerjs'; // Recommended

or

<!-- Not recommended when using Webpack -->
<script src="./node_modules/hammerjs/hammer.js">

devversion avatar Aug 18 '16 13:08 devversion

@DevVersion you're right (sorry I deleted my message by mistake).

vapits avatar Aug 18 '16 13:08 vapits

@vapits No worries - glad I could help :)

devversion avatar Aug 18 '16 13:08 devversion

I had to use I had to use @ctkdev and @uncledlm and @DevVersion solutions =D

I did the import in polyfills.ts (using angular-cli webpack)

medeirosrich avatar Sep 21 '16 13:09 medeirosrich

Using angular-cli@latest (webpack)

I added hammerjs

npm install --save hammerjs @types/hammerjs

then on the last line of src/polyfills.ts I added import 'hammerjs';

petersgiles avatar Sep 26 '16 23:09 petersgiles

@ctkdev and @uncledlm solutions worked perfectly

whitewaves avatar Oct 14 '16 12:10 whitewaves

Hi, doing what suggested above this solve the loading issue but now I get a typescript error: error TS2300: Duplicate identifier 'TouchAction'

this is just an sample one, I get a lot of those (I assume these are all related to hammerjs) although the app seems to work fine.

Any idea? Thanks!

aviramga avatar Oct 26 '16 14:10 aviramga

Is all of this documented somewhere other than the issues section? Thank God for the internet + googling...yeesh!

MikeGitIt avatar Nov 06 '16 02:11 MikeGitIt

This should be included in the getting started guide!

shaozi avatar Nov 16 '16 17:11 shaozi

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.