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
Conversation
@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 |
8492ec5
to
5b2b9a4
Compare
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.
LGTM but I'd like for @TimvdLippe to take a look as well before landing.
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.
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'); |
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.
@mathiasbynens Can the export of Worker
be renamed to PuppeteerWorker
in Worker.js
or does that constitute a breaking change?
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 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?
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.
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.
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.
29d5aa6
to
b44abf8
Compare
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 usreference a
Worker
. I have renamed the imports toPuppeteerWorker
asI couldn't figure out a way to tell TS to not load in the worker types;
longer term we might consider renaming
Worker
toPuppeteerWorker
(oran 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'timplement a
dispatchEvent
method - which is not a problem - but TSexpects it to. I've used
@ts-ignore
on that error because it'sabsolutely fine and not something we rely on.