Skip to content

feat: add JSDoc + checkJs TypeScript type checking (Option B)#54

Merged
nitrocode merged 1 commit into
mainfrom
copilot/evaluate-typescript-vs-javascript
Apr 24, 2026
Merged

feat: add JSDoc + checkJs TypeScript type checking (Option B)#54
nitrocode merged 1 commit into
mainfrom
copilot/evaluate-typescript-vs-javascript

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 24, 2026

Enables TypeScript's type checker on the existing .js source without a build step or syntax migration — the browser still loads the original files directly.

New files

  • tsconfig.jsoncheckJs: true, strict: true, noEmit: true; scope limited to death-clock-core.js and scripts/*.js
  • global.d.ts — extends Window with the project's dual-export globals (MilestonesData, DeathClockCore, ChangelogData, ProjectStatsData) and declares the Milestone / ChangelogRelease interfaces

Bugs surfaced and fixed by the type checker

  • Date arithmeticd - base replaced with d.getTime() - base.getTime() in generateProjectionData and getTimeDelta; TypeScript correctly rejects implicit Date subtraction
  • Index access on ObjectcomputePassiveRate params tightened from {Object} to {Object.<string, number>} / {Object.<string, boolean>} so agents[a.id] and roles[r.id] are safe
  • never[] inference in build-changelogcurrentRelease.sections and currentSection.items were inferred as never[], silently making push() a no-op for TypeScript; fixed with explicit @typedef + @type annotations
  • Untyped yaml.load() resultsdoc in build-milestones.js and build-project-stats.js cast to typed shapes so property access is checked

JSDoc annotation improvements

  • {Array}{Milestone[]} / {Milestone|null} in getTriggeredMilestones, getNextMilestone, getNextMilestoneForPlayer — callback access to .tokens is now statically verified
  • Helper functions in build scripts annotated with @param / @typedef

CI

npm run typecheck (tsc --noEmit) added as a step in unit-tests.yml, running before Jest, so type regressions fail the PR.

@nitrocode nitrocode marked this pull request as ready for review April 24, 2026 02:53
@nitrocode nitrocode enabled auto-merge (squash) April 24, 2026 02:54
@github-actions
Copy link
Copy Markdown
Contributor

👁️ PR Preview

🚀 Open Preview

Deployed from commit 6919bf1 · Updates on every push to this PR
(Preview is removed automatically when the PR is closed.)

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (3cd91d7) to head (6919bf1).
⚠️ Report is 1 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##              main       #54   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines          233       233           
  Branches       107       107           
=========================================
  Hits           233       233           
Flag Coverage Δ
unit 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
death-clock-core.js 100.00% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3cd91d7...6919bf1. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nitrocode nitrocode merged commit 7fda3f0 into main Apr 24, 2026
3 checks passed
@nitrocode nitrocode deleted the copilot/evaluate-typescript-vs-javascript branch April 24, 2026 02:55
github-actions Bot added a commit that referenced this pull request Apr 24, 2026
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.

3 participants