Skip to content

bump: update TypeScript templates to TypeScript 6#3642

Merged
knative-prow[bot] merged 4 commits intoknative:mainfrom
Ankitsinghsisodya:bump-typescript-6
Apr 29, 2026
Merged

bump: update TypeScript templates to TypeScript 6#3642
knative-prow[bot] merged 4 commits intoknative:mainfrom
Ankitsinghsisodya:bump-typescript-6

Conversation

@Ankitsinghsisodya
Copy link
Copy Markdown
Contributor

What

Bumps TypeScript from v5 to v6 across both TypeScript function templates (templates/typescript/http and templates/typescript/cloudevents), including all required tooling adjustments.

This is the TypeScript follow-up to #3582 (Node template bumps).

Changes

package.json (both templates)

Package Old New Notes
typescript ^5.5.2 ^6.0.3 TypeScript 6
typescript-eslint ^8.0.0 ^8.59.0 first version with TS6 peer dep support
ts-node ^10.9.2 removed ts-node 10 does not support TypeScript 6
tsx ^4.21.0 drop-in replacement for ts-node
tsd ^0.31.1 ^0.33.0 adds TypeScript 6 support

tsconfig.json (both templates)

Option Old New Why
rootDir not set "./src" TS6 no longer infers rootDir; without this, output lands in build/src/ instead of build/
moduleResolution "node" "bundler" "node" (node10) is deprecated in TS6; bundler+commonjs is the recommended migration path

Scripts (both templates)

- "test:unit": "ts-node node_modules/tape/bin/tape test/unit.ts",
- "test:integration": "ts-node node_modules/tape/bin/tape test/integration.ts",
+ "test:unit": "tsx node_modules/tape/bin/tape test/unit.ts",
+ "test:integration": "tsx node_modules/tape/bin/tape test/integration.ts",

package-lock.json regenerated for both templates.

Verification

  • tsc --noEmit passes on both templates with TypeScript 6.0.3
  • tsc build produces build/index.js at the expected path in both templates
  • No source changes required in src/index.ts or test files

Copilot AI review requested due to automatic review settings April 25, 2026 09:47
@knative-prow knative-prow Bot requested review from dsimansk and jrangelramos April 25, 2026 09:48
@knative-prow knative-prow Bot added the size/XXL 🤖 PR changes 1000+ lines, ignoring generated files. label Apr 25, 2026
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented Apr 25, 2026

Hi @Ankitsinghsisodya. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@knative-prow knative-prow Bot added the needs-ok-to-test 🤖 Needs an org member to approve testing label Apr 25, 2026
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

Updates the TypeScript function templates to TypeScript 6 and adjusts associated tooling/config to keep builds/tests working under TS6.

Changes:

  • Bump TypeScript and related tooling dependencies (notably typescript-eslint, tsd) and replace ts-node with tsx.
  • Update tsconfig.json to set rootDir and migrate moduleResolution to bundler.
  • Regenerate package-lock.json for both TypeScript templates to reflect dependency changes.

Reviewed changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
templates/typescript/http/tsconfig.json Adds rootDir and updates module resolution for TS6 output/layout compatibility.
templates/typescript/http/package.json Bumps TS-related dev deps and switches tests from ts-node to tsx.
templates/typescript/http/package-lock.json Lockfile refresh reflecting TS6 + tsx dependency graph.
templates/typescript/cloudevents/tsconfig.json Adds rootDir and updates module resolution for TS6 output/layout compatibility.
templates/typescript/cloudevents/package.json Bumps TS-related dev deps and switches tests from ts-node to tsx.
templates/typescript/cloudevents/package-lock.json Lockfile refresh reflecting TS6 + tsx dependency graph.
Files not reviewed (2)
  • templates/typescript/cloudevents/package-lock.json: Language not supported
  • templates/typescript/http/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread templates/typescript/http/package.json Outdated
Comment thread templates/typescript/cloudevents/package.json Outdated
@Ankitsinghsisodya Ankitsinghsisodya force-pushed the bump-typescript-6 branch 2 times, most recently from f3bdcce to 8694522 Compare April 25, 2026 10:59
Upgraded TypeScript, tsx, tsd, and typescript-eslint to their latest versions.
Replaced ts-node with tsx in test scripts for improved performance.
Added rootDir option in tsconfig.json for better project structure.
Changed moduleResolution from 'node' to 'bundler' for module handling.
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.41%. Comparing base (f2327f3) to head (08828a0).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3642      +/-   ##
==========================================
+ Coverage   56.40%   56.41%   +0.01%     
==========================================
  Files         180      181       +1     
  Lines       20578    20669      +91     
==========================================
+ Hits        11607    11661      +54     
- Misses       7769     7795      +26     
- Partials     1202     1213      +11     
Flag Coverage Δ
e2e 36.29% <ø> (+0.10%) ⬆️
e2e go 32.99% <ø> (+0.14%) ⬆️
e2e node 28.78% <ø> (+0.16%) ⬆️
e2e python 33.36% <ø> (+0.13%) ⬆️
e2e quarkus 28.88% <ø> (+0.12%) ⬆️
e2e rust 28.28% <ø> (+0.09%) ⬆️
e2e springboot 26.78% <ø> (+0.13%) ⬆️
e2e typescript 28.88% <ø> (+0.16%) ⬆️
e2e-config-ci 18.12% <ø> (+0.06%) ⬆️
integration 17.44% <ø> (-0.12%) ⬇️
unit macos-14 43.47% <ø> (-0.04%) ⬇️
unit macos-latest 43.47% <ø> (-0.04%) ⬇️
unit ubuntu-24.04-arm 43.67% <ø> (-0.04%) ⬇️
unit ubuntu-latest 44.34% <ø> (-0.05%) ⬇️
unit windows-latest 43.50% <ø> (-0.04%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.

@Ankitsinghsisodya
Copy link
Copy Markdown
Contributor Author

@matejvasek, just looked into the Podman CI failure — it's not related to the TypeScript changes in this PR at all.

The issue is in hack/cluster.sh. The local registry is started with -p "127.0.0.1:50000:5000" which only binds to IPv4. On the Ubuntu runner, Go resolves localhost to [::1] (IPv6) first, so when func deploy tries to reach the registry it gets connection refused:

dial tcp [::1]:50000: connect: connection refused

The fix is straightforward — drop the 127.0.0.1: prefix so the registry binds on all interfaces (both IPv4 and IPv6):

-    $CONTAINER_ENGINE run -d --restart=always -p "127.0.0.1:50000:5000" --name "func-registry" registry:2
+    $CONTAINER_ENGINE run -d --restart=always -p "50000:5000" --name "func-registry" registry:2

This applies to both the docker and podman branches inside the registry() function in cluster.sh.

What are your thoughts?

@matejvasek
Copy link
Copy Markdown
Contributor

@matejvasek, just looked into the Podman CI failure — it's not related to the TypeScript changes in this PR at all.

The issue is in hack/cluster.sh. The local registry is started with -p "127.0.0.1:50000:5000" which only binds to IPv4. On the Ubuntu runner, Go resolves localhost to [::1] (IPv6) first, so when func deploy tries to reach the registry it gets connection refused:

dial tcp [::1]:50000: connect: connection refused

That's odd I would expect Go to use Happy Eyeballs, dial both 127.0.0.1 and ::1 and use the one that responds first.

The fix is straightforward — drop the 127.0.0.1: prefix so the registry binds on all interfaces (both IPv4 and IPv6):

-    $CONTAINER_ENGINE run -d --restart=always -p "127.0.0.1:50000:5000" --name "func-registry" registry:2
+    $CONTAINER_ENGINE run -d --restart=always -p "50000:5000" --name "func-registry" registry:2

This applies to both the docker and podman branches inside the registry() function in cluster.sh.

What are your thoughts?

There are various school of thought.
I myself would prefer listening on all interfaces :: as you suggested. Some people prefer listening on localhost only for security reason, but IMO that folly and one should use firewall for that.

@matejvasek
Copy link
Copy Markdown
Contributor

Maybe the podman issue was just a flake?

@matejvasek matejvasek requested a review from twoGiants April 27, 2026 15:11
@matejvasek
Copy link
Copy Markdown
Contributor

matejvasek commented Apr 27, 2026

@twoGiants please check this PR, you know JS more than me

Claude reviewd this and does not like the change of bundler

  1. moduleResolution: "bundler" is incompatible with module: "commonjs" (likely broken)...

But maybe it's all right, I do not know.

Copy link
Copy Markdown
Contributor

@twoGiants twoGiants left a comment

Choose a reason for hiding this comment

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

Hi @Ankitsinghsisodya ! 👋 😸

Thank you for your contribution. See my comments below.

@matejvasek I addressed your comment.

Comment thread templates/typescript/cloudevents/package.json
Comment thread templates/typescript/cloudevents/tsconfig.json Outdated
Copy link
Copy Markdown
Contributor

@twoGiants twoGiants left a comment

Choose a reason for hiding this comment

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

/approve
/lgtm

@knative-prow knative-prow Bot added the lgtm 🤖 PR is ready to be merged. label Apr 28, 2026
@matejvasek
Copy link
Copy Markdown
Contributor

/test unit-tests

@matejvasek
Copy link
Copy Markdown
Contributor

I did rerun it, but it may be legit error:

node:internal/errors:484
    ErrorCaptureStackTrace(err);
    ^
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension "" for /home/prow/go/src/knative.dev/func/templates/typescript/cloudevents/node_modules/tape/bin/tape
    at __node_internal_captureLargerStackTrace (node:internal/errors:484:5)
    at new NodeError (node:internal/errors:393:5)
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:79:11)
    at defaultGetFormat (node:internal/modules/esm/get_format:121:38)
    at defaultLoad (node:internal/modules/esm/load:81:20)
    at nextLoad (node:internal/modules/esm/loader:163:28)
    at load (file:///home/prow/go/src/knative.dev/func/templates/typescript/cloudevents/node_modules/tsx/dist/esm/index.mjs:2:1777)
    at nextLoad (node:internal/modules/esm/loader:163:28)
    at ESMLoader.load (node:internal/modules/esm/loader:601:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22)
    at new ModuleJob (node:internal/modules/esm/module_job:63:26)
    at #createModuleJob (node:internal/modules/esm/loader:476:17)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:526:24)
    at async loadESM (node:internal/process/esm_loader:91:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}
Node.js v18.10.0
make: *** [Makefile:265: test-typescript] Error 1
╔═════════════════════════════════════════════════╗
║                                                 ║
║   BUILT-IN TEMPLATE TESTS FAILED TESTS PASSED   ║
║                                                 ║
║           at 2026-04-28 12:49:31.389            ║
║                                                 ║
╚═════════════════════════════════════════════════╝
+ EXIT_VALUE=2
+ set +o xtrace

@matejvasek
Copy link
Copy Markdown
Contributor

The test failed again. Possibly because the knative test infra uses NodeJS 18?

@matejvasek
Copy link
Copy Markdown
Contributor

matejvasek commented Apr 28, 2026

You probably also need to update test/presubmit-tests.sh too.
https://github.com/knative/func/blob/main/test/presubmit-tests.sh#L23

Modified test scripts in TypeScript templates to utilize Node.js with tsx for improved compatibility and performance. Updated Node.js version in presubmit tests from v18.10.0 to v22.11.0.
@knative-prow knative-prow Bot removed the lgtm 🤖 PR is ready to be merged. label Apr 28, 2026
@matejvasek
Copy link
Copy Markdown
Contributor

matejvasek commented Apr 28, 2026

Why you changed tsx => node --require tsx/cjs in the latest commit?
Wasn't updating node version in test/presubmit-tests.sh sufficient?

@matejvasek
Copy link
Copy Markdown
Contributor

/ok-to-test

@knative-prow knative-prow Bot added ok-to-test 🤖 Non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test 🤖 Needs an org member to approve testing labels Apr 28, 2026
@Ankitsinghsisodya
Copy link
Copy Markdown
Contributor Author

Why you changed tsx => node --require tsx/cjs in the latest commit? Wasn't updating node version in test/presubmit-tests.sh sufficient?

Locally some tests were failing. Changing tsx => node --require tsx/cjs worked because it bypasses esm entirely and uses commonjs hooks, which has no problem with extensonless files

@matejvasek matejvasek requested a review from twoGiants April 28, 2026 15:30
@matejvasek
Copy link
Copy Markdown
Contributor

/lgtm

@knative-prow knative-prow Bot added the lgtm 🤖 PR is ready to be merged. label Apr 29, 2026
@matejvasek
Copy link
Copy Markdown
Contributor

/approve

@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented Apr 29, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Ankitsinghsisodya, matejvasek, twoGiants

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow Bot added the approved 🤖 PR has been approved by an approver from all required OWNERS files. label Apr 29, 2026
@knative-prow knative-prow Bot merged commit 13fb32b into knative:main Apr 29, 2026
66 of 70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved 🤖 PR has been approved by an approver from all required OWNERS files. lgtm 🤖 PR is ready to be merged. ok-to-test 🤖 Non-member PR verified by an org member that is safe to test. size/XXL 🤖 PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants