Skip to content

Add TypeScript checkJs validation#278

Closed
curtcox wants to merge 2 commits intomainfrom
codex/add-typescript-checkjs-ci-job
Closed

Add TypeScript checkJs validation#278
curtcox wants to merge 2 commits intomainfrom
codex/add-typescript-checkjs-ci-job

Conversation

@curtcox
Copy link
Copy Markdown
Owner

@curtcox curtcox commented Nov 1, 2025

Summary

  • add a TypeScript configuration that enables checkJs for static JavaScript files
  • expose a new npm script for running the TypeScript check locally
  • run the new type-check script in a dedicated GitHub Actions job so failures are reported separately

Testing

  • npm run typecheck:js (fails in this environment: npm install blocked by 403 from npm registry)

https://chatgpt.com/codex/tasks/task_b_69069a174be88331a9a205e590072a33

Summary by CodeRabbit

  • Chores
    • Added TypeScript type checking to the continuous integration pipeline.
    • Configured automatic type validation for JavaScript files during builds.
    • Enhanced development tooling with new type checking capabilities integrated into the build system.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Nov 1, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

TypeScript type checking infrastructure was added to the project. A new tsconfig.json configuration file enables JavaScript type checking for files in the static/ directory, targeting ES2015. TypeScript was added as a devDependency with version ^5.4.5, a corresponding npm script typecheck:js was added to package.json, and a new GitHub Actions CI job was created to run type checking in parallel with existing jobs.

Changes

Cohort / File(s) Change Summary
TypeScript Configuration
tsconfig.json
New file: Configured TypeScript compiler with checkJs enabled for JavaScript type checking, noEmit mode, ES2015 target, ES2017 and DOM libs, including files under static/**/*.js
CI/Automation
.github/workflows/ci.yml
New job added: "TypeScript checkJs" job runs in parallel, checks out repo, sets up Node.js 20, installs dependencies, and executes npm run typecheck:js
Package Management
package.json
Added npm script typecheck:js for TypeScript compilation; added typescript (^5.4.5) to devDependencies

Sequence Diagram

sequenceDiagram
    participant CI as GitHub Actions
    participant Node as Node.js Env
    participant TS as TypeScript
    participant Static as Static Files
    
    CI->>Node: Checkout & Setup Node 20
    CI->>Node: Install dependencies (npm install)
    Note over Node: TypeScript ^5.4.5 installed
    CI->>TS: npm run typecheck:js
    activate TS
    TS->>Static: Read static/**/*.js files
    TS->>TS: Type check with tsconfig.json<br/>(checkJs enabled)
    TS-->>CI: Report results (no emit)
    deactivate TS
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Areas requiring attention:
    • Verify tsconfig.json settings align with project's JavaScript file structure and intended coverage under static/**/*.js
    • Confirm TypeScript version ^5.4.5 compatibility with existing project dependencies
    • Ensure CI job syntax and Node.js version (20) are consistent with project standards

Poem

🐰 Hop along with types so clear,
JavaScript's secrets we need not fear!
TypeScript guards our static files tight,
CI checks them day and night—
Quality assured, our code's delight!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "Add TypeScript checkJs validation" accurately and directly describes the main change in the changeset. The changeset adds a TypeScript configuration with checkJs enabled for static JavaScript files, introduces an npm script to run the type-check locally, and adds a GitHub Actions job to execute this validation in CI. The title is concise, clear, and specific enough that a teammate scanning the repository history would immediately understand that this PR introduces TypeScript type checking capabilities to the project.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/add-typescript-checkjs-ci-job

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1 to +8
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"target": "ES2015"
},
"include": ["static/**/*.js"]
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge TypeScript check fails on undeclared browser globals

The new configuration runs tsc --project tsconfig.json against every file under static/**/*.js, but these scripts rely on globals such as window.ace (see static/js/code_editor.js and static/js/server_form.js). Because the repo does not declare these globals via JSDoc or ambient .d.ts files, tsc with checkJs: true emits errors like Property 'ace' does not exist on type 'Window & typeof globalThis', so the newly added GitHub Actions job will fail immediately on current sources. Either limit the include set to files that already have type annotations or add declarations for the global objects before enabling this check.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d2f4076 and 0d60613.

📒 Files selected for processing (3)
  • .github/workflows/ci.yml (1 hunks)
  • package.json (1 hunks)
  • tsconfig.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Unit Tests and Coverage
🔇 Additional comments (2)
package.json (1)

6-11: Structure looks good, but dependent on tsconfig.json fix.

The package.json changes are well-structured: the typecheck:js script correctly invokes TypeScript against tsconfig.json, and the typescript ^5.4.5 dependency is appropriately pinned. However, the success of this script in CI depends on resolving the undeclared globals issue in tsconfig.json.

.github/workflows/ci.yml (1)

89-107: CI job structure is sound; will fail until tsconfig.json globals issue is resolved.

The new TypeScript checkJs job is well-structured: appropriate runner selection (ubuntu-latest), correct Node.js version consistency with the eslint job, proper dependency installation, and correct script invocation. The job will run in parallel with existing checks as intended. However, it will fail on the current codebase until the undeclared browser globals issue in tsconfig.json is addressed.

Comment on lines +1 to +9
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"target": "ES2015",
"lib": ["ES2017", "DOM"]
},
"include": ["static/**/*.js"]
}
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.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Unresolved critical issue: TypeScript will fail on undeclared browser globals.

A prior review identified that this configuration will immediately fail on current sources because static JavaScript files reference globals like window.ace (see static/js/code_editor.js and static/js/server_form.js) that are not declared. With checkJs: true and the DOM lib included, TypeScript emits errors like Property 'ace' does not exist on type 'Window & typeof globalThis'.

Before merging, either:

  1. Add ambient .d.ts files declaring these globals, or
  2. Add JSDoc type annotations to the affected static JavaScript files, or
  3. Narrow the include pattern to exclude files without type annotations.

🏁 Script executed:

#!/bin/bash
# Verify that undeclared globals issue has been addressed

# Search for window.ace and similar global references in static/**/*.js
echo "=== Searching for undeclared global references ==="
rg -n --type=js "window\." static/ || echo "No matches found"

# Check if any .d.ts files have been added to declare globals
echo ""
echo "=== Checking for ambient type declarations ==="
find . -name "*.d.ts" -type f | head -20

# Check if JSDoc type annotations exist in static/**/*.js
echo ""
echo "=== Checking for JSDoc type annotations in static/**/*.js ==="
rg -n --type=js "@type|@ts-" static/ | head -10

Length of output: 2590


Unresolved critical blocker: TypeScript type checking will fail on custom globals.

The configuration enables JavaScript type checking (checkJs: true) on static/**/*.js files, but the code references undeclared custom globals like window.ace, window.codeEditors, window.serverDefinitionEditor, and others that do not exist on the Window type. TypeScript will emit errors like Property 'ace' does not exist on type 'Window & typeof globalThis'.

This must be resolved before the CI build can succeed. Either:

  1. Add .d.ts files with ambient declarations for these globals (e.g., declare global { interface Window { ace?: any; codeEditors?: Record<string, any>; ... } })
  2. Add JSDoc @type annotations to the affected static JavaScript files
  3. Narrow the include pattern to exclude these files until they are properly typed

@curtcox curtcox closed this Nov 2, 2025
@curtcox curtcox deleted the codex/add-typescript-checkjs-ci-job branch November 2, 2025 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant