Skip to content

refactor: TypeScript 6 with full strict mode - #377

Merged
dkastl merged 2 commits into
nextfrom
refactor/typescript-6-strict
Jun 11, 2026
Merged

refactor: TypeScript 6 with full strict mode#377
dkastl merged 2 commits into
nextfrom
refactor/typescript-6-strict

Conversation

@dkastl

@dkastl dkastl commented Jun 11, 2026

Copy link
Copy Markdown
Member

Final piece of the Phase 2 frontend architecture series: the toolchain typechecks the whole bundle under strict: true on TypeScript 6, and CI enforces it.

tsconfig rewrite

The old config described a project that no longer exists: jsx: react, an es6 lib (the source of the long-standing flatMap/Object.entries errors), an unused outDir, and a paths mapping from the webpack era. The new config matches reality, a Vite-bundled browser app typechecked with tsc --noEmit:

  • target/lib es2022, moduleResolution: bundler
  • strict: true
  • skipLibCheck: true (the ol/ol-ext type packages do not pass a strict lib check themselves)

tsc --noEmit went from 16 errors (silently tolerated; nothing ran tsc) to 0, and pnpm typecheck now runs in CI before the build.

Source fixes

All mechanical and behavior-preserving:

  • Definite-assignment assertions on GttClient properties, which are populated by the init helpers the constructor calls.
  • Explicit this annotations on the remaining instance-bound functions (geocoding, styles).
  • Null guards and optional chaining for DOM lookups. The issue-form label scan was copy-pasted five times across geocoding and helpers with a type strict mode rejects; it is now a shared findFieldInput helper.
  • getStyle now matches OpenLayers' StyleFunction signature instead of relying on an unsound parameter type.
  • Module declarations for the style side-effect imports (a new TS 6 check), and the stale FontFaceSet augmentation left over from the icon-font era is deleted.
  • SearchGoogle's default apiKey is '' instead of null (same constructor-time rejection), and initLayers declares the undefined it could already return.

Verification

  • pnpm typecheck: 0 errors; pnpm build green.
  • Map smoke test in a Redmine 6.1 instance: issue map renders, console clean.
  • 39 unit/functional + 3 system tests pass locally against Redmine 6.1-stable, Ruby 3.4, PostGIS 17.

Bumps typescript 5.7 -> 6.0 and rewrites tsconfig for what the
project actually is today: a Vite-bundled browser app typechecked
with tsc --noEmit (target/lib es2022, moduleResolution bundler,
strict, skipLibCheck for the ol/ol-ext type packages). The old
config still declared jsx: react, an es6 lib (which made flatMap
and Object.entries errors) and an outDir nobody used.

The source fixes are mechanical and behavior-preserving:
- definite-assignment assertions on GttClient properties (populated
  by the init helpers; the early return covers a missing target)
- explicit this annotations on instance-bound functions
- null guards and optional chaining for DOM lookups; the repeated
  issue-form label scan is extracted into a shared findFieldInput
  helper (it was copy-pasted five times across geocoding and
  helpers, typed in a way strict mode rejects)
- getStyle now matches OpenLayers' StyleFunction signature
- declarations for style side-effect imports; stale FontFaceSet
  augmentation from the icon-font era deleted

Adds a pnpm typecheck script and runs it in CI before the build so
the codebase stays strict-clean.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR upgrades the frontend toolchain to TypeScript 6 and enforces full strict: true typechecking in CI, with a tsconfig rewrite aligned to the current Vite/browser build and a set of strict-mode-driven source fixes across the GttClient OpenLayers/geocoding code.

Changes:

  • Rewrites tsconfig.json for a Vite-bundled browser app (ES2022 libs, bundler resolution, strict: true, noEmit) and adds a CI pnpm typecheck gate.
  • Updates OpenLayers style/geolocation/edit/layer init code and geocoding/search utilities to satisfy strict mode (explicit this, null guards, corrected signatures).
  • Adds/adjusts ambient type declarations for stylesheet side-effect imports and removes stale global font-related typings.

Reviewed changes

Copilot reviewed 14 out of 18 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tsconfig.json Updates compiler settings for TS6 + strict typechecking with noEmit and browser/Vite-appropriate targets.
src/components/gtt-client/openlayers/styles.ts Aligns style function typing with OpenLayers’ StyleFunction signature and adds null-safety.
src/components/gtt-client/openlayers/geolocation.ts Uses undefined to clear geometries to satisfy stricter typings.
src/components/gtt-client/openlayers/edit.ts Adds optional chaining for safer geometry access.
src/components/gtt-client/init/layers.ts Makes initLayers return type reflect existing early-return behavior.
src/components/gtt-client/init/events.ts Improves DOM query typing via generic querySelectorAll<T>().
src/components/gtt-client/helpers/index.ts Adds findFieldInput helper and refactors repeated label scans to use it.
src/components/gtt-client/GttClient.ts Uses definite-assignment assertions and tweaks i18n parsing for strict mode compatibility.
src/components/gtt-client/geocoding/SearchGTT.ts Adds definite-assignment assertion for a late-assigned button property.
src/components/gtt-client/geocoding/SearchGoogle.ts Updates defaults and adds strict-mode this typing / non-null assertions.
src/components/gtt-client/geocoding/SearchFactory.ts Fixes callback typing to match the actual callback payload shape.
src/components/gtt-client/geocoding/index.ts Adds null guards/optional chaining and reuses findFieldInput in geocoding flows.
src/components/gtt-client/geocoding/CustomButtonMixin.ts Works around missing typings on ol-ext element helper by casting.
src/@types/custom-fontface-set.d.ts Removes stale global augmentation.
src/@types/assets.d.ts Adds ambient module declarations for CSS/SCSS side-effect imports.
package.json Bumps TypeScript to v6 and adds a typecheck script.
pnpm-lock.yaml Locks TypeScript v6 resolution.
.github/workflows/test-postgis.yml Enforces pnpm typecheck in CI before build.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/gtt-client/geocoding/index.ts
Comment thread src/components/gtt-client/GttClient.ts Outdated
- guard the place-search submit handler against no radio selection
- fail fast with an explicit error when the #gtt-defaults i18n
  payload is missing instead of parsing an empty fallback object
  that would crash later with a less actionable message
@dkastl
dkastl merged commit 2f63d1e into next Jun 11, 2026
9 checks passed
@dkastl
dkastl deleted the refactor/typescript-6-strict branch June 11, 2026 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants