swipe
swipe copied to clipboard
SwipeJS is not a module to import
it seems to be forgot to export Swipe,so the es6 or ts module can not import,hope to update the swipe.d.ts file
You should just import swipejs, i.e.:
import "swipejs";
(as per this stackoverflow: https://stackoverflow.com/questions/40441252/typescript-typings-give-me-index-d-ts-is-not-a-module).
The above, using Rollup (es6 imports) didn't work for me.
The following works fine: import Swipe from 'swipejs';
In my TypeScript project built with create-react-app, this did not work:
import "swipejs";
It compiled OK but failed at runtime when my code called new Swipe
. It appears that Webpack depends on the names you specify in the import to know what types to rename (in this case, Swipe).
The import statement you really want is the one given by @powellian above:
import Swipe from "swipejs";
...however, the TypeScript compiler chokes on this with the error:
File 'node_modules/swipejs/types/swipe.d.ts' is not a module. TS2306
I was able to fix this by changing this line in swipe.d.ts in my local node_modules folder:
declare class Swipe {
to
export default class Swipe {
As soon as I made this change, everything worked. So I'm with @paddy-wu, the swipe.d.ts file needs to be changed to fix this issue. I'll be happy to do a PR for this if you want.
Hi, The version 2.2.16 is out with the file "types/swipe.d.ts" on the version 2.2.13, I cleared npm cache deleted node modules but a fresh install of 2.2.16 always brings the types of version 2.2.13. In #130 this fix should be out on 2.2.16 can anyone confirm the same issue?
Upon checking master types/swipe.d.ts file is not updated with #130 PR
I have gone deep and it seems that on 17th of March the #130 was merged, however on 30th of March @lyfeyaj reverted this changes on the commit dd788653b62eb525e1312e17c715982c4f34e646
@JoseCMRocha: The change made by @lyfeyaj to types/swipe.d.ts on March 30th did not exactly revert my changes from PR #130. Instead, my change to use "export default" syntax was removed and "export = " syntax was added in its place; note that the file now ends in the line:
export = Swipe;
I'm not sure why @lyfeyaj made this change. But I'm fine with it ether way; it seems like both forms work fine in my application. I'm not seeing any versioning problems as you described.

in my case the issue still remains - just installed Swipe to give it a test drive. I have the lastest version.
@RandScullard Here is why I've made this change: https://www.typescriptlang.org/docs/handbook/declaration-files/templates/module-class-d-ts.html
@JoseCMRocha 2.2.13 was a typo, is fixed in version 2.2.18
@mkbctrl You may need to change your tsconfig.json
file as following:
{
"compilerOptions": {
"moduleResolution": "node"
}
}
For further information, please check below link: https://github.com/Microsoft/TypeScript/issues/8920#issuecomment-223052268 and https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Module%20Resolution.md