Im trying to build an Angular application for a chessgame. I want to use the library chess.js https://github.com/jhlywa/chess.js/blob/master/README.md with the types declared in https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/chess.js But whenever i run the application theres an error on runtime.
I've installed the packages through npm with
npm install --save chess.js @types/chess.js
And in the service that uses the library i've got this relevant code:
import {Chess, ChessInstance} from "chess.js"
@Injectable({
providedIn: 'root'
})
export class GameService {
private chess: ChessInstance = new Chess()
constructor() {}
...
}
The error i get is:
core.js:15724 ERROR Error: Uncaught (in promise): TypeError: chess_js__WEBPACK_IMPORTED_MODULE_4__.Chess is not a constructor
TypeError: chess_js__WEBPACK_IMPORTED_MODULE_4__.Chess is not a constructor
I've also tried importing it as:
import * as Chessjs from "chess.js"
@Injectable({
providedIn: 'root'
})
export class GameService {
private chess: Chessjs.ChessInstance = new Chessjs.Chess()
constructor() {}
...
}
To no success.
I've also tried declaring chess.js from my app.module.ts, but that seems to be the wrong way about importing non-module scripts
Any help would be widely appreciated