File tree 3 files changed +7
-6
lines changed
3 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -89,8 +89,8 @@ export abstract class ManagerBase<T> implements IWidgetManager {
89
89
* Make sure the view creation is not out of order with
90
90
* any state updates.
91
91
*/
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 = { } ) : Promise < VT > {
94
94
const viewPromise = model . state_change = model . state_change . then ( ( ) => {
95
95
return this . loadClass ( model . get ( '_view_name' ) ,
96
96
model . get ( '_view_module' ) ,
Original file line number Diff line number Diff line change @@ -170,8 +170,8 @@ interface IWidgetManager {
170
170
* Make sure the view creation is not out of order with
171
171
* any state updates.
172
172
*/
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 > ;
175
175
176
176
/**
177
177
* callback handlers specific to a view
Original file line number Diff line number Diff line change @@ -691,9 +691,10 @@ class WidgetView extends NativeView<WidgetModel> {
691
691
/**
692
692
* Create and promise that resolves to a child view of a given model
693
693
*/
694
- create_child_view ( child_model : WidgetModel , options = { } ) : Promise < DOMWidgetView > {
694
+ create_child_view < VT extends DOMWidgetView = DOMWidgetView > ( child_model : WidgetModel , options ?: any ) : Promise < VT > ;
695
+ create_child_view < VT extends WidgetView = WidgetView > ( child_model : WidgetModel , options = { } ) : Promise < VT > {
695
696
options = { parent : this , ...options } ;
696
- return this . model . widget_manager . create_view ( child_model , options )
697
+ return this . model . widget_manager . create_view < VT > ( child_model , options )
697
698
. catch ( utils . reject ( 'Could not create child view' , true ) ) ;
698
699
}
699
700
You can’t perform that action at this time.
0 commit comments