Skip to content

chore: upgrade TypeScript from 5.6.3 to 6.0.3#504

Merged
marcoscaceres merged 12 commits into
mainfrom
chore/typescript-6
May 3, 2026
Merged

chore: upgrade TypeScript from 5.6.3 to 6.0.3#504
marcoscaceres merged 12 commits into
mainfrom
chore/typescript-6

Conversation

@marcoscaceres

Copy link
Copy Markdown
Collaborator

Summary

Major TypeScript upgrade from 5.6.3 to 6.0.3.

Changes

  • TypeScript 5.6.3 → 6.0.3
  • @types/node 22.9.0 → 24.12.2
  • tsconfig.json: module/moduleResolution changed from esnext/node to nodenext/nodenext

Code fixes (12 files)

  • Catch clause unknown typing — narrowed with instanceof in 8 route handlers
  • Module import resolution — .ts extension for typeof import() in 2 update workers
  • @ts-ignore@ts-expect-error in xref search
  • Definite assignment assertion in Logger class
  • Type compatibility fix in view engine
  • TaskModule type relaxed for worker input types

Supersedes Dependabot PR #486.

Comment thread routes/caniuse/feature.ts Fixed
Comment thread routes/github/commits.ts Fixed
Comment thread routes/github/files.ts Fixed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Upgrades the repo to TypeScript 6.0.3 (and newer Node typings) and updates TypeScript/ESM module resolution settings, with follow-up type fixes across route handlers and utilities to keep the build passing under stricter typing.

Changes:

  • Upgrade dev deps: typescript 5.6.3 → 6.0.3 and @types/node 22.9.0 → 24.12.2
  • Switch TS module settings to module: nodenext + moduleResolution: nodenext
  • Apply targeted TS-compat fixes: safer catch handling/narrowing, worker typeof import() tweaks, and minor typing adjustments in utilities

Reviewed changes

Copilot reviewed 15 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
package.json Bumps TypeScript and Node type definitions.
pnpm-lock.yaml Locks updated dependency graph for the upgraded toolchain.
tsconfig.json Moves compilation/module resolution to NodeNext.
utils/view-engine.ts Adjusts Express view engine typing/callback handling for TS 6.
utils/disk-cache.ts Narrows catch error typing when ignoring ENOENT.
utils/background-task-queue.ts TS 6 class property initialization fix; relaxes worker module input typing.
routes/xref/update.ts Updates worker module type query import to include .ts under NodeNext.
routes/caniuse/update.ts Updates worker module type query import to include .ts under NodeNext.
routes/xref/lib/store.ts Narrows catch type and checks ENOENT in a TS-safe way.
routes/xref/lib/search.ts Replaces @ts-ignore with @ts-expect-error and documents intent.
routes/w3c/group.ts Reworks catch blocks to safely derive status/message from unknown errors.
routes/respec/builds/update.ts Uses HTTPError narrowing for status/message in catch.
routes/docs/update.ts Uses HTTPError narrowing for status/message in catch.
routes/github/files.ts Avoids assuming caught values have .message; normalizes to string.
routes/github/commits.ts Avoids assuming caught values have .message; normalizes to string.
routes/github/contributors.ts Safely checks error type before inspecting .message.
routes/caniuse/feature.ts Avoids assuming caught values have .message; normalizes to string.
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 utils/view-engine.ts Outdated
Comment thread utils/view-engine.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 17 changed files in this pull request and generated 1 comment.

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 utils/background-task-queue.ts Outdated
Comment thread routes/respec/builds/update.ts
Comment thread utils/view-engine.ts Outdated
- Update typescript to ^6.0.3 and @types/node to ^24.12.2
- Change tsconfig module/moduleResolution from esnext/node to nodenext
- Fix catch clause variables typed as unknown (stricter in TS 6)
- Replace @ts-ignore with @ts-expect-error
- Fix definite assignment assertion for Logger.result
- Fix view-engine type compatibility with express

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 17 changed files in this pull request and generated 1 comment.

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 utils/view-engine.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 17 changed files in this pull request and generated 3 comments.

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 utils/background-task-queue.ts Outdated
Comment thread utils/disk-cache.ts Outdated
Comment thread routes/xref/lib/store.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 17 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

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

@marcoscaceres
marcoscaceres marked this pull request as ready for review April 26, 2026 08:44
marcoscaceres and others added 3 commits April 26, 2026 18:46
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@marcoscaceres

Copy link
Copy Markdown
Collaborator Author

@copilot you review this and any issues that come ip

@marcoscaceres

Copy link
Copy Markdown
Collaborator Author

@copilot Fix failing test on ci

@marcoscaceres

Copy link
Copy Markdown
Collaborator Author

@copilot try again?

Copilot AI commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

@copilot try again?

Fixed in 977c771.

The failure was a cache poisoning bug in searchOne: the options.all flag changes how filterByForContext behaves (when all:true, the for filter is skipped and all results are returned), but all was not included in the cache key. When tests ran in a different order (seed 29416), the all:true query ran first, cached the unfiltered 3-item result for the "event" term, then the no-all query hit that stale cache entry and returned 3 items instead of 1.

The fix adds options.all to the cache key: const cacheKey = options.all ? \${query.id}:all` : query.id`

Comment thread routes/w3c/group.ts
Comment thread routes/xref/lib/search.ts Outdated
input: unknown;
timings: Record<string, Date> = {};
result: { type: "success" | "failure"; value: unknown };
result!: { type: "success" | "failure"; value: unknown };

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What does this do?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The ! is TypeScript's definite assignment assertion. It tells the compiler this property will be assigned before it's read, even though the constructor doesn't assign it. Without it, TS6 with strictPropertyInitialization (implied by strict) reports an error because result has no initializer and isn't set in the constructor. It's safe here because setResult() (line 99) is always called before result is read.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

TIL!

- Re-throw HTTPError directly in group.ts catch block instead of
  double-wrapping it
- Revert cache key change in search.ts (behavior change, not a TS
  upgrade fix; should be a separate PR)
@marcoscaceres

Copy link
Copy Markdown
Collaborator Author

@copilot Can you confirm all your feedback has been addressed? Please resolve the threads that have been addressed and fix anything outstanding.

Copilot AI commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

@copilot Can you confirm all your feedback has been addressed? Please resolve the threads that have been addressed and fix anything outstanding.

All feedback has been addressed. Here's a summary of what's in the current branch:

  • utils/view-engine.tsEngineCallback type alias removes the as cast; non-async with explicit .then(); error normalized via instanceof Error
  • utils/background-task-queue.tsresult! definite assignment assertion; TaskModule uses method shorthand for bivariant parameter checking
  • utils/disk-cache.ts — uses getErrnoCode() helper for safe ENOENT check (handles non-Error throwables)
  • routes/xref/lib/store.ts — uses getErrnoCode() instead of inline err?.code
  • routes/w3c/group.ts — re-throws HTTPError directly; safe narrowing in route handler catch
  • routes/xref/lib/search.ts@ts-ignore@ts-expect-error; cache key change reverted per @sidvishnoi

CI is passing (commit 1d4b8e8). Note: I don't have the ability to resolve GitHub review threads directly — those will need to be resolved manually.

@marcoscaceres
marcoscaceres merged commit 708f323 into main May 3, 2026
3 checks passed
@marcoscaceres
marcoscaceres deleted the chore/typescript-6 branch May 3, 2026 08:34
marcoscaceres added a commit that referenced this pull request May 4, 2026
* chore: upgrade TypeScript from 5.6.3 to 6.0.3

- Update typescript to ^6.0.3 and @types/node to ^24.12.2
- Change tsconfig module/moduleResolution from esnext/node to nodenext
- Fix catch clause variables typed as unknown (stricter in TS 6)
- Replace @ts-ignore with @ts-expect-error
- Fix definite assignment assertion for Logger.result
- Fix view-engine type compatibility with express

* Apply suggestions from code review

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* refactor: type engine directly as EngineCallback, remove async and cast

Agent-Logs-Url: https://github.com/speced/respec-web-services/sessions/50c73c28-bbb9-43db-8a58-d5c85ae17fd3

* refactor: simplify engine body, let TS infer params from EngineCallback type

Agent-Logs-Url: https://github.com/speced/respec-web-services/sessions/50c73c28-bbb9-43db-8a58-d5c85ae17fd3

* fix: resolve TaskModule TS errors, extract getErrnoCode helper

Agent-Logs-Url: https://github.com/speced/respec-web-services/sessions/a465b3f6-aa1e-4a52-9998-11d12704f748

* test: add coverage for getErrnoCode utility

Agent-Logs-Url: https://github.com/speced/respec-web-services/sessions/a465b3f6-aa1e-4a52-9998-11d12704f748

* fix(xref): include options.all in search cache key to prevent cache poisoning

Agent-Logs-Url: https://github.com/speced/respec-web-services/sessions/9ff1c977-d8d7-467c-937f-9353541e3b87

* fix: address Sid's review feedback

- Re-throw HTTPError directly in group.ts catch block instead of
  double-wrapping it
- Revert cache key change in search.ts (behavior change, not a TS
  upgrade fix; should be a separate PR)

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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.

5 participants