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

deps: upgrade typescript to 5.5.3 #16091

Merged
merged 10 commits into from
Jul 3, 2024
Merged

deps: upgrade typescript to 5.5.3 #16091

merged 10 commits into from
Jul 3, 2024

Conversation

connorjclark
Copy link
Collaborator

@connorjclark connorjclark commented Jun 27, 2024

Upgrades typescript from 5.0.4 to 5.52

....or rather, tries to. I found that 5.1 has introduced errors that I cannot resolve:

yarn run v1.22.19
$ tsc --build ./tsconfig-all.json
core/gather/session.js(137,33): error TS2769: No overload matches this call.
  Overload 1 of 2, '(timeoutId: string | number | Timeout | undefined): void', gave the following error.
    Argument of type 'Timer' is not assignable to parameter of type 'string | number | Timeout | undefined'.
      Property '[Symbol.dispose]' is missing in type 'Timer' but required in type 'Timeout'.
  Overload 2 of 2, '(id: number | undefined): void', gave the following error.
    Argument of type 'Timer' is not assignable to parameter of type 'number'.
core/gather/driver/wait-for-condition.js(151,35): error TS2769: No overload matches this call.
  Overload 1 of 2, '(timeoutId: string | number | Timeout | undefined): void', gave the following error.
    Argument of type 'Timer' is not assignable to parameter of type 'string | number | Timeout | undefined'.
  Overload 2 of 2, '(id: number | undefined): void', gave the following error.
    Argument of type 'Timer' is not assignable to parameter of type 'number'.
core/gather/driver/wait-for-condition.js(196,37): error TS2769: No overload matches this call.
  Overload 1 of 2, '(timeoutId: string | number | Timeout | undefined): void', gave the following error.
    Argument of type 'Timer' is not assignable to parameter of type 'string | number | Timeout | undefined'.
  Overload 2 of 2, '(id: number | undefined): void', gave the following error.
    Argument of type 'Timer' is not assignable to parameter of type 'number'.
core/gather/driver/wait-for-condition.js(270,37): error TS2769: No overload matches this call.
  Overload 1 of 2, '(timeoutId: string | number | Timeout | undefined): void', gave the following error.
    Argument of type 'Timer' is not assignable to parameter of type 'string | number | Timeout | undefined'.
  Overload 2 of 2, '(id: number | undefined): void', gave the following error.
    Argument of type 'Timer' is not assignable to parameter of type 'number'.
core/gather/driver/wait-for-condition.js(370,35): error TS2769: No overload matches this call.
  Overload 1 of 2, '(timeoutId: string | number | Timeout | undefined): void', gave the following error.
    Argument of type 'Timer' is not assignable to parameter of type 'string | number | Timeout | undefined'.
  Overload 2 of 2, '(id: number | undefined): void', gave the following error.
    Argument of type 'Timer' is not assignable to parameter of type 'number'.
core/gather/driver/wait-for-condition.js(528,36): error TS2769: No overload matches this call.
  Overload 1 of 2, '(timeoutId: string | number | Timeout | undefined): void', gave the following error.
    Argument of type 'Timer' is not assignable to parameter of type 'string | number | Timeout | undefined'.
  Overload 2 of 2, '(id: number | undefined): void', gave the following error.
    Argument of type 'Timer' is not assignable to parameter of type 'number'.
cli/run.js(96,3): error TS2322: Type 'any' is not assignable to type 'never'.
cli/run.js(102,3): error TS2322: Type 'any' is not assignable to type 'never'.
cli/run.js(114,3): error TS2322: Type 'any' is not assignable to type 'never'.
cli/sentry-prompt.js(50,48): error TS2769: No overload matches this call.
  Overload 1 of 2, '(timeoutId: string | number | Timeout | undefined): void', gave the following error.
    Argument of type 'Timer' is not assignable to parameter of type 'string | number | Timeout | undefined'.
  Overload 2 of 2, '(id: number | undefined): void', gave the following error.
    Argument of type 'Timer' is not assignable to parameter of type 'number'.
core/gather/gatherers/link-elements.js(106,7): error TS2322: Type '{ supportedModes: ("navigation" | "timespan")[]; dependencies: { DevtoolsLog: symbol; }; }' is not assignable to type 'GathererMetaNoDependencies'.
  Object literal may only specify known properties, and 'dependencies' does not exist in type 'GathererMetaNoDependencies'.
core/lib/proto-preprocessor.js(137,24): error TS7006: Parameter 'flag' implicitly has an 'any' type.
core/lib/proto-preprocessor.js(138,25): error TS7006: Parameter 'flag' implicitly has an 'any' type.
core/scripts/manual-chrome-launcher.js(27,37): error TS7006: Parameter 'flag' implicitly has an 'any' type.
core/scripts/manual-chrome-launcher.js(29,39): error TS7006: Parameter 'flag' implicitly has an 'any' type.
core/scripts/manual-chrome-launcher.js(32,49): error TS7006: Parameter 'flag' implicitly has an 'any' type.
core/scripts/manual-chrome-launcher.js(40,27): error TS7006: Parameter 'flag' implicitly has an 'any' type.
core/test/config/validation-test.js(92,9): error TS2322: Type '{ id: string; gatherer: { instance: LinkElements; }; dependencies: { DevtoolsLog: { id: string; }; }; }' is not assignable to type 'AnyArtifactDefn'.
  The types of 'gatherer.instance.meta' are incompatible between these types.
    Property 'dependencies' is missing in type 'GathererMetaNoDependencies' but required in type 'GathererMetaWithDependencies<"DevtoolsLog">'.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

summarizing above:

  1. Inside Node code, setTimeout seems to be using the browser definition instead of the Node one, so it doesn't like us giving it NodeJS.Timeout
  2. Inside node code, process is any so many cascading errors from that in cli
  3. Something funky with LH.Gatherer.GathererMeta

@connorjclark connorjclark changed the title wip deps: upgrade typescript to 5.5.2 Jun 27, 2024
yarn.lock Outdated Show resolved Hide resolved
TagNames extends Array<string> ?
HtmlAndSvgElementTagNameMap[TagNames[number]] :
TagNames extends string ?
HtmlAndSvgElementTagNameMap[TagNames] :
Element: // Fall back for queries typed-query-selector fails to parse, e.g. `'[alt], [aria-label]'`.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the query selector type library broke in a 5.x, and in upgrading I found that their API changed from an array of tags to just a union.

@connorjclark
Copy link
Collaborator Author

connorjclark commented Jun 28, 2024

process issue: the process-global.js file was mucking things up. adding to tsconfig exclude

clearTimeout issue: we were using an older interface - NodeJS.Timer - which is no longer getting updates. Such as adding the dispose symbol. I filed a bug

remaining:

core/gather/gatherers/link-elements.js(106,7): error TS2353: Object literal may only specify known properties, and 'dependencies' does not exist in type 'GathererMetaNoDependencies'.
core/test/config/validation-test.js(92,9): error TS2322: Type '{ id: string; gatherer: { instance: LinkElements; }; dependencies: { DevtoolsLog: { id: string; }; }; }' is not assignable to type 'AnyArtifactDefn'.
  The types of 'gatherer.instance.meta' are incompatible between these types.
    Property 'dependencies' is missing in type 'GathererMetaNoDependencies' but required in type 'GathererMetaWithDependencies<"DevtoolsLog">'.

@connorjclark
Copy link
Collaborator Author

connorjclark commented Jul 1, 2024

I ran a bisect over typescript

every-ts bisect start 5.5.2 5.0.4 --
every-ts bisect run sh -c "(tsc --build ./tsconfig-all.json || true) | (! grep -q 'GathererMetaNoDependencies')"

looks very related: microsoft/TypeScript@615a97b

@connorjclark connorjclark marked this pull request as ready for review July 1, 2024 20:39
@connorjclark connorjclark requested a review from a team as a code owner July 1, 2024 20:39
@connorjclark connorjclark requested review from adamraine and removed request for a team July 1, 2024 20:39
/**
* This needs to be in the constructor.
* https://github.com/GoogleChrome/lighthouse/issues/12134
* @type {LH.Gatherer.GathererMeta<'DevtoolsLog'>}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this was true for browserify

@@ -389,7 +389,7 @@ function coerceOptionalStringBoolean(value) {
function coerceOutput(values) {
const outputTypes = ['json', 'html', 'csv'];
const errorHint = `Argument 'output' must be an array from choices "${outputTypes.join('", "')}"`;
if (!values.every(/** @return {item is string} */ item => typeof item === 'string')) {
Copy link
Member

Choose a reason for hiding this comment

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

Huge

yarn.lock Outdated Show resolved Hide resolved
@connorjclark connorjclark changed the title deps: upgrade typescript to 5.5.2 deps: upgrade typescript to 5.5.3 Jul 3, 2024
@connorjclark connorjclark merged commit a21fde7 into main Jul 3, 2024
27 checks passed
@connorjclark connorjclark deleted the upgrade-ts-5.5 branch July 3, 2024 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants