dotCMS / dotCMS/core

[06/44] Enable TS strict mode in dotcms-js

Open
#35,939 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Team : Maintenance Type : Refactoring
Dominant language
Java
Stars
970
Forks
486
Avg merge
3d 33m
Merged PRs (30d)
170

Description

Description

Part of the strict-mode rollout epic #35932. Enable TypeScript strict mode for the dotcms-js project.

  • Dependency layer: 1 (0 = leaf library, 10 = top-level app)
  • Internal dependents: 20 project(s), including the dotcms-ui admin app
  • Rollout order: 6 / 44

Approach corrected. The original criteria referenced typescript-strict-plugin, npx tsc-strict, and // @ts-strict-ignore. That approach was dropped — the bootstrap issue #35933 closed without the plugin ever landing (it is absent from package.json, pnpm-lock.yaml, and main). The established pattern is per-project tsconfig.json flags, set by the first merged rollout PR #36879 (dotcms-models). See epic #35932 for details.

Acceptance Criteria

  • The six strict flags are added to libs/dotcms-js/tsconfig.json (not tsconfig.base.json, which stays at "strict": false):
    forceConsistentCasingInFileNames, strict, noImplicitOverride, noPropertyAccessFromIndexSignature, noImplicitReturns, noFallthroughCasesInSwitch.
  • pnpm exec tsc -p libs/dotcms-js/tsconfig.lib.json --noEmit exits 0 (38 errors at the start, across 11 files).
  • No new any, @ts-ignore, or @ts-expect-error. Prefer correcting types over silencing; any definite-assignment assertion (!) carries a TODO explaining why widening was not viable.
  • The six already-strict consumers still build: data-access, global-store, portlets-dot-analytics, portlets-dot-analytics-data-access, portlets-dot-locales-portlet, utils-testing.
  • pnpm exec nx affected -t build,lint does not regress any of the 20 dependents.
  • pnpm exec nx format:check passes.

Out of scope

  • tsconfig.spec.json — it fails today with TS2688: Cannot find type definition file for 'jasmine', a pre-existing breakage unrelated to strict mode.
  • The skip:lint / skip:test tags — nx run dotcms-js:lint currently fails with 42 problems (mostly no-explicit-any); re-enabling lint is separate work.
  • Adding a typecheck target or CI gate. Note the consequence: dotcms-js has no build target and is tag-excluded from lint and test, so nothing in CI verifies these flags. They document intent; they do not enforce it. The six already-strict consumers provide partial, incidental coverage only.

Priority

Medium

Additional Context

One project in the bottom-up rollout tracked by epic #35932. Full specification: specs/35939-dotcms-js-strict-mode/spec.md.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with libs/dotcms-js/tsconfig.json and the full specification in specs/35939-dotcms-js-strict-mode/spec.md. Run pnpm exec tsc -p libs/dotcms-js/tsconfig.lib.json --noEmit to inspect the 38 errors across 11 files, then verify the six strict consumers, affected builds, and format check. Done means all six flags are enabled without new suppressions and the listed checks pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.