From 513e637f35c41068cc67c36b1788762c9b095377 Mon Sep 17 00:00:00 2001 From: Michael Kauzmann Date: Tue, 9 May 2023 12:25:31 -0600 Subject: [PATCH] remove usages of AnyScreen outside of joist, and update doc, https://github.com/phetsims/joist/issues/886 --- js/Screen.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/js/Screen.ts b/js/Screen.ts index a59133fc..6377d02b 100644 --- a/js/Screen.ts +++ b/js/Screen.ts @@ -69,10 +69,9 @@ type SelfOptions = { }; export type ScreenOptions = SelfOptions & PhetioObjectOptions & PickRequired; -// Accept any subtype of TModel (defaults to supertype), and any subtype of ScreenView (defaults to subtype). -type CreateView = ( model: M ) => V; - -// The IntentionalAny in the model type is due to https://github.com/phetsims/joist/issues/783#issuecomment-1231017213 +// @joist-internal - This type is uses IntentionalAny to break the contravariance dependency that the createView function +// has on Screen. Ideally we could use TModel instead, but that would involve a rewrite of how we pass closures into +// Screen instead of the already created Model/View themselves. See https://github.com/phetsims/joist/issues/783#issuecomment-1231017213 export type AnyScreen = Screen; // Parameterized on M=Model and V=View @@ -92,7 +91,7 @@ class Screen extends PhetioObject { public readonly createKeyboardHelpNode: null | ( ( tandem: Tandem ) => Node ); // joist-internal public readonly pdomDisplayNameProperty: TReadOnlyProperty; private readonly createModel: () => M; - private readonly createView: CreateView; + private readonly createView: ( model: M ) => V; private _model: M | null; private _view: V | null; @@ -105,7 +104,7 @@ class Screen extends PhetioObject { documentation: 'Section of a simulation which has its own model and view.' } ); - public constructor( createModel: () => M, createView: CreateView, providedOptions: ScreenOptions ) { + public constructor( createModel: () => M, createView: ( model: M ) => V, providedOptions: ScreenOptions ) { const options = optionize()( {