Skip to content

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

@andrewbranch

Description

@andrewbranch

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

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions