The Wayback Machine - https://web.archive.org/web/20201127110419/https://github.com/BrainJS/brain.js/issues/551
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to TypeScript #551

Open
mubaidr opened this issue May 17, 2020 · 121 comments
Open

Migrate to TypeScript #551

mubaidr opened this issue May 17, 2020 · 121 comments

Comments

@mubaidr
Copy link
Contributor

@mubaidr mubaidr commented May 17, 2020

We plan to gradually migrate brain.js to TypeScript, code base is pretty large, so we would love your help! 💪

How to contribute?

  • Convert a file from .js to .ts
  • Add types, fix all type errors.
  • Submit a PR! 🎉

Here you can find a guide on how to contribute.

Want to convert something, let us know in the comment and go ahead! 😎

To avoid duplicate work please comment on which part you want to work on (as long as nobody else is working on it) so we can mark it as taken.

Reach out to us!
Feel free to reach if you have questions or need help getting started. You can leave comments here or you can tag me in your PR if you need any help or you're not sure about something!

You can also get in touch on our Gitter & Slack.

Happy Coding! 🤟


UPDATE:

Wohoooo!!! 🎉

All files inside src directory are migrated to typescript. (Except few ones which are already taken up and being worked on), though we are still looking on improvements to types in these files and removing any types from the source. You are welcome to contribute. 😊

__tests__ directory has still some files left that needs migration to typescript, so feel free to pick em up! 🍭


UPDATE

For anyone looking to contribute, here is the list of files that still needs typescript migration:

https://github.com/BrainJS/brain.js/search?l=javascript&p=1

@mubaidr mubaidr pinned this issue May 17, 2020
@mubaidr mubaidr mentioned this issue Jun 15, 2020
0 of 10 tasks complete
@yashshah1
Copy link
Contributor

@yashshah1 yashshah1 commented Jul 25, 2020

I'd like to start working on this, I have some experience with Ts, can you tell me which module is up for grabs?

@mubaidr
Copy link
Contributor Author

@mubaidr mubaidr commented Jul 25, 2020

@yashshah1 You are welcome to contribute, please pick any module or portion for conversion and mention it here, so I can mark it in-progress (to avoid any duplication effort).

@nabeelvalley
Copy link
Contributor

@nabeelvalley nabeelvalley commented Aug 5, 2020

I'd like to work on this too, any recommendations on where to start?

@mubaidr
Copy link
Contributor Author

@mubaidr mubaidr commented Aug 5, 2020

@nabeelvalley here is the short guide, super simple to start. Please pick any module or portion for conversion and mention it here, so I can mark it in-progress (to avoid any duplication effort).

Here you can find a guide on how to contribute.

@nabeelvalley
Copy link
Contributor

@nabeelvalley nabeelvalley commented Aug 6, 2020

@mubaidr I'm working from the utilities up, to avoid having untyped dependencies

The tests seem to be failing when I convert the file to JS because it looks like Jest is running against the TS files instead of the compiled JS - has the TS Compile been configured?

Looks like the tests are also currently failing:

Test Suites: 1 failed, 5 passed, 6 of 64 total
Tests:       9 failed, 114 passed, 123 total
Snapshots:   0 total
Time:        206.723 s

It appears that the soft-max tests are receiving a Float32Array instead of a plain array - should I look where the Float32 is coming from or should I update the unit tests to expect a Floar32Array instead?

The data returned looks exactly the same, it's just that the object types are different so the deep equality is failing:

Example for one of the tests below:

  ● SoftMax › .compare2D › can run on a simple matrix

    assert.deepEqual(received, expected)

    Expected value to deeply equal to:
      [[-0, 2], [3, 4]]
    Received:
      [[-0, 2], [3, 4]]

    Difference:

    - Expected
    + Received

      Array [
    -   Array [
    +   Float32Array [
          -0,
          2,
        ],
    -   Array [
    +   Float32Array [
          3,
          4,
        ],
      ]
@mubaidr
Copy link
Contributor Author

@mubaidr mubaidr commented Aug 9, 2020

Yes, you can update test to expect Float32Array.

In the mean-time some tests might still fail, because they have not yet been updated recently. You can can continue working and make sure build process is successful and conversion does not cause increase in no. of failed tests.

@HarshKhandeparkar
Copy link
Contributor

@HarshKhandeparkar HarshKhandeparkar commented Aug 28, 2020

Hi! I want to help. If I convert one file, do I need to convert related files too or something? Or just a single file?

@mubaidr
Copy link
Contributor Author

@mubaidr mubaidr commented Aug 28, 2020

You don't need to updated all the related files, just go file by file and make sure build is successful.

@HarshKhandeparkar
Copy link
Contributor

@HarshKhandeparkar HarshKhandeparkar commented Aug 28, 2020

Utilities is taken, isnt it?

@HarshKhandeparkar
Copy link
Contributor

@HarshKhandeparkar HarshKhandeparkar commented Aug 28, 2020

Activation functions seem like a good place to start, may I work on it?

@nabeelvalley
Copy link
Contributor

@nabeelvalley nabeelvalley commented Aug 28, 2020

Utilities is taken, isnt it?

Hi @HarshKhandeparkar, I haven't had a chance to work on this you're welcome to take utilities if you want, just note that needs to be updated above

@HarshKhandeparkar
Copy link
Contributor

@HarshKhandeparkar HarshKhandeparkar commented Aug 28, 2020

Np @nabeelvalley. I think I'll work on activation functions :)

@HarshKhandeparkar HarshKhandeparkar mentioned this issue Aug 28, 2020
3 of 12 tasks complete
@HarshKhandeparkar
Copy link
Contributor

@HarshKhandeparkar HarshKhandeparkar commented Aug 29, 2020

@nabeelvalley I think I managed to fix the jest error you were facing in #582. You may copy paste my changes to jest.config.json or wait for the PR to be merged :)

@HarshKhandeparkar
Copy link
Contributor

@HarshKhandeparkar HarshKhandeparkar commented Aug 29, 2020

estimator/ has a single file. Looks like a nice 🎯.

@HarshKhandeparkar HarshKhandeparkar mentioned this issue Aug 29, 2020
3 of 12 tasks complete
@HarshKhandeparkar
Copy link
Contributor

@HarshKhandeparkar HarshKhandeparkar commented Aug 30, 2020

I think I'll snipe some of the utilities next, if you don't mind @nabeelvalley.

@HarshKhandeparkar
Copy link
Contributor

@HarshKhandeparkar HarshKhandeparkar commented Aug 30, 2020

You would have probably started in alphabetical order(I am assuming), so I am going to start from the bottom.

@HarshKhandeparkar
Copy link
Contributor

@HarshKhandeparkar HarshKhandeparkar commented Sep 1, 2020

Going to snipe utilities/values* tonight :)

@robertleeplummerjr
Copy link
Contributor

@robertleeplummerjr robertleeplummerjr commented Sep 1, 2020

Huzzah!

@mubaidr
Copy link
Contributor Author

@mubaidr mubaidr commented Sep 1, 2020

Build systems seems to be broken, I am looking into this issue. 🧯

@HarshKhandeparkar
Copy link
Contributor

@HarshKhandeparkar HarshKhandeparkar commented Sep 1, 2020

Can I continue or should I wait?

@mubaidr
Copy link
Contributor Author

@mubaidr mubaidr commented Sep 1, 2020

You should continue your contributions! I will try to fix it asap.

@grigori-gru
Copy link
Contributor

@grigori-gru grigori-gru commented Oct 22, 2020

@mubaidr
which files can I take?

@mubaidr
Copy link
Contributor Author

@mubaidr mubaidr commented Oct 23, 2020

We have following available:

  • https://github.com/BrainJS/brain.js/blob/master/__tests__/praxis/arthur-deviation-biases/end-to-end.js
  • https://github.com/BrainJS/brain.js/blob/master/__tests__/praxis/arthur-deviation-weights/end-to-end.js
  • https://github.com/BrainJS/brain.js/blob/master/__tests__/recurrent/end-to-end.js
grigori-gru added a commit to grigori-gru/brain.js that referenced this issue Oct 23, 2020
mubaidr added a commit that referenced this issue Oct 24, 2020
#551 arthur-deviation-biases/end-to-end to ts
@dhairyagada
Copy link
Contributor

@dhairyagada dhairyagada commented Oct 24, 2020

@mubaidr I'll be taking up https://github.com/BrainJS/brain.js/blob/master/__tests__/recurrent/end-to-end.js

@shubhi23994
Copy link

@shubhi23994 shubhi23994 commented Oct 25, 2020

Hey! Would like to pick up some work here. I can help with removing any type or converting the file to typescript(although I don't see any file pending). You can direct me to "what is still pending"

@dhairyagada dhairyagada mentioned this issue Oct 25, 2020
4 of 11 tasks complete
@mubaidr
Copy link
Contributor Author

@mubaidr mubaidr commented Oct 25, 2020

@shubhi23994 That would be great! You can run npm run lint to identify any usages. Looking forward!

@mubaidr
Copy link
Contributor Author

@mubaidr mubaidr commented Oct 25, 2020

For anyone looking to contribute, here is the list of files that still needs typescript migration:

https://github.com/BrainJS/brain.js/search?l=javascript&p=1

@luisgregson
Copy link

@luisgregson luisgregson commented Oct 27, 2020

Looks like childrens-book.js has already been converted. I'm going to convert https://github.com/BrainJS/brain.js/blob/370502c92ce228148524bc3bff95eac304a559a5/examples/javascript/predict-tense.js if that's not being worked on atm?

@dhairyagada
Copy link
Contributor

@dhairyagada dhairyagada commented Oct 27, 2020

@mubaidr
Copy link
Contributor Author

@mubaidr mubaidr commented Oct 27, 2020

@luisgregson @dhairyagada Please wait for input from @robertleeplummerjr I think he was working on these, if otherwise, you can then work on these, please.

@robertleeplummerjr
Copy link
Contributor

@robertleeplummerjr robertleeplummerjr commented Oct 27, 2020

Yea, nearly done, but was away last week. Look for by end of week something for review. @dhairyagada I'd love to get your help on it, however.

@luisgregson
Copy link

@luisgregson luisgregson commented Oct 27, 2020

@mubaidr @robertleeplummerjr
Sorry, i couldn't see neural-network.js mentioned here so i thought it was free. I'll stop working on it. But let me know if you want any help 🙂

@robertleeplummerjr
Copy link
Contributor

@robertleeplummerjr robertleeplummerjr commented Oct 27, 2020

Sorry, neural-network.js is free, I am working on rnn.js.

@mubaidr
Copy link
Contributor Author

@mubaidr mubaidr commented Oct 27, 2020

@luisgregson You can continue working on neural-network.js, please 👍🏼

@dhairyagada
Copy link
Contributor

@dhairyagada dhairyagada commented Oct 28, 2020

Yea, nearly done, but was away last week. Look for by end of week something for review. @dhairyagada I'd love to get your help on it, however.

Sure @robertleeplummerjr , I would love to help! Please let me know how can I contribute to it

@robertleeplummerjr
Copy link
Contributor

@robertleeplummerjr robertleeplummerjr commented Nov 17, 2020

I have pushed up the RNN changes to https://github.com/BrainJS/brain.js/tree/rnn-ts @dhairyagada. If you want to check it out. It is nearly complete in script conversion, but I've not tested it entirely yet. The typescript fails around serializing and deserializing from JSON.

@dhairyagada
Copy link
Contributor

@dhairyagada dhairyagada commented Nov 22, 2020

I have pushed up the RNN changes to https://github.com/BrainJS/brain.js/tree/rnn-ts @dhairyagada. If you want to check it out. It is nearly complete in script conversion, but I've not tested it entirely yet. The typescript fails around serializing and deserializing from JSON.

Sure @robertleeplummerjr I'll check it out

@HarshKhandeparkar
Copy link
Contributor

@HarshKhandeparkar HarshKhandeparkar commented Nov 25, 2020

Wow, this has made a lot of progress! Is there anything left where I can help?

@robertleeplummerjr
Copy link
Contributor

@robertleeplummerjr robertleeplummerjr commented Nov 25, 2020

I've got rnn.ts nearly done, upgrades to the data-formatter.ts (because they are so heavily linked) and some minor fixes along with the to-svg.ts fixes. I even found a (semi naughty) way of fixing some weirdness we were seeing in equation.ts. I'll have them pushed tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.