I have demo project I'm about to compile to ES5 with ES2015 modules enabled and tslib
used for external TS helpers:
package.json
{
"name": "foo",
"scripts": {
"build": "tsc"
},
"dependencies": {
"tslib": "^1.9.3"
},
"devDependencies": {
"typescript": "^3.1.3"
}
}
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"outDir": "./lib",
"rootDir": "./src",
"importHelpers": true,
"strict": true,
"experimentalDecorators": true
}
}
src/index.ts
function a(target: any) {
return target;
}
@a
export class Foo {}
This results in an error:
src/index.ts:5:1 - error TS2354: This syntax requires an imported helper but module 'tslib' cannot be found.
While lib/index.js
is correctly compiled:
import * as tslib_1 from "tslib";
function a(target) {
return target;
}
var Foo = /** @class */ (function () {
function Foo() {
}
Foo = tslib_1.__decorate([
a
], Foo);
return Foo;
}());
export { Foo };
How can this problem be solved?