Skip to content

fix(frontend): add prism/r type shim so tsc unblocks Cloud Build#7052

Merged
MarkusNeusinger merged 4 commits into
mainfrom
claude/fix-language-count-display-iL5NJ
May 17, 2026
Merged

fix(frontend): add prism/r type shim so tsc unblocks Cloud Build#7052
MarkusNeusinger merged 4 commits into
mainfrom
claude/fix-language-count-display-iL5NJ

Conversation

@MarkusNeusinger
Copy link
Copy Markdown
Owner

Why

The frontend changes from PR #6961languages count on the landing strip, ggplot2 card on /libraries, R code viewer on /scatter-basic/r/ggplot2 — are merged on main, but production still shows the pre-#6961 state:

$ curl -s https://anyplot.ai/assets/constants-Cv1rI8LA.js | head -c 200
…LIBRARIES=['altair','bokeh','highcharts',…]  # no ggplot2
$ curl -s https://anyplot.ai/assets/LandingPage-Bluw1eOY.js | grep -oE '.{20}languages.{20}'
…children:[{value:`1`,label:`languages`}…    # hardcoded '1'

All served assets carry last-modified: Sat, 16 May 2026 20:04:15 GMT — about 2.5 h before #6961 merged. The API was redeployed (/stats now returns "languages":2,"libraries":10), but the frontend Cloud Run revision is stale.

Root cause

The frontend Cloud Build (app/cloudbuild.yamlyarn build = tsc && vite build) fails at the tsc step:

src/components/CodeHighlighter.tsx(3,15): error TS7016: Could not find a declaration
file for module 'react-syntax-highlighter/dist/esm/languages/prism/r'.
'…/react-syntax-highlighter/dist/esm/languages/prism/r.js' implicitly has an 'any' type.

@types/react-syntax-highlighter actually does ship an ambient declaration for this exact path (line 2768 of its index.d.ts), but with moduleResolution: "bundler" tsc resolves the import to the sibling .js file first and never reaches the @types index — only r trips, python from the line above happens to resolve through the cached package types. Net effect: tsc exits non-zero, vite build never runs, no new Docker layer, Cloud Run keeps serving the previous revision.

Docker build log confirmed this:

ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 2
The command '/bin/sh -c yarn build' returned a non-zero code: 2

PR #6961 listed this exact TS error under "Out of scope" — it had been latent since #6944 added the R import, and only became a deploy blocker because #6961 was the first frontend-touching PR after the lib bumps that affect tsc behavior.

Fix

Add app/src/types/react-syntax-highlighter.d.ts declaring the missing module locally. A project-local shim wins over @types, which is enough to unblock tsc. The runtime import is unchanged — Prism still registers the real R grammar via registerLanguage('r', r), and a grep over the rebuilt CodeHighlighter-*.js confirms the R keyword set is bundled:

break|else|for|function|if|in|next|repeat|while

So R syntax highlighting on /scatter-basic/r/ggplot2 works as intended.

Test plan

  • cd app && yarn build — green (was failing on TS7016 before)
  • cd app && yarn test — 459/459 green
  • New bundle hash differs from the deployed one (LandingPage-e58y3raq.js vs prod LandingPage-Bluw1eOY.js), confirming the redeploy will publish fresh assets
  • After merge: Cloud Build for anyplot-app finishes green; https://anyplot.ai/assets/LandingPage-*.js no longer contains the hardcoded {value:'1',label:'languages'}
  • After deploy: landing strip shows languages: 2, /libraries shows the ggplot2 card, /scatter-basic/r/ggplot2 code panel renders R code with highlighting

Notes


Generated by Claude Code

The `react-syntax-highlighter/dist/esm/languages/prism/r` import added in
PR #6944 has an ambient declaration in `@types/react-syntax-highlighter`,
but with `moduleResolution: bundler` tsc resolves it to the sibling .js
file first and never reaches the @types index — TS7016 trips `tsc &&
vite build` in the frontend Cloud Build trigger. The image never gets
rebuilt, so Cloud Run keeps serving the pre-#6961 revision and the
landing strip still shows `languages: 1`, the `/libraries` page is still
missing the ggplot2 card, and the R code viewer is still empty even
though those fixes are merged on main.

A project-local shim takes precedence over @types and is enough to get
`yarn build` green again, which lets the next merge to main publish the
already-merged frontend changes.
Copilot AI review requested due to automatic review settings May 17, 2026 09:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review any files in this pull request.

PR #6961 deferred a known `tsc` error under "Out of scope" and that
deferral broke every subsequent frontend Cloud Build — the language
count, ggplot2 card, and R code viewer fixes never reached anyplot.ai
even though the PR merged green. Codify the rule so the next latent
blocker gets fixed in the same PR instead of parked.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI review requested due to automatic review settings May 17, 2026 10:01
@MarkusNeusinger MarkusNeusinger enabled auto-merge (squash) May 17, 2026 10:02
@MarkusNeusinger MarkusNeusinger disabled auto-merge May 17, 2026 10:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 1 out of 2 changed files in this pull request and generated no new comments.

@MarkusNeusinger MarkusNeusinger enabled auto-merge (squash) May 17, 2026 10:04
@MarkusNeusinger MarkusNeusinger merged commit 173d4dd into main May 17, 2026
7 checks passed
@MarkusNeusinger MarkusNeusinger deleted the claude/fix-language-count-display-iL5NJ branch May 17, 2026 10:05
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