#7495 🐛 BUG: C3's web framework ts detection is broken
Confirmed internal architecture bug. Templates with js/ts variants must implement selectVariant workaround. Maintainer-authored issue with clear diagnosis. No user-facing impact currently.
Keep open as tracking issue for C3 internal improvement
Analysis Report
Issue Review: cloudflare/workers-sdk#7495
Summary
C3's hasTsConfig check for web frameworks runs before the framework's generate function, making TypeScript detection unreliable for templates with js/ts variants.
Findings
- Created: 2024-12-09
- Updated: 2025-10-30
- Version: C3@2.33.3 → 2.62.3 (current)
- Component: C3 (create-cloudflare)
- Labels: bug, c3
- Comments: 2
Key Evidence
Issue confirmed by maintainer: @penalosa acknowledged the bug but removed the
regressionlabel noting it's not user-facing (2025-02-17).Workaround implemented in templates: The Astro template explicitly works around this issue with a comment referencing #7495:
copyFiles: { async selectVariant(ctx) { // Note: this `selectVariant` function should not be needed // this is just a quick workaround until // https://github.com/cloudflare/workers-sdk/issues/7495 // is resolved return usesTypescript(ctx) ? "ts" : "js"; }, variants: { ... } }Root cause confirmed in code: In
templates.tslines 684-691, whenselectVariantis not defined and there's ageneratefunction, the code defaults tojsbecausehasTsConfig(path)returns false (the tsconfig doesn't exist yet):if (hasTsConfig(path)) { args.lang = "ts"; } else if (template.generate) { // If there is a generate process then we assume that a potential typescript // setup must have been part of it, so we should not offer it here args.lang = "js"; }No fix merged: No PRs reference fixing #7495. The issue number doesn't appear in the changelog.
Related PR #11684 (merged 2025-12-17) added
--variantCLI flag as another workaround, but doesn't fix the core issue.Related issue #7492 (Astro env.d.ts error) was closed, likely using the workaround approach.
Recommendation
Status: KEEP OPEN
Reasoning: This is a confirmed internal code architecture issue that requires templates with js/ts variants to implement a selectVariant workaround function. The issue author (@dario-piotrowicz) is a maintainer who documented the problem clearly. While currently only affecting internal template development (since SvelteKit's variants were removed in PR #7494), this technical debt should be addressed before adding new framework templates with proper js/ts variants.
Action: Keep open as a tracking issue for C3 internal improvement. Low priority since workarounds exist and there's no user-facing impact currently.
Notes & Feedback (0)
No notes yet.