chrisbateman / impetus

Agnostic utility for adding momentum to anything. It's like iScroll, except not for scrolling. Supports mouse and touch events.
chrisbateman.github.io/impetus
MIT License
487 stars 70 forks source link

Adding support for Typescript #50

Closed mobileben closed 4 years ago

mobileben commented 5 years ago

I'm new to the Javascript/Typescript game. This library looked useful and was looking to incorporate it into a Typescript project, but, due to my inexperience with integrating modules that aren't Typescript and don't have a declaration file, I am having difficulty getting this integrated. I've tried to import this via

import { Impetus } from 'impetus'

When run, I'll get a Uncaught TypeError: impetus_1.Impetus is not a constructor. When looking at the dist code, I do see that it ends up creating a var Impetus = function Impetus(_ref).

So admittedly it isn't clear to me how that would translate to a class.

Are there any plans to add in Typescript support?

I'm considering just dropping this into a .ts file, since it is relatively small.

gianlucag commented 4 years ago

Got the same problem, I'm now trying to build a custom TypeScript version of the library

chrisbateman commented 4 years ago

This is unrelated to TypeScript - you're getting is not a constructor because your variable is undefined. It's a default export rather than a named export:

import Impetus from 'impetus';