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

    Imported before Forger kept the single votes, the next import adds them.

  • Verified V +2

    Imported before Forger kept the single votes, the next import adds them.

Issues 2

Files 124

Show 104 more files