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

LocaleProperty does not set its type. #1000

Closed
pixelzoom opened this issue Dec 9, 2024 · 2 comments
Closed

LocaleProperty does not set its type. #1000

pixelzoom opened this issue Dec 9, 2024 · 2 comments

Comments

@pixelzoom
Copy link
Contributor

pixelzoom commented Dec 9, 2024

Discovered while working on secondLocaleProperty: LocaleProperty in phetsims/number-pairs#22 ...

In localeProperty.ts, LocaleProperty is exported so that clients can create other instances. But unlike other Property subclasses, LocaleProperty does not set its phetioValueType or valueType, and leaves that to clients. So I'm getting this error in Number Pairs:

Assertion failed: PhET-iO Properties must specify a phetioValueType: numberPairs.global.model.preferences.secondLocaleProperty

The singleton localeProperty is instantiated like this:

const localeProperty = new LocaleProperty( phet.chipper.locale, {
  tandem: Tandem.GENERAL_MODEL.createTandem( 'localeProperty' ),
  valueType: 'string',
  phetioFeatured: true,
  phetioValueType: StringIO,
  phetioDocumentation: 'Specifies language currently displayed in the simulation'
} );

So this should be a matter of moving valueType: 'string' and phetioValueType: StringIO to a LocaleProperty constructor (it currently has a default a constructor) and defining LocalePropertyOptions.

Discussed with @zepumph in Slack#developer, and the above sounds correct and desirable, so I'll go for it.

@pixelzoom
Copy link
Contributor Author

... So this should be a matter of moving valueType: 'string' and phetioValueType: StringIO to a LocaleProperty constructor (it currently has a default a constructor) and defining LocalePropertyOptions.

... which is exactly what I did in 4810d1d.

@zepumph would you please review? Close if OK.

@zepumph
Copy link
Member

zepumph commented Dec 9, 2024

Perfect. Thank you for doing this.

@zepumph zepumph assigned pixelzoom and unassigned zepumph Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants