Skip to content

importHelpers with CommonJS .js file results in "This syntax requires an imported helper but module 'tslib' cannot be found" #58450

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

Closed
andrewbranch opened this issue May 6, 2024 · 2 comments Β· Fixed by #58451
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@andrewbranch
Copy link
Member

πŸ”Ž Search Terms

tslib javascript

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about quantum tunneling

⏯ Playground Link

No response

πŸ’» Code

// index.js
module.exports = function foo(args) {
  const { bar, ...extraArgs } = args;
  return extraArgs;
}
npm i tslib
tsc --checkJs --importHelpers --module commonjs --noEmit index.js

πŸ™ Actual behavior

index.js:2:19 - error TS2354: This syntax requires an imported helper but module 'tslib' cannot be found.

2   const { bar, ...extraArgs } = args;
                    ~~~~~~~~~

πŸ™‚ Expected behavior

No error

Additional information about the issue

No response

@andrewbranch andrewbranch self-assigned this May 6, 2024
@andrewbranch andrewbranch added the Bug A bug in TypeScript label May 6, 2024
@andrewbranch andrewbranch added this to the TypeScript 5.5.1 milestone May 6, 2024
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label May 6, 2024
@fatcerberus
Copy link

Is this different than #57688?

@andrewbranch
Copy link
Member Author

Yes, this has existed in all module resolution modes forever. importHelpers in CommonJS JS files has never worked AFAICT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants