Skip to content

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

@bluetech

Description

@bluetech

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
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind: supportAsking for support with something or a specific use casescope: dependenciesIssues or PRs about updating a dependencyscope: docsDocumentation could be improved. Or changes that only affect docssolution: tsc behaviorThis is tsc's behavior as well, so this is not a bug with this plugin

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions