-
Notifications
You must be signed in to change notification settings - Fork 947
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
WidgetManagerBase: Improve create_view return type #2662
WidgetManagerBase: Improve create_view return type #2662
Conversation
Is this still relevant given the discussion on removing |
We're removing display_model/display_view in favor of keeping and using create_view. |
092660e
to
1f4262b
Compare
@jasongrout would it be fine to merge this PR? |
options = { parent: this, ...options}; | ||
return this.model.widget_manager.create_view(child_model, options) | ||
return this.model.widget_manager.create_view<VT>(child_model, options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think once you have the overrides, you won't need to specify the type parameter here, as it should select the right override.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! Thanks you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it does not seem to compile without it:
src/widget.ts:696:9 - error TS2322: Type 'Promise<DOMWidgetView>' is not assignable to type 'Promise<VT>'.
Type 'DOMWidgetView' is not assignable to type 'VT'.
'DOMWidgetView' is assignable to the constraint of type 'VT', but 'VT' could be instantiated with a different subtype of constraint 'WidgetView'.
696 return this.model.widget_manager.create_view(child_model, options)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
697 .catch(utils.reject('Could not create child view', true));
I feel like this compilation error is not legit though, as DOMWidgetView
is a subclass of WidgetView
, what do you think?
4ec05d9
to
65346ed
Compare
Signed-off-by: martinRenou <martin.renou@gmail.com>
378c679
to
480f1bc
Compare
Given a video widget model
VideoModel
which has an associated viewVideoView
. The following code does not compile:With the following error:
This PR allows doing: