oakmac / chessboardjs

JavaScript chessboard
https://chessboardjs.com
MIT License
2k stars 407 forks source link

TypeScript suppot? #152

Open LgArcida opened 6 years ago

LgArcida commented 6 years ago

Can I use this for an Anguar 4 site? If so how?

I am not getting any error but the board is not visible at all.

davidmpaz commented 6 years ago

Usually what you only need is the types definitions. Having that in place, you can compile your application and import the module. Maybe you will need to take care of some issues about how current chessboard is written (which kind of syntax: ES5 or ES6 etc.) in order to configure properly typescript compiler.

I have been working a lot with typescript lately, so I would love to take care at this. Give me some time to try out things and I will report back. For sure if you came up with a type definition earlier it will be perfect.

As documentation:

At end, we should have available types definitions as an npm package @types/chessboardjs which is built from a PR made againts: https://github.com/DefinitelyTyped/DefinitelyTyped

Cheers

snowman745 commented 6 years ago

Hi David, I also am using TypeScript and want to use this chessboard.js class in my code.

Have you had a chance to create the type definition file yet?

profmicrop commented 6 years ago

Hi David,

Have you had create the typescript file for this chessboard.js?

davidmpaz commented 6 years ago

@snowman745 @profmicrop ,

Sorry guys, I did not had the time for this. My apologies. I will find the time today to look at it and start progress.

As a hint I did find this thread: https://stackoverflow.com/questions/43482076/typescript-declaration-file-for-chessboardjs-implicit-import. Which can provides some ideas.

profmicrop commented 6 years ago

Thanks, We are looking forward.. 👍

davidmpaz commented 6 years ago

@snowman745 @profmicrop could you give a try to the files referenced in previous pull request?

supertorpe commented 5 years ago

Currently I'm using chessboard.js in an Ionic 4 / Angular 8 site/app. Simply reference it in angular.json:

"styles": [
    ...,
    {
        "input": "node_modules/chessboardjs/www/releases/0.3.0/css/chessboard-0.3.0.css"
    }
],
"scripts": [
    "node_modules/jquery/dist/jquery.min.js",
    "node_modules/chessboardjs/www/releases/0.3.0/js/chessboard-0.3.0.js"
],

and declare ChessBoard in the code:

declare var ChessBoard: any;

martinlombana commented 4 years ago

Currently I'm using chessboard.js in an Ionic 4 / Angular 8 site/app. Simply reference it in angular.json:

"styles": [
    ...,
    {
        "input": "node_modules/chessboardjs/www/releases/0.3.0/css/chessboard-0.3.0.css"
    }
],
"scripts": [
    "node_modules/jquery/dist/jquery.min.js",
    "node_modules/chessboardjs/www/releases/0.3.0/js/chessboard-0.3.0.js"
],

and declare ChessBoard in the code:

declare var ChessBoard: any;

But you are not getting code completion with your IDE, this way? I use pycharm pro and I don't get code completion if there are no typings for ts.

Thanks

supertorpe commented 4 years ago

@martinlombana You are correct, I don't have code completion, but I can use the component.

martinlombana commented 4 years ago

What about:

https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/chessboardjs

Did someone take a look at these? Are they up to date?