question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`TS2354 This syntax requires an imported helper but module 'tslib' cannot be found.`

See original GitHub issue

I see that the code has some references to tslib and importHelpers so I assume this should work transparently. If not, I’ll be happy to know what is missing.

Here is how to reproduce:

Installed packages:

$ npm ls --depth=0
├── resolve@1.3.2
├── rollup@0.41.6
├── rollup-plugin-typescript2@0.4.0
├── tslib@1.6.0
└── typescript@2.2.2

tsconfig.json:

{
    "compilerOptions": {
        "target": "es5"
    }
}

rollup.config.js:

import typescript from 'rollup-plugin-typescript2';

export default {
	entry: './main.ts',

	plugins: [
		typescript()
	]
}

main.ts:

import {Foo} from './module';

console.log("HERE" + Foo);

And module.ts:

export class Foo {}

export class Bar extends Foo {}

When running rollup as follows:

./node_modules/.bin/rollup -c rollup.config.js

I get this error:

🚨   rpt2: module.ts (3,18): semantic error TS2354 This syntax requires an imported helper but module 'tslib' cannot be found.
module.ts

I think this is because the extends syntax requires an __extends helper from tslib, but typescript can’t find tslib.

Expected result is that the required helpers become part of the bundle.

Thanks.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:19 (6 by maintainers)

github_iconTop GitHub Comments

88reactions
ezolenkocommented, Jun 21, 2022

Looks like you need "moduleResolution": "node" in tsconfig, otherwise typescript can’t find tslib in node_modules.

Not sure if that could pose problems on non-node setups, but I haven’t heard anything to that effect yet.

85reactions
giniedpcommented, Sep 28, 2019

@hueitan i faced the same issue while already having "moduleResolution": "node". Fixed it by adding "tslib": "^1.10.0" to my devDependencies.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"This syntax requires an imported helper but module 'tslib ...
This results in an error: src/index.ts:5:1 - error TS2354: This syntax requires an imported helper but module 'tslib' cannot be found.
Read more >
TypeScript error “TS2354: This syntax requires an ... - GitHub
js:3:8 - error TS2354: This syntax requires an imported helper but module 'tslib' cannot be found. 3 const {ArgumentParser} = require('argparse') ...
Read more >
This syntax requires an imported helper but module 'tslib ...
To solve the error "This syntax requires an imported helper but module 'tslib' cannot be found", install tslib by running npm install -D...
Read more >
How to fix Visual Studio throwing a "This syntax requires an ...
Fixing “This syntax requires an imported helper named '__spreadArray' which does not exist in 'tslib'. Consider upgrading your version of 'tslib ...
Read more >
this syntax requires an imported helper but ... - Code Grepper
this syntax requires an imported helper but module 'tslib' cannot be found.ts(2354). Add Answer | View In TPC Matrix. Technical Problem Cluster First ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found