Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transforming JavaScript decorators to the configured target environment ("nodeXX.Y.Z") is not supported yet #393

Open
3 of 5 tasks
darcyrush opened this issue Nov 16, 2023 · 6 comments
Labels
bug Something isn't working tsconfig

Comments

@darcyrush
Copy link

darcyrush commented Nov 16, 2023

Precheck

  • I searched existing issues before opening this one to avoid duplicates
  • I'm able to reproduce this issue and prove it with a minimal reproduction
  • I understand this is not a place to ask for free debugging support

Problem

As requested in 348

Even when a tsconfig.json containing "experimentalDecorators": true is in the root folder as the package.json, when running the commands using tsx or node importing tsx the following error is output

> npx tsx --tsconfig ./src/tsconfig.json src/main.ts

node:internal/process/esm_loader:34
      internalBinding('errors').triggerUncaughtException(
                                ^

Error: Transform failed with 2 errors:
/home/drush/Workspace/pocs/tsx-min-repo/src/health.controller.ts:3:0: ERROR: Transforming JavaScript decorators to the configured target environment ("node21.2.0") is not supported yet
/home/drush/Workspace/pocs/tsx-min-repo/src/health.controller.ts:5:2: ERROR: Transforming JavaScript decorators to the configured target environment ("node21.2.0") is not supported yet
    at failureErrorWithLog (/home/drush/Workspace/pocs/tsx-min-repo/node_modules/esbuild/lib/main.js:1649:15)
    at /home/drush/Workspace/pocs/tsx-min-repo/node_modules/esbuild/lib/main.js:847:29
    at responseCallbacks.<computed> (/home/drush/Workspace/pocs/tsx-min-repo/node_modules/esbuild/lib/main.js:703:9)
    at handleIncomingPacket (/home/drush/Workspace/pocs/tsx-min-repo/node_modules/esbuild/lib/main.js:762:9)
    at Socket.readFromStdout (/home/drush/Workspace/pocs/tsx-min-repo/node_modules/esbuild/lib/main.js:679:7)
    at Socket.emit (node:events:519:28)
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)
    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23) {
  errors: [
    {
      detail: undefined,
      id: '',
      location: {
        column: 0,
        file: '/home/drush/Workspace/pocs/tsx-min-repo/src/health.controller.ts',
        length: 1,
        line: 3,
        lineText: '@Controller()',
        namespace: '',
        suggestion: ''
      },
      notes: [],
      pluginName: '',
      text: 'Transforming JavaScript decorators to the configured target environment ("node21.2.0") is not supported yet'
    },
    {
      detail: undefined,
      id: '',
      location: {
        column: 2,
        file: '/home/drush/Workspace/pocs/tsx-min-repo/src/health.controller.ts',
        length: 1,
        line: 5,
        lineText: "  @Get('health/readiness')",
        namespace: '',
        suggestion: ''
      },
      notes: [],
      pluginName: '',
      text: 'Transforming JavaScript decorators to the configured target environment ("node21.2.0") is not supported yet'
    }
  ],
  warnings: []
}

Expected behavior

I expect tsx should discover and use the "experimentalDecorators": true value within tsconfig.json using either --tsconfig <path> or the TSX_TSCONFIG_PATH env variable.

Minimal reproduction URL

https://github.com/darcyrush/tsx-min-repo

Version

4.1.2

Node.js version

21.2.0

Package manager

npm

Operating system

Linux

Contributions

  • I plan to open a pull request for this issue
  • I plan to make a financial contribution to this project
@darcyrush darcyrush added bug Something isn't working pending triage labels Nov 16, 2023
@privatenumber
Copy link
Owner

Sounds like an esbuild limitation. Can you also file it over at https://github.com/evanw/esbuild?

@privatenumber
Copy link
Owner

privatenumber commented Nov 17, 2023

This is happening because of tsx's implementation of tsconfig. You only listed main.ts in tsconfig.json#files so it only applies that config to main.ts.

Seems TypeScript compiler constructs a dependency tree from files and applies the tsconfig to all of them. I can fix tsx to follow this behavior, but it would really throw a wrench into scenarios where users want to load multiple tsconfigs (monorepos).

Side note: tsx should also recommend enabling experimentalDecorators instead of showing that error.

For now, you can work around this by adjusting your files or includes in tsconfig.json.

@darcyrush
Copy link
Author

Seems TypeScript compiler constructs a dependency tree from files and applies the tsconfig to all of them.

Yes, I stumbled across this 'feature' and find that it works well with es-lint as super cheap tree-shaking to find unused files in our projects. It would be great if tsx could emulate the same behavior as tsc in this respect at some point in the future.

it would really throw a wrench into scenarios where users want to load multiple tsconfigs (monorepos).

This is an interesting comment, as for a concurrent project I am investigating using a monorepo in combination with npm workspaces and would love to use tsx in both cases using files and the tsc dependency tree logic.

I can fix tsx to follow this behavior

If you eventually have a working branch or rc release that manages to allow the use of monorepos alongside the tsc dependency tree logic, I am happy to test with both a normal and monorepo.

For now I confirm that include with all files works around this issue. Thank you for investigating.

@privatenumber privatenumber mentioned this issue Nov 21, 2023
21 tasks
@odinho

This comment was marked as off-topic.

@RobertAKARobin

This comment was marked as off-topic.

@privatenumber
Copy link
Owner

This thread is being locked now that the bug is confirmed, and the recent conversation hasn't been productive in finding a solution.

Issues is intended for reporting and fixing bugs rather than seeking one-off workarounds & help. However, if you're looking for a workaround, please read the previous conversation.

Repository owner locked and limited conversation to collaborators Jan 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working tsconfig
Projects
None yet
Development

No branches or pull requests

4 participants