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

Get rid of as unknown as Node in traits #1498

Closed
11 of 12 tasks
jessegreenberg opened this issue Nov 11, 2022 · 2 comments
Closed
11 of 12 tasks

Get rid of as unknown as Node in traits #1498

jessegreenberg opened this issue Nov 11, 2022 · 2 comments

Comments

@jessegreenberg
Copy link
Contributor

jessegreenberg commented Nov 11, 2022

In phetsims/joist#881 @samreid showed a way to get rid of the as unknown as Node for traits.

The way to make the type cast unecessary is to declare Node as the type for the constructor with

const Voicing = <SuperType extends Constructor<Node>>( Type: SuperType )

We should use that for other traits too!

I see this as unknown as Node in

  • ParallelDOM - this isn't a trait anymore, but the type casts are still necessary because of old implementation that used to assume trait. Would be nice to get rid of someday, but its larger than this issue.
  • Paintable
  • InteractiveHighlighting
  • ReadingBlock
  • Voicing
  • HeightSizable
  • Sizable
  • WidthSizable
  • DelayedMutate
  • AccessibleNumberSpinner
  • AccessibleSlider
  • AccessibleValueHandler
@jessegreenberg
Copy link
Contributor Author

@jonathanolson are you OK with this? I wanted to run it by you because it touched Paintable, Sizable, WidthSizable, HeightSizable, DelayedMutate.

@veillette veillette changed the title Get rid of as uknown as Node in traits Get rid of as unknown as Node in traits Feb 1, 2023
@jonathanolson
Copy link
Contributor

This looks great! It didn't used to work in previous TypeScript versions, I'm very glad it works now!

@jonathanolson jonathanolson moved this from Review to On Hold in Jonathan Olson's Board Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants