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

Use 'void' for the contextual type of an unused expression #40204

Closed
wants to merge 2 commits into from

Conversation

rbuckton
Copy link
Member

This Draft PR primarily is intended to investigate the consequence of contextually typing unused expressions to void.

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Aug 23, 2020
@rbuckton
Copy link
Member Author

@typescript-bot run dt
@typescript-bot test this
@typescript-bot user test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 23, 2020

Heya @rbuckton, I've started to run the extended test suite on this PR at b1d9034. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 23, 2020

Heya @rbuckton, I've started to run the parallelized Definitely Typed test suite on this PR at b1d9034. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 23, 2020

Heya @rbuckton, I've started to run the parallelized community code test suite on this PR at b1d9034. You can monitor the build here.

@rbuckton
Copy link
Member Author

From what I can see, using void as the contextual type of any unused expression seems to be a major breaking change.

@rbuckton
Copy link
Member Author

The most recent commit demonstrates only contextually typing unused await to void.

@rbuckton
Copy link
Member Author

@typescript-bot run dt
@typescript-bot test this
@typescript-bot user test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 24, 2020

Heya @rbuckton, I've started to run the parallelized community code test suite on this PR at 28b39d9. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 24, 2020

Heya @rbuckton, I've started to run the parallelized Definitely Typed test suite on this PR at 28b39d9. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 24, 2020

Heya @rbuckton, I've started to run the extended test suite on this PR at 28b39d9. You can monitor the build here.

@rbuckton
Copy link
Member Author

@typescript-bot user test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 24, 2020

Heya @rbuckton, I've started to run the parallelized community code test suite on this PR at 28b39d9. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master.

@rbuckton
Copy link
Member Author

From the user tests:

chrome-devtools-frontend:

node_modules/chrome-devtools-frontend/front_end/bindings/TempFile.js(77,9): error TS2322: Type '(value?: void | PromiseLike<void>) => void' is not assignable to type '(this: FileReader, ev: ProgressEvent<FileReader>) => any'.
  Types of parameters 'value' and 'ev' are incompatible.
    Type 'ProgressEvent<FileReader>' is not assignable to type 'void | PromiseLike<void>'.
      Property 'then' is missing in type 'ProgressEvent<FileReader>' but required in type 'PromiseLike<void>'.

Due to the fact the contextual type is void instead of unknown, this no longer becomes assignable to the onloadend handler of a FileReader. Addressing this would require either a cast of the promise or changing the code to reader.onloadend = () => resolve();

node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1995,65): error TS2345: Argument of type '(value?: void | PromiseLike<void>) => void' is not assignable to parameter of type '(arg0: Event) => any'.
  Types of parameters 'value' and 'arg0' are incompatible.
    Type 'Event' is not assignable to type 'void | PromiseLike<void>'.
      Property 'then' is missing in type 'Event' but required in type 'PromiseLike<void>'.

In this case, the resolve callback is no longer assignable to the click handler. Addressing this would require casting the promise.

puppeteer

src/node/BrowserFetcher.ts(335,64): error TS2345: Argument of type '(value?: void | PromiseLike<void>) => void' is not assignable to parameter of type '(error: Error) => void'.
  Types of parameters 'value' and 'error' are incompatible.
    Type 'Error' is not assignable to type 'void | PromiseLike<void>'.
      Property 'then' is missing in type 'Error' but required in type 'PromiseLike<void>'.

This is another case of resolve no longer being assignable to an existing callback.

@rbuckton
Copy link
Member Author

At present this does not seem to be a tenable solution. From the user tests, there are several errors where contextually typing to void resulted in breaks in both JS and TS code, as void is too precise. As this was a change intended to reduce breaks caused by #39817, at this time it does not seem to be a viable solution.

@rbuckton rbuckton closed this Aug 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants