Typescript errors using RequireJS
Closed this issue · 1 comments
Shuffle version
v5.2.3
Describe the bug
Using Typescript compiler to build AMD modules that depends on Shuffle generates wrong constructor code.
Reproduction link
It is so simple that I did not create one.
To Reproduce
There are 2 types of errors when importing the module using Typescript imports:
import Shuffle from "shufflejs"
This way, it is compiled to
define(["require", "exports", "shufflejs"], function (require, exports, shufflejs_1) {});
but the Shuffle variable is always translated to shufflejs_1.default and variable shufflejs_1 seems undefined, so the code do not work.
import Shuffle = require("shufflejs");
The module generated is
define(["require", "exports", "shufflejs"], function (require, exports, Shuffle) {});
and works, but type definitions do not allow me to compile, unless using // @ts-ignore
before every reference to Shuffle types.
I do not know why the module is not instantiated in first example, as the defines seems equals.
Expected behavior
Work with type checkings.
Desktop (please complete the following information):
- OS: Windows 10 and Ububtu 18.04
- Browsers: Chromium and Firefox
- Versions: all updated
I'm not sure how to help here. It's been many years since I've touched RequireJS and I don't know how it works with TypeScript. If you can provide a reduced test case for it, I may be able to help.
You might be better off just ignoring all the types from Shuffle.
// Make sure this file is included in your tsconfig.json
declare module 'shufflejs';