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

Port to TypeScript #401

Closed
samreid opened this issue Oct 10, 2021 · 3 comments
Closed

Port to TypeScript #401

samreid opened this issue Oct 10, 2021 · 3 comments
Assignees

Comments

@samreid
Copy link
Member

samreid commented Oct 10, 2021

To help move TypeScript forward and to get the benefits of TypeScript in this repo, we should port it to TypeScript.

@samreid
Copy link
Member Author

samreid commented Oct 11, 2021

Summarizing work so far. It took nearly 3 hours to port all of bending light (8900 lines) to TypeScript. WebStorm tooling provided good support with tooling like "infer types from JSDoc" and "promote to property". The port is not complete due to the following:

  • 76 @ts-ignore, mainly due to strings, and inadequacies in common code
  • implicit any due to numerous non-generic Property and Emitter
  • 58 explicit : any due to inadequancy in common code
  • Some type casting to unknown and to the type, due to inadequancy in common code
  • I haven't added types for the options yet, they are all typed as options?:any
  • Several TODOs marked
  • Incomplete enumeration support

I discovered numerous problems in this port so far, like:

  • Using less than operator to compare number and string.
  • Passing Path options to Shape
  • Places where options are passed through but not received.
  • Numerous bad JSDoc types
  • Numerous sloppy types, where not all types were being handled properly (mostly around null initializers)

samreid added a commit to phetsims/chipper that referenced this issue Oct 11, 2021
samreid added a commit that referenced this issue Oct 11, 2021
samreid added a commit that referenced this issue Oct 11, 2021
samreid added a commit that referenced this issue Oct 11, 2021
samreid added a commit that referenced this issue Oct 11, 2021
samreid added a commit that referenced this issue Oct 11, 2021
samreid added a commit that referenced this issue Oct 11, 2021
samreid added a commit that referenced this issue Oct 11, 2021
samreid added a commit that referenced this issue Oct 11, 2021
samreid added a commit that referenced this issue Oct 11, 2021
@samreid
Copy link
Member Author

samreid commented Oct 11, 2021

In the commits, I added type declaration for strings, better enum support and addressed several TODOs. Total time so far: about 9.5 hours. What's left:

  • 42 ts-ignore
  • 1 any
  • 7 TODO (many from pre-existing problems)

Many of the existing problems are due to inadequacies in common code. I can add better types for options, and look through the any and ts-ignore again, but many things may need to wait until we have common code support.

samreid added a commit that referenced this issue Oct 11, 2021
samreid added a commit that referenced this issue Oct 11, 2021
samreid added a commit to phetsims/chipper that referenced this issue Oct 11, 2021
samreid added a commit that referenced this issue Oct 11, 2021
samreid added a commit that referenced this issue Oct 11, 2021
samreid added a commit that referenced this issue Oct 11, 2021
@samreid
Copy link
Member Author

samreid commented Oct 12, 2021

This port is is good shape and I don't plan other work at the moment. Closing.

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

No branches or pull requests

1 participant