`TS2354 This syntax requires an imported helper but module 'tslib' cannot be found.`
See original GitHub issueI 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:
- Created 6 years ago
- Reactions:3
- Comments:19 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looks like you need
"moduleResolution": "node"
in tsconfig, otherwise typescript can’t findtslib
innode_modules
.Not sure if that could pose problems on non-node setups, but I haven’t heard anything to that effect yet.
@hueitan i faced the same issue while already having
"moduleResolution": "node"
. Fixed it by adding"tslib": "^1.10.0"
to my devDependencies.