Merge conflict Gerrit cannot merge this change. It needs a rebase onto main.

Review main Work in progress Orphaned

67256[WIP][TASK] Enable TypeScript `strictNullChecks` option

Benjamin Franzke CR 0 V -1 Normal +84 −69 updated 02/14/25, 06:44

Commit message

Enforce compilation errors when possible null values
are used without proper assertion that the value is set.

This is to avoid bugs like #91913 or #101893

See also: https://www.typescriptlang.org/tsconfig/strictNullChecks.html

TODO:
 * Found 2624 errors in 269 files. :\
 * Probably to be combined with `strictPropertyInitialization`
   (which requires the `strictNullChecks` option and initializers
   will become useful anyway if we add have to add `|null` or
   `|undefined` to properties.

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 6
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/56/67256/6 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/56/67256/6 && git cherry-pick FETCH_HEAD

Review

  • Code review CR 0 Needs a vote
  • Verified V -1 Blocked
    • core-ci -1 CI

Relation chain 6

  1. 67256 [WIP][TASK] Enable TypeScript `strictNullChecks` option This change

  2. main 88218[WIP][TASK] Enable TypeScript `strictBuiltinIteratorReturn` option This change is based on it Abandoned Benjamin Franzke CR 0 V 0 → 13.4 Easy +1 −0

    The chain has patch set 1 of 2, the changes above it need a rebase.

  3. main 88217[WIP][TASK] Enable TypeScript `useUnknownInCatchVariables` option This change is based on it Abandoned Benjamin Franzke CR 0 V 0 → 13.4 Easy +10 −6

    The chain has patch set 1 of 2, the changes above it need a rebase.

  4. main 88216[TASK] Enable most TypeScript strict-mode options This change is based on it Merged Benjamin Franzke CR +2 V +2 → 13.4 Easy +16 −10

    The chain has patch set 1 of 5, the changes above it need a rebase.

  5. main 88215[TASK] Enable TypeScript `noUnusedLocals` option This change is based on it Merged Benjamin Franzke CR +2 V +2 → 13.4 Normal +20 −65

    The chain has patch set 1 of 5, the changes above it need a rebase.

  6. main 88205[TASK] Enable TypeScript `noImplicitOverride` option This change is based on it Merged Benjamin Franzke CR +2 V +2 → 13.4 Hard +367 −359

    The chain has patch set 1 of 2, the changes above it need a rebase.

Issues 3

Files 24

Show 4 more files

Review log 1116

  1. Benjamin Franzke uploaded patch set 1 12/28/20, 22:49

  2. TYPO3com voted on patch set 1 V -1 12/28/20, 22:59 Completed build in 10m 10s on Mon, 28 Dec, 10:59 PM Test Summary: 32540 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8484

  3. Benni Mack wrote 11/29/21, 10:03

    Change destination moved from master to main
  4. Benni Mack updated the commit message in patch set 2 11/29/21, 13:13

  5. Benjamin Franzke uploaded patch set 3 11/30/23, 08:28

  6. core-ci voted on patch set 3 V -1 11/30/23, 08:35 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50151

  7. Benjamin Franzke marked it ready for review 11/30/23, 08:47

  8. Benjamin Franzke marked it work in progress 05/30/24, 07:15

  9. Benjamin Franzke uploaded patch set 4 V -1 07/15/24, 13:15

  10. core-ci voted on patch set 4 V -1 07/15/24, 13:20 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/61586

  11. Benni Mack updated the commit message in patch set 5 V -1 10/18/24, 13:38

  12. core-ci voted on patch set 5 V -1 10/18/24, 22:34 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/68010

  13. Ayke Halder commented on patch set 5 10/24/24, 09:44

    Maybe combine the fixing of TypeScript `strictNullChecks` with ESLint `@typescript-eslint/no-unnecessary-condition` rule. This will show code with implemented null-checks on objects declared as a type excluding `null`.
  14. Ayke Halder commented on patch set 5 10/24/24, 09:54

    Reply

    E.g. code like this in `Build/Sources/TypeScript/backend/form-engine.ts`: ``` const currentState = (el.querySelector('input[type="radio"]:checked') as HTMLInputElement)?.value; ``` Which should be one of these: ``` const currentState = (el.querySelector('input[type="radio"]:checked') as HTMLInputElement|null)?.value; Or this (identical with code above): const currentState = el.querySelector<HTMLInputElement>('input[type="radio"]:checked')?.value; ```
  15. Benjamin Franzke uploaded patch set 6 V -1 02/14/25, 06:31

  16. core-ci voted on patch set 6 V -1 02/14/25, 06:44 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74138