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

Stricter typescript + some cleanups #3570

Merged
merged 5 commits into from
Sep 27, 2022

Conversation

vidartf
Copy link
Member

@vidartf vidartf commented Aug 26, 2022

This increases the typescript strictness, and makes the exceptions that we need explicit (this will also opt us in to any future TS strictness checks by default). In addition to that, the following changes were made:

  • Fix assumptions about all caught errors being instances of Error. With strict checks, TS insists that these are unknown.
  • Further narrow typing of output from _deserialize from Tweak some typings #3554: After deserialization, we know we have a dict of something, but have no idea about what is in it, since deserializers can return anything. Ideally we should also make it explicit in ISerializers that the return type is unknown, but this might be a breaking change.. ?
  • Change the typing of unpack_models so that it is compatible with ISerializers (newly included strictness check will also complain if not). This is because the ISerlializers make all argument optional to allow them to ignore arguments they don't care about, even if the arguments must always be passed by a caller. This is chosen to be the lesser of two evils, but this might be open for discussion.
  • Narrows the typings of the ICallbacks callbacks. Also not clear whether this is an ok change or not.

@github-actions
Copy link

Binder 👈 Launch a binder notebook on branch vidartf/ipywidgets/unpack-typing

Be more explicit about the fact that we don't know the output of deserialized output
This also makes it explicit which exceptions from full strictness that we rely on:
- noImplicitThis: Mostly in backbone patch
- strictPropertyInitialization: a bunch of properties initialized during backbone init calls is not covered correctly for this strict check
- strictFunctionTypes: The ISerializer interface makes all the arguments optional to allow simpler definitions (`deserializer: (value: any): unknown  => { ... }`). However, this does cause `unpack_models` to be typed
There might have been a good reason why these weren't already narrowed, so should check.
Copy link
Member

@martinRenou martinRenou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks

@martinRenou martinRenou merged commit 3148ca3 into jupyter-widgets:master Sep 27, 2022
@vidartf vidartf deleted the unpack-typing branch October 12, 2022 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants