Skip to content

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

Description

@nicobytes

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status
    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions