Skip to content

chore(examples): move the TypeScript examples to tsx and TypeScript 6 - #419

Merged
jsteinich merged 2 commits into
open-constructs:mainfrom
jsteinich:claude/examples-tsx-typescript-6
Sep 12, 2026
Merged

jsteinich merged 2 commits into
open-constructs:mainfrom
jsteinich:claude/examples-tsx-typescript-6

Conversation

@jsteinich

Copy link
Copy Markdown
Contributor

Related issue

Alignment follow-up to #396 (init template → tsx + TypeScript 6) and #406 (packages → TypeScript 6). The examples were the last part of the repo still on ts-node and TypeScript 5.

Description

Two commits, in the order they have to happen:

1. chore(examples): run the TypeScript examples with tsx (669eae2)

21 of the 22 TypeScript examples ran npx ts-node main.ts. ts-node cannot be used with TypeScript 6 — it merges a bundled @tsconfig/nodeXX default supplying a deprecated moduleResolution: node10, which the compiler rejects — so the examples demonstrated a setup the CLI no longer produces, and copying their config into a generated project reproduces that failure. The documentation example was already on tsx; its pin is brought in line.

2. chore(examples): move the TypeScript examples to TypeScript 6 (86d7436)

typescript goes from ^5.0.0 to ~6.0.0, plus the same two config changes the template needed:

  • types: ["node", "jest"] — the tsconfigs include __tests__, and TypeScript 6 otherwise stops resolving the jest globals (Cannot find name 'describe').
  • isolatedModules in azure-service-bus-queue-trigger, the only example with a ts-jest preset, which cannot emit under TypeScript 6 in language-service mode.

No example sets baseUrl, so none of that cleanup applies here.

The commits cannot be reordered or split into separate PRs: TypeScript 6 with ts-node is exactly the broken combination, and CI exercises both halves — tools/build-example.mjs runs build (→ tsc, which hits the describe error) and then synth (→ the app command, which hits TS5107).

Verification

Beyond type-checking, one example was taken end to end locally on TypeScript 6.0.3:

examples/typescript/aws-prebuilt
  tsc --pretty false     exit 0
  tsx main.ts            exit 0, cdktf.out produced

The rest are covered by the Examples Integration matrix.

Checklist

  • I have updated the PR title to match CDKTN's style guide
  • I have run the linter on my code locally
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation if applicable
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works if applicable
  • New and existing unit tests pass locally with my changes

The diff is 65 files but highly repetitive — three small edits repeated across 22 examples.

🤖 Generated with Claude Code

@jsteinich
jsteinich requested a review from a team as a code owner September 10, 2026 00:44
jsteinich and others added 2 commits September 11, 2026 21:03
The init template moved to tsx in open-constructs#396 because ts-node cannot be used with
TypeScript 6: it merges a bundled @tsconfig/nodeXX default that supplies a
deprecated `moduleResolution: node10`, which the compiler rejects. The
examples still ran `npx ts-node main.ts`, so they demonstrated a setup the
CLI no longer produces, and copying their config into a generated project
would reproduce that failure.

The documentation example was already on tsx; its pin is brought in line
with the rest.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Brings the examples in line with the packages (open-constructs#406) and the init
template (open-constructs#396), which now generates projects on TypeScript 6. Only
possible now that the examples run on tsx: TypeScript 6 with ts-node
fails synth with TS5107.

Two config changes are needed, the same ones the template took:

- `types: ["node", "jest"]`, because the tsconfigs include `__tests__`
  and the jest globals otherwise stop resolving.
- `isolatedModules` in azure-service-bus-queue-trigger, the one example
  with a ts-jest preset, which cannot emit under TypeScript 6 in
  language-service mode.

No example sets `baseUrl`, so none of that cleanup applies here.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

I'm going to lock this pull request because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Oct 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants