phetsims / joist

Joist is the main framework for PhET Interactive Simulations. Joist creates and displays the simulation content, home screen, navigation bar, About dialog, enables switching between tabs, and other framework-related features.
http://scenerystack.org/
MIT License
9 stars 6 forks source link

Updates to typescript handling of i18n dynamic strings #892

Closed zepumph closed 1 year ago

zepumph commented 1 year ago

While working on https://github.com/phetsims/chipper/issues/1366, I found that most of the @ts-expect-errors in joist have to do with the newish dynamic locales, mapping a locale string to a general string and then trying to pull the string union back out. Luckily, in my working copy I'm finding it quite easy to base everything on the typeof the locale map object for exact type checking.

zepumph commented 1 year ago

Ok. I had good success here. I like all of the changes, specifying Locale instead of string is a huge improvement in joist and expanded to a large number of other places.

samreid commented 1 year ago

I found some sims such as Molecule Shapes allow empty english strings, so I adjusted the assertion. Tagging @zepumph in case this is unexpected.