Skip to content

Support TypeScript 7.1 API - #1704

Draft
johnnyreilly with Copilot wants to merge 43 commits into
mainfrom
copilot/implement-new-tsgo-api-support
Draft

Support TypeScript 7.1 API#1704
johnnyreilly with Copilot wants to merge 43 commits into
mainfrom
copilot/implement-new-tsgo-api-support

Conversation

Copilot AI commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

This PR is an attempt at using the TypeScript 7.1+ API.

This pares back the earlier tsgo integration attempt to the new API alone. Instead of carrying both implementations, experimentalNativeApi now routes through the tsgo API directly, with the existing loader flow left in place for non-tsgo usage.

  • What changed

    • Added a dedicated experimental tsgo transpile path behind experimentalNativeApi
    • Stopped trying to preserve the prior/native hybrid design; this path uses the new API only
    • Kept the existing typescript dependency for current loader internals and config handling, while loading the tsgo API from typescript-native-preview
  • Loader integration

    • Made loader instance creation async so the ESM-only tsgo sync API can be loaded at runtime
    • Switched transpile-only emit to a native tsgo-backed implementation when experimentalNativeApi is enabled
    • Reused existing source-map/module completion flow so the new path plugs into webpack with minimal surface change
  • Native API path

    • Added /src/native.ts to:
      • import typescript-native-preview/unstable/sync
      • open/update a tsgo snapshot for the configured project
      • emit JavaScript for the current file via getJavaScriptEmit
      • register project/config dependencies with webpack
      • translate tsgo diagnostics into webpack module errors
  • Option model

    • Added experimentalNativeApi to loader options
    • Kept this path scoped to transpileOnly; it does not attempt to support the older language-service/watch/project-reference machinery
  • Execution coverage
    Execution tests are generally passing - loaderOptions does not

@johnnyreilly

Copy link
Copy Markdown
Member

@copilot update

ts: [5.6.2, 5.7.2, 5.8.2, 5.9.2, 6.0.2] # next excluded for now
and
ts: [5.6.2, 5.7.2, 5.8.2, 5.9.2, 6.0.2] # next excluded for now
to only cater for: 7.1.0-dev.20260725.1 - the existing versions specified do not contain the new API.

We expect execution-tests to pass after this change

Copilot AI commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

@copilot update

ts: [5.6.2, 5.7.2, 5.8.2, 5.9.2, 6.0.2] # next excluded for now
and https://github.com/TypeStrong/ts-loader/blob/53082fbe1cdeb560b6...

Updated in fcc8a21 to run the execution-test matrix only against 7.1.0-dev.20260725.1. I also verified the native path locally with yarn build && yarn execution-tests -- --single-test nativeApiTranspile.

@johnnyreilly

Copy link
Copy Markdown
Member

@copilot great work! We would like the following to succeed:

yarn build && yarn execution-tests

Remember backwards compatibility is not required - feel free to make changes

Copilot AI commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

@copilot great work! We would like the following to succeed:

yarn build && yarn execution-tests
...

Verified on fcc8a21: yarn build && yarn execution-tests now succeeds locally (30 execution suites passed).

@johnnyreilly

Copy link
Copy Markdown
Member

@copilot we have explictly removed the historic typescript version from dependencies and moved to use 7.1 directly. This has broken compilation. Please fix it. You will likely need to use new APIs in TypeScript 7 to achieve this. No cheating.

Copilot AI commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

@copilot we have explictly removed the historic typescript version from dependencies and moved to use 7.1 directly. This has broken compilation. Please fix it. You will likely need to use new APIs i...

Updated in 4706cfe. yarn build now passes against direct TypeScript 7 by routing the loader through typescript/unstable/sync instead of the removed legacy compiler API.

@johnnyreilly

Copy link
Copy Markdown
Member

@copilot make experimentalNativeApi: true the default behaviour and ensure execution-tests pass. We are happy to ignore loaderOptions test for now

Copilot AI commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

@copilot make experimentalNativeApi: true the default behaviour and ensure execution-tests pass. We are happy to ignore loaderOptions test for now

Addressed in 048c5ce. The native execution test now relies on the default native API path, loaderOptions is skipped for now, and yarn build && yarn execution-tests passes locally.

@johnnyreilly johnnyreilly changed the title Add minimal experimental tsgo transpile path Support TypeScript 7.1 API Jul 28, 2026
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.

2 participants