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

support dynamic import with import assertion with module: preserve #58975

Closed
stefanprobst opened this issue Jun 22, 2024 · 0 comments Β· Fixed by #59005
Closed

support dynamic import with import assertion with module: preserve #58975

stefanprobst opened this issue Jun 22, 2024 · 0 comments Β· Fixed by #59005
Assignees
Labels
Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.

Comments

@stefanprobst
Copy link

πŸ”Ž Search Terms

  • module preserve
  • dynamic import
  • import assertions

πŸ•— Version & Regression Information

  • This changed between versions 5.3 and 5.4 (when module: preserve was introduced)

⏯ Playground Link

https://www.typescriptlang.org/play/?module=200#code/IYZwngdgxgBAZgV2gFwJYHsIygCwKZQDWAFAJQwDeAUDLTAE57IL1aoC2ADuvcsQEQA6APQATYMmCCAViEz8ANJRgB3VMhwAuZcjCc82-rPkwAvmdIBuKqapA

πŸ’» Code

see the repo: https://github.com/stefanprobst/issue-ts-preserve

πŸ™ Actual behavior

when running tsc --noEmit in the example repo, i see this error message:

index.ts:2:31 - error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'.

2  return import("./data.json", { with: { type: "json" } });
                                ~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 1 error in index.ts:2

πŸ™‚ Expected behavior

i had expected module: "preserve" to work with dynamic imports + import assertions.

when setting module: "esnext", i see no error message

Additional information about the issue

No response

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Jun 24, 2024
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 5.6.0 milestone Jun 24, 2024
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants