microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

Home Page:https://www.typescriptlang.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

andrewbranch opened this issue Β· comments

πŸ”Ž 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

Is this different than #57688?

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