`importHelpers` with CommonJS `.js` file results in "This syntax requires an imported helper but module 'tslib' cannot be found"
andrewbranch opened this issue Β· comments
Andrew Branch commented
π 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
Bruce Pascoe commented
Is this different than #57688?
Andrew Branch commented
Yes, this has existed in all module resolution modes forever. importHelpers
in CommonJS JS files has never worked AFAICT