File tree Expand file tree Collapse file tree 3 files changed +9
-6
lines changed
Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -89,8 +89,9 @@ export abstract class ManagerBase<T> implements IWidgetManager {
8989 * Make sure the view creation is not out of order with
9090 * any state updates.
9191 */
92- create_view ( model : DOMWidgetModel , options : any ) : Promise < DOMWidgetView > ;
93- create_view ( model : WidgetModel , options = { } ) : Promise < WidgetView > {
92+ create_view < VT extends DOMWidgetView = DOMWidgetView > ( model : DOMWidgetModel , options ?: any ) : Promise < VT > ;
93+ create_view < VT extends WidgetView = WidgetView > ( model : WidgetModel , options ?: any ) : Promise < VT > ;
94+ create_view < VT extends WidgetView = WidgetView > ( model : WidgetModel , options = { } ) : Promise < VT > {
9495 const viewPromise = model . state_change = model . state_change . then ( ( ) => {
9596 return this . loadClass ( model . get ( '_view_name' ) ,
9697 model . get ( '_view_module' ) ,
Original file line number Diff line number Diff line change @@ -170,8 +170,8 @@ interface IWidgetManager {
170170 * Make sure the view creation is not out of order with
171171 * any state updates.
172172 */
173- create_view ( model : DOMWidgetModel , options ?: unknown ) : Promise < DOMWidgetView > ;
174- create_view ( model : WidgetModel , options ?: unknown ) : Promise < WidgetView > ;
173+ create_view < VT extends DOMWidgetView = DOMWidgetView > ( model : DOMWidgetModel , options ?: unknown ) : Promise < VT > ;
174+ create_view < VT extends WidgetView = WidgetView > ( model : WidgetModel , options ?: unknown ) : Promise < VT > ;
175175
176176 /**
177177 * callback handlers specific to a view
Original file line number Diff line number Diff line change @@ -691,9 +691,11 @@ class WidgetView extends NativeView<WidgetModel> {
691691 /**
692692 * Create and promise that resolves to a child view of a given model
693693 */
694- create_child_view ( child_model : WidgetModel , options = { } ) : Promise < DOMWidgetView > {
694+ create_child_view < VT extends DOMWidgetView = DOMWidgetView > ( child_model : DOMWidgetModel , options ?: any ) : Promise < VT > ;
695+ create_child_view < VT extends WidgetView = WidgetView > ( child_model : WidgetModel , options ?: any ) : Promise < VT > ;
696+ create_child_view < VT extends WidgetView = WidgetView > ( child_model : WidgetModel , options = { } ) : Promise < VT > {
695697 options = { parent : this , ...options } ;
696- return this . model . widget_manager . create_view ( child_model , options )
698+ return this . model . widget_manager . create_view < VT > ( child_model , options )
697699 . catch ( utils . reject ( 'Could not create child view' , true ) ) ;
698700 }
699701
You can’t perform that action at this time.
0 commit comments