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

chore: Upgrade TypeScript to 3.6 #5559

Merged
merged 1 commit into from Mar 31, 2020
Merged

Conversation

jackfranklin
Copy link
Collaborator

Continues the work to get up to TS 3.8 (latest release at time of
writing).

This version of TS introduced built in definitions for web workers that
include an interface Worker so TS gets confused when it sees us
reference a Worker. I have renamed the imports to PuppeteerWorker as
I couldn't figure out a way to tell TS to not load in the worker types;
longer term we might consider renaming Worker to PuppeteerWorker (or
an alternative) but that would be a breaking change that we don't need
right now.

The other fix is to solve an issue where the ws library doesn't
implement a dispatchEvent method - which is not a problem - but TS
expects it to. I've used @ts-ignore on that error because it's
absolutely fine and not something we rely on.

@jackfranklin
Copy link
Collaborator Author

@TimvdLippe happy to take any thoughts you have on TypeScript and if there's better workarounds.

My approach here is I'd rather do the minimum reasonable fixes to get TS happy so we can get up to 3.8, and then solve these problems "properly" when we migrate the source code to .ts.

tsconfig.json Outdated Show resolved Hide resolved
Copy link
Member

@mathiasbynens mathiasbynens left a comment

Choose a reason for hiding this comment

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

LGTM but I'd like for @TimvdLippe to take a look as well before landing.

Copy link
Contributor

@TimvdLippe TimvdLippe left a comment

Choose a reason for hiding this comment

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

If the export cant be renamed, this LGTM!

@@ -26,7 +26,7 @@ const {Keyboard, Mouse, Touchscreen} = require('./Input');
const Tracing = require('./Tracing');
const {helper, debugError, assert} = require('./helper');
const {Coverage} = require('./Coverage');
const {Worker} = require('./Worker');
const {Worker: PuppeteerWorker} = require('./Worker');
Copy link
Contributor

Choose a reason for hiding this comment

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

@mathiasbynens Can the export of Worker be renamed to PuppeteerWorker in Worker.js or does that constitute a breaking change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think that would be a breaking change if we support people who have done:

const { Worker } = require('puppeteer/lib/Worker')

I'm not sure how common that is - @mathiasbynens WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

It's a potentially breaking change that we can avoid in this case, so let's just stick to the more conservative change for now.

lib/WebSocketTransport.js Outdated Show resolved Hide resolved
Continues the work to get up to TS 3.8 (latest release at time of
writing).

This version of TS introduced built in definitions for web workers that
include an `interface Worker` so TS gets confused when it sees us
reference a `Worker`. I have renamed the imports to `PuppeteerWorker` as
I couldn't figure out a way to tell TS to not load in the worker types;
longer term we might consider renaming `Worker` to `PuppeteerWorker` (or
an alternative) but that would be a breaking change that we don't need
right now.

The other fix is similar; TypeScript doesn't differentiate between the
built-in `WebSocket` type and the `ws` library. Renaming the import
solves this too.
@mathiasbynens mathiasbynens merged commit 29b626a into master Mar 31, 2020
@mathiasbynens mathiasbynens deleted the upgrade-typescript-3.6 branch March 31, 2020 13:46
@mathiasbynens mathiasbynens added this to the TypeScript migration milestone Apr 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants