Skip to content

[FEATURE]: Support TypeScript 7 #10533

Open
nodejs/import-in-the-middle
#300

Description

@HarryCruse-Kaluza

Package Name

typescript

Package Version(s)

7.0.0

Describe the feature you'd like

Hi,

I'd like to be able to update my project to TypeScript 7, but dd-trace-js doesn't support it yet.

I saw that Dependabot created this PR for it: #9327

But it was closed with the comment

Let us delay landing the TS update until v7 ships the missing parts

What exactly are the missing parts? I couldn't find an open issue about TS 7, so I'm creating this one so that I can keep an eye on it. Thanks!

Is your feature request related to a problem?

No response

Describe alternatives you've considered

No response

Additional context

No response

Activity

  1. pabloerhard commented on Sep 28, 2026

    @pabloerhard
    Contributor

    Hi @HarryCruse-Kaluza, thanks for opening this. That PR updated TypeScript as a dev dependency of dd-trace-js. TypeScript 7 removed the JavaScript compiler API used by some of our lint and test tooling, which is why that dependency update could not simply be merged.

    I went on and quickly tested a package built from unchanged master, plus published dd-trace-js v5.128.0 and v6.17.0, in isolated projects using TypeScript 7.0.2. Strict type checks passed for the imports and module-resolution settings we tested.

    If your project does fail, could you share the exact dd-trace-js and TypeScript versions, failing command and error, and tsconfig.json (or a minimal reproduction)? This would help us address any existing issue faster.

  2. HarryCruse-Kaluza commented on Oct 1, 2026

    @HarryCruse-Kaluza
    Author

    Ok, thanks for your reply 🙂 I tried to update my project to TS7 a while ago, and we hit a lot of failures with vitest that seemed to be caused by dd-trace. I'll try to run it again to get more info, but I might not have time until next week. I hope that's ok

  3. pabloerhard commented on Oct 1, 2026

    @pabloerhard
    Contributor

    That works. Let us know if any failures still seem to be related to dd-trace-js so we can look into them!

  4. HarryCruse-Kaluza commented on Oct 5, 2026

    @HarryCruse-Kaluza
    Author

    Thanks for being patient! Here are the repro steps:

    mkdir dd-trace-tsc-repro && cd dd-trace-tsc-repro
    npm init -y
    npm install dd-trace@5.127.0 typescript@7.0.2
    npx tsc --version  # works
    NODE_OPTIONS='--import dd-trace/register.js' npx tsc --version
    

    which gives this output:

    node:internal/modules/esm/loader:337
          throw new ERR_REQUIRE_CYCLE_MODULE(message);
                ^
    
    Error [ERR_REQUIRE_CYCLE_MODULE]: Cannot require() ES Module /.../dd-trace-tsc-repro/node_modules/typescript/bin/tsc in a cycle. A cycle involving require(esm) is not allowed to maintain invariants mandated by the ECMAScript specification. Try making at least part of the dependency in the graph lazily loaded.
        at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:337:13)
        at loadESMFromCJS (node:internal/modules/cjs/loader:1774:24)
        at Module._compile (node:internal/modules/cjs/loader:1938:5)
        at Object..js (node:internal/modules/cjs/loader:2096:10)
        at Module.load (node:internal/modules/cjs/loader:1678:32)
        at Module._load (node:internal/modules/cjs/loader:1470:12)
        at wrapModuleLoad (node:internal/modules/cjs/loader:261:19)
        at loadCJSModuleWithModuleLoad (node:internal/modules/esm/translators:376:15)
        at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:248:9)
        at ModuleJob.run (node:internal/modules/esm/module_job:569:25) {
      code: 'ERR_REQUIRE_CYCLE_MODULE'
    }
    
    Node.js v26.10.0
    

    But running the same steps with typescript@6.0.2 succeeds.

    Note that even with TS7, running NODE_OPTIONS='--import dd-trace/register.js' node node_modules/typescript/lib/tsc.js --version does succeed.

    In our CI we're setting NODE_OPTIONS='--import dd-trace/register.js --import dd-trace/ci/init.js' and then running our build & test command, so that Vitest results get uploaded to Datadog. We can work around it to some extent by running the build in a separate step from the tests, but it would be nice if that wasn't necessary. Thanks!

  5. BridgeAR commented on Oct 5, 2026

    @BridgeAR
    Member

    I did not yet look into it closer, but it does seem to be related to the dual module hazard happening with require(ESM). That applies to e.g., GraphQL, AWS SDK, and seemingly also here.

    If it is about that, we have to find a solution for iitm / ritm for this @pabloerhard. I had a look at this before and have draft PRs open but they are outdated and ideally, we fix it not in dd-trace-js, but in the combined resolution one.

  6. BridgeAR commented on Oct 5, 2026

    @BridgeAR
    Member

    Related #10605

  7. pabloerhard commented on Oct 5, 2026

    @pabloerhard
    Contributor

    This appears to be a separate issue from the dual-module hazard. IITM overrides Node’s correctly resolved ESM format for extensionless entrypoints, which seems to affect TypeScript 7’s tsc launcher. I was able to reproduce @HarryCruse-Kaluza failure and I'm working on an upstream iitm fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions