-
Notifications
You must be signed in to change notification settings - Fork 902
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
Consider supporting Typescript #253
Comments
I just came here and saw this awesome ml5js module for js users, it's really fantastic! And I would like to vote YES for writing code in TypeScript because it will really help us to save lots of time to maintain the code with higher quality. Here's a wonderful TypeScript talk from Anders Hejlsberg at here |
We have discussed this a few times, but given the size of the project now, I think this is a very reasonable change to explore and possible make. Will take some time to update the source but might be worth it. Perhaps we can discuss this in more detailed on our January meetup? @shiffman, what are your thoughts on this? |
I've never really used Typescript, but when I quickly hacked ml5 to have the classifier support Canvas input, understanding the supported types of the arguments and variables was my main struggle. |
@nathanvogel Yes, that's exactly why we need TypeScript! |
I am very happy to revisit this discussion! My thinking has been to stay with JavaScript in terms of the project being easier to contribute to for beginner coders and alignment with p5.js (I like opening up the source code in class to show how the library works and have it be recognizable for students). @oveddan brings up a lot of good points. Let's discuss next week during our meetings at ITP, I'll be sending out some e-mails about that soon! |
This came up a bit in our discussions at ITP yesterday. One idea proposed was to do this incrementally and maybe use typescript for new models/classes we are adding to ml5 and see how that goes. Would that be possible? Keeping the existing code base as is (for now) and adding a new class with typescript as a trial run? |
Here's a nice quick intro to TypeScript for those so interested! (Like me) https://dev.to/robertcoopercode/get-started-with-typescript-in-2019-6hd |
Hey just got back in town. I think trying it for one or two new models makes sense. It should definitely be possible to do with javascript and typescript side by side. I can take a stab at this for the BodyPix implementation. |
Right now when you attempt to install type definitions for ml5 like so npm install --save-dev @types/ml5 you are met with the following error:
As a deeply invested Following is a list of helpful resources: https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html |
Hi, I like this library and I'm in support of having a Has anyone started working on this? I'm happy to take a quick stab otherwise. EDIT: A quick draft that I did |
any updates? |
@kresli - Thanks for checking in. It definitely is helpful to help gauge interest in certain features. |
news? |
Is it done? Please update the thread if it's done. |
Hi All, We're certainly excited about Typescript and the potential for more maintainable and predictable code behavior, but our priority is to focus on creating less entry barriers to contribution. If there's particular motivation, please feel free to suggest or point to resources for ways we might integrate Typescript in a nice way! Thanks! Making a note of the helpful resources from @mateja176 #253 (comment) |
I'd suggest not writing (or re-writing) all/any of As an example, P5 itself already has published TypeScript type definitions (just type "P5" into the search bar). |
Has there been any movement on this? |
Hi, I found a way to use ml5 with Typescript using few simple tricks. You may call it just a workaround till we have support for Typescript. I have a written a blog post on this. Check it out |
Maybe trying ts-migrate(https://github.com/airbnb/ts-migrate)? ex passing 3 parameters even though the function requires 2 parameters. The migration could be helpful to detect unknown issues |
I have used the draft from @dikarel in my starter pack for ML5 with webpack and TS setup. https://github.com/dejavu1987/ml5-typescript-webpack It is a nice way to start, will happily contribute. |
I am interesting in writing types for this package. Would the maintainers consider switching the codebase over to Typescript, or should the types be managed separately as part of the DefinitelyTyped project? I've created type definitions for a package on DefinitelyTyped before but that one was pretty easy as the type types were simple and well-defined. The advantage of writing Typescript into the code as opposed to adding on declarations from outside is that it allows me to see what the types are really supposed to be based on errors in the functions. There are some things in the JSDoc that need way more information in order to be useful Typescript. For example the |
I converted one model ( The part that I really cannot get my head around is something in the JSDoc which seems to contradict what I'm actually seeing in the code. It says that Here's how I typed
|
do you even typescript xD what makes typescript beautiful is you can see all the types and the IntelliSense is superb looks clean and neat. |
If you cannot re-write the entire codebase in Typescript then please at least create separate type definitions ( |
Hi @azzazkhan -- thanks! My thinking has definitely shifted on this over the last couple years and I'd be happy to support incrementally updating ml5 to TS. @lindapaiste has some work open for this #1388 If you have some time and could review some of the PRs related to the PR linked above, that'd definitely move us closer to making this happen! TY! |
d.ts declaration file please! |
Any news? |
I want to open the discussion here around allowing models to be developed in typescript in ml5. I feel like using Typescript would bring many advantages.
I know there is the argument that we want to make ml5 easy for people new to coding to contribute to, and that by throwing in Typescript they'd have to learn something new on top of javascript and it would potentially hinder them from contributing. I actually would think in the long term it would make it easier for them to contribute and make it faster for them to fix bugs and add features because of the points stated above. They should be able to learn the basics of Typescript by seeing existing code in the repo and reading some intro documentation (it's very well documented) and once they get over that hump with VSCode's awesome typescript integration they'd have a much better experience coding with the repo.
I think a basic start would be to allow (but not require) new models to be made in Typescript. This could be a trial.
What are your thoughts?
The text was updated successfully, but these errors were encountered: