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

fix: Remove <null> from Value to fix TopLevelSpec consumed by code using strict mode. #7352

Merged
merged 3 commits into from
Apr 6, 2021

Conversation

walterra
Copy link
Contributor

@walterra walterra commented Apr 2, 2021

Related to #6912.

When you consume TopLevelSpec like import type { TopLevelSpec } from 'vega-lite'; in a project with strictNullChecks set to true, you'll run into the following error:

ERROR
      node_modules/vega-lite/build/src/vega.schema.d.ts:34:19 - error TS2344: Type 'null' does not satisfy the constraint 'SignalRef | ExprRef'.

      34     value?: Value<null>;
                           ~~~~

      Found 1 error.

The problem seems to be that the generic ES for the Value type doesn't include null. Changing that type to Value<ES extends ExprRef | SignalRef | null = ExprRef | SignalRef | null> fixes it.

An alternative would be to remove the <null> from the code that references Value since the type definition includes ExprRef | SignalRef as a default anyway.

Let me know which version would make more sense and I'll update the PR.

@walterra walterra changed the title Fix: Add null to ES generic to fix TopLevelSpec consumed by code using strict mode. fix: Add null to ES generic to fix TopLevelSpec consumed by code using strict mode. Apr 2, 2021
@domoritz
Copy link
Member

domoritz commented Apr 2, 2021

I think removing the null is cleaner.

Can you check why we have null there?

@walterra
Copy link
Contributor Author

walterra commented Apr 2, 2021

Great, pushed an update that just removes the <null> part. I know too little about the history of the code to know why it's there. The type for Value will allow null because it's part of the PrimitiveValue union type bit so it should be fine.

@walterra
Copy link
Contributor Author

walterra commented Apr 2, 2021

It was introduced here: b404b86

Looking at that change, I think it's safe to remove the <null> part.

@walterra walterra changed the title fix: Add null to ES generic to fix TopLevelSpec consumed by code using strict mode. fix: Remove <null> from Value to fix TopLevelSpec consumed by code using strict mode. Apr 2, 2021
@domoritz
Copy link
Member

domoritz commented Apr 2, 2021

Can you rebuild the schema yarn schema?

@walterra
Copy link
Contributor Author

walterra commented Apr 2, 2021

Just did that, but it didn't produce any changes I could commit. Is there a way to trigger the tests again?

@walterra walterra marked this pull request as ready for review April 2, 2021 19:45
@domoritz
Copy link
Member

domoritz commented Apr 2, 2021

Just did that, but it didn't produce any changes I could commit. Is there a way to trigger the tests again?

Great if there are no changes! Before and after, is there any externally observable change? Can you assign a value that could not be assigned before or vice versa?

To run the test in your fork, you may need to add a github token. Buf it there are no changes, then we should be good.

Let me know and I will review the changes carefully.

@domoritz
Copy link
Member

domoritz commented Apr 4, 2021

I copied this pull request to #7357

@domoritz
Copy link
Member

domoritz commented Apr 6, 2021

This change makes a difference (#7357 (comment)) but since the schema is not affected, this is ok.

Thank you for the pull request.

@domoritz domoritz merged commit 9de2b42 into vega:master Apr 6, 2021
@walterra walterra deleted the wr/toplevelspec-strict-mode branch April 6, 2021 18:29
@walterra
Copy link
Contributor Author

walterra commented Apr 6, 2021

Thanks for merging and doing the follow up!

@walterra
Copy link
Contributor Author

walterra commented Apr 7, 2021

Do you have a usual release schedule? I'm just wondering if you can estimate when this fix will make it into a release? Thanks!

@domoritz
Copy link
Member

domoritz commented Apr 7, 2021

We do not and I want to get a few more things into the 5.1 release. I expect a release in the next two weeks, though.

@walterra
Copy link
Contributor Author

walterra commented Apr 7, 2021

Sounds great, thanks!

jasongrout added a commit to jasongrout/jupyterlab that referenced this pull request Jul 9, 2021
Strict null checking is giving some errors when compiling the docs. For example vega/vega-lite#7352 and another one:

Error: buildutils/src/local-repository.ts:113:34 - error TS2345: Argument of type '{ prev_npm: string; prev_yarn: string; pid: number | undefined; }' is not assignable to parameter of type 'JSONObject'.
  Property 'pid' is incompatible with index signature.
    Type 'number | undefined' is not assignable to type 'JSONValue'.
      Type 'undefined' is not assignable to type 'JSONValue'.

113   utils.writeJSONFile(info_file, data);
                                     ~~~~

Error: node_modules/vega-lite/build/src/vega.schema.d.ts:34:19 - error TS2344: Type 'null' does not satisfy the constraint 'SignalRef | ExprRef'.

34     value?: Value<null>;
                     ~~~~
jasongrout added a commit to jasongrout/jupyterlab that referenced this pull request Jul 9, 2021
Strict null checking is giving some errors when compiling the docs. For example vega/vega-lite#7352 and another one:

Error: buildutils/src/local-repository.ts:113:34 - error TS2345: Argument of type '{ prev_npm: string; prev_yarn: string; pid: number | undefined; }' is not assignable to parameter of type 'JSONObject'.
  Property 'pid' is incompatible with index signature.
    Type 'number | undefined' is not assignable to type 'JSONValue'.
      Type 'undefined' is not assignable to type 'JSONValue'.

113   utils.writeJSONFile(info_file, data);
                                     ~~~~

Error: node_modules/vega-lite/build/src/vega.schema.d.ts:34:19 - error TS2344: Type 'null' does not satisfy the constraint 'SignalRef | ExprRef'.

34     value?: Value<null>;
                     ~~~~
jasongrout added a commit to jasongrout/jupyterlab that referenced this pull request Jul 9, 2021
Strict null checking is giving some errors when compiling the docs. For example vega/vega-lite#7352 and another one:

Error: buildutils/src/local-repository.ts:113:34 - error TS2345: Argument of type '{ prev_npm: string; prev_yarn: string; pid: number | undefined; }' is not assignable to parameter of type 'JSONObject'.
  Property 'pid' is incompatible with index signature.
    Type 'number | undefined' is not assignable to type 'JSONValue'.
      Type 'undefined' is not assignable to type 'JSONValue'.

113   utils.writeJSONFile(info_file, data);
                                     ~~~~

Error: node_modules/vega-lite/build/src/vega.schema.d.ts:34:19 - error TS2344: Type 'null' does not satisfy the constraint 'SignalRef | ExprRef'.

34     value?: Value<null>;
                     ~~~~
blink1073 pushed a commit to jupyterlab/jupyterlab that referenced this pull request Jul 9, 2021
* Restrict version of linting packages

When refreshing the yarn.lock files, with ^ semver ranges on linters, it upgraded the lint packages to newer versions that had different linting decisions (causing lots of formatting changes). I think upgrading lint to new linting decisions should be a very explicit decision (not just refreshing yarn, but actually updating required versions), since lots of formatting changes can be effected.

* Restrict storybook version

* Refresh yarn.lock

This was done by deleting the lock file and installing fresh.

* Fix linting error.

This fixes one place where a promise was not handled.

* Turn off strict null checking for typedoc.

Strict null checking is giving some errors when compiling the docs. For example vega/vega-lite#7352 and another one:

Error: buildutils/src/local-repository.ts:113:34 - error TS2345: Argument of type '{ prev_npm: string; prev_yarn: string; pid: number | undefined; }' is not assignable to parameter of type 'JSONObject'.
  Property 'pid' is incompatible with index signature.
    Type 'number | undefined' is not assignable to type 'JSONValue'.
      Type 'undefined' is not assignable to type 'JSONValue'.

113   utils.writeJSONFile(info_file, data);
                                     ~~~~

Error: node_modules/vega-lite/build/src/vega.schema.d.ts:34:19 - error TS2344: Type 'null' does not satisfy the constraint 'SignalRef | ExprRef'.

34     value?: Value<null>;
                     ~~~~

* Update reference UI screenshots to reflect a single launcher tab not having a close “X”.

In the latest 3.0 release, if a single launcher tab is open, it does not have a close X in the tab (since we must have at least one tab open). In master, the close X does appear, but does nothing when clicking on it. After  #10516, the 3.0 behavior is restored: if a single launcher tab is open, it does not have an X.
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

2 participants