Review main Merged

72806[TASK] Update to TypeScript 4.5

Benjamin Franzke CR +2 V +2 Hard +438 −436 updated 12/30/21, 12:12

Commit message

This is a preparatory update to help migration to ES2020 modules ("ESM").
TypeScript >=4.1.1 fixes it's es2020 module target to allow import.meta,
see https://github.com/microsoft/TypeScript/issues/41249

Also related eslint tools are updated and the configuration
format is streamlined to json, while we are at it.
(not really needed, just drive-by cleanups)

Notes:

 * @types/chrome is removed because of a conflict. It has been added
   in #82595 but it has actually never been used. This package contains
   a dependency to @types/filesystem which is currently not
   TypeScript 4.5 compatible, therefore both packages are removed.

 * tsconfig.json is adapted to explicitly configure
   "useDefineForClassFields": false.
   With our current target ES2017 this defaults to false, but with
   TypeScript >=4.3 and target ES2020 the default changes to `true`.
   Lit requires this setting to be false for decorators to work,
   so we add explicit configuration as recommended by Lit:
   https://lit.dev/docs/components/decorators/#decorators-typescript

 * The `true` ("force-reload") parameter of document.location.reload()
   calls is removed as this flag is non standard an only available
   in firefox. It is not longer permitted by TypeScript 4.5, also see:
   https://developer.mozilla.org/en-US/docs/Web/API/Location/reload#location.reload_has_no_parameter

 * Many compiled files are changed because calls like `foo.bar()`
   (where `foo` is imported from another module) are now transpiled
   to `(0, foo).bar()` in order to avoid calling module exports with
   a `this` value:
   https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-4.html#more-compliant-indirect-calls-for-imported-functions
   This is to comply with native ES6 Modules and therefore marked as a
   breaking change in TypeScript, but it only affects names imports
   and therefore doesn't affect the instances we export via `import =`.
   (It only affects imports from jquery, moment, lit and function exports)
   This actually brings us closer to ES6 module compatibility.

Commands executed:

  # Introduces in #82595 and unused since then
  yarn remove @types/chrome

  yarn add --dev \
    typescript@~4.5.0 \
    grunt-eslint@^24.0.0 \
    eslint@^8.0.1 \
    @typescript-eslint/eslint-plugin@^5.8.0 \
    @typescript-eslint/parser@^5.8.0 \
    @typescript-eslint/typescript-estree@^5.8.0

  yarn build

Review

  • Code review CR +2 Done
    • Andreas Kienast +2
    • Benni Mack +1
  • Verified V +2 Done
    • Andreas Kienast +2
    • Benni Mack +1
    • core-ci +1 CI

Issues 2

Files 124

Show 104 more files

Review log 1318

  1. Benjamin Franzke uploaded patch set 1 12/28/21, 09:05

  2. Benjamin Franzke uploaded patch set 2 12/28/21, 09:16

  3. core-ci voted on patch set 1 V +1 12/28/21, 09:17 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21474

  4. core-ci voted on patch set 2 V +1 12/28/21, 09:29 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21475

  5. Benjamin Franzke updated the commit message in patch set 3 12/28/21, 09:39

  6. core-ci voted on patch set 3 V +1 12/28/21, 09:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21476

  7. Benni Mack voted on patch set 3 CR +1 12/28/21, 11:49

  8. Benjamin Franzke commented on patch set 3 CR -1 12/28/21, 12:07

    Need to check why this currently "works" without explicitly setting "useDefineForClassFields": false, in tsconfig.json reference: https://github.com/lit/lit/issues/1985 https://github.com/microsoft/TypeScript/issues/45584
  9. Benjamin Franzke uploaded patch set 4 12/28/21, 12:32

  10. Benjamin Franzke commented on patch set 4 12/28/21, 12:32

    Reply

    Ok, we were not affected due to target: ES2017 in tsconfig.json Anyway, added the flag as explicit configuration as per Lit documentation.
  11. core-ci voted on patch set 4 V +1 12/28/21, 12:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21479

  12. Benjamin Franzke uploaded patch set 5 12/28/21, 13:48

  13. Benjamin Franzke commented on patch set 5 12/28/21, 13:48

    oops, needed by @typescript-eslint/* as peerDependency. No errors, but warnings during yarn upgrade. Therefore now re-added.
  14. core-ci voted on patch set 5 V +1 12/28/21, 14:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21480

  15. Benni Mack voted on patch set 5 V +1 CR +1 12/29/21, 20:44

  16. Andreas Kienast commented on patch set 5 CR -1 12/30/21, 11:57

    on it
  17. Andreas Kienast voted on patch set 5 V +2 CR +2 12/30/21, 12:12

  18. Andreas Kienast merged patch set 6 12/30/21, 12:12