GoogleChrome / lighthouse

Automated auditing, performance metrics, and best practices for the web.
https://developer.chrome.com/docs/lighthouse/overview/
Apache License 2.0
28k stars 9.32k forks source link

deps: upgrade typescript to 5.5.2 #16091

Open connorjclark opened 3 days ago

connorjclark commented 3 days ago

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 commented 2 days ago

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">'.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.