Skip to content

Upgrade to TypeScript 7 and tighten type checking - #316

Merged
bhousel merged 3 commits into
mainfrom
typescript-7
Nov 16, 2026
Merged

bhousel merged 3 commits into
mainfrom
typescript-7

Conversation

@bhousel

@bhousel bhousel commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Upgrades to TypeScript 7 (the native compiler), following the agent-practices TypeScript 7 playbook, then tightens the compiler settings while we're here.

Upgrade to TypeScript 7

  • typescript goes to ^7.0.2.
  • TypeDoc and the docs script are removed. TypeDoc 0.28 needs TypeScript's JavaScript compiler API, which TypeScript 7 doesn't have. The backlog has a note on docs generation, including a one-off command that regenerates them with TypeScript 6.

Tighten TypeScript settings and remove any

  • Turns on noImplicitAny and isolatedDeclarations, and drops allowJs.
  • Adds OsmEntityLike, OsmGraphLike and SessionMutex types, so the osm helpers and utilSessionMutex no longer take or return any.
  • Tiler's getter/setter methods (tileSize, zoomRange, margin, skipNullIsland) use overloads, so t.tileSize() returns a number and t.tileSize(512) returns the Tiler.
  • utilSessionMutex no longer assigns a mock document to globalThis outside the browser.
  • Tests replace 17 as any casts with @ts-expect-error and type their fixtures.

The generated .d.ts files change only where the API typings above were tightened. A simulated TypeScript 7 consumer type-checks under both nodenext and bundler resolution.

Enable noUncheckedIndexedAccess for util

  • It's on in packages/util/tsconfig.json only. Turning it on needed 14 small fixes in source and none in tests.
  • Math stays off: most of its indexing is bounds-safe hot loops, where the flag would add ~200 ! marks or runtime guards. knowledge/decisions.md records why. The benchmarks item in the backlog is now a performance pass, which may make the flag cheap to turn on for math later.

bun run all passes: 522 tests.

🤖 Generated with Claude Code

bhousel and others added 3 commits November 16, 2026 11:10
- typescript ^6.0.3 -> ^7.0.2; no code changes needed, generated .d.ts unchanged
- Remove typedoc and the docs script: TypeDoc 0.28 needs the JS compiler API,
  which TypeScript 7 does not have
- Note docs generation in knowledge/backlog.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- tsconfig: enable noImplicitAny (via strict), declaration + isolatedDeclarations,
  add DOM to lib; drop unused allowJs and redundant noImplicitThis
- util: type the OSM graph/entity params (OsmGraphLike, OsmEntityLike) instead
  of any; utilStringQs returns Record<string, string>; utilQsString takes a
  Record; GroupBy/UniqBy key functions may return numbers
- util: utilSessionMutex returns a SessionMutex and no longer writes a mock
  document onto globalThis; add @types/aes-js and @types/diacritics
- math: Tiler accessors use getter/setter overloads, so tileSize(512) returns
  this and tileSize() returns number; annotate computed constants
- tests: replace as any with @ts-expect-error for intentionally invalid input

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Math stays off: its indexing is mostly bounds-safe hot loops, and the flag
would add ~200 non-null assertions or guards. Recorded why in decisions.md,
and expanded the benchmarks backlog item into a performance pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bhousel
bhousel merged commit ba87b86 into main Nov 16, 2026
1 check passed
@bhousel
bhousel deleted the typescript-7 branch November 16, 2026 18:57
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.

1 participant