Closed thynson closed 4 years ago
I have the same error. I tried to install tslib@1.11.2
with yarn & npm, and checked the package.json
file, but nothing really happened. I was still getting the same error. So was to see this.
I have the same error. I tried to install
tslib@1.11.2
with yarn & npm, and checked thepackage.json
file, but nothing really happened. I was still getting the same error. So was to see this.
Have you tried removing the node_modules and lockfile before downgrading tslib to ~1.11.2
?
I solved it afterwards. Here is my full answer.
P.S. If you have solved the problem. please close the issue that you opened here.
P.S. If you have solved the problem. please close the issue that you opened here.
I've solved it before submit this issue, but I think it's an accidential breaking change of tslib and they should fix it.
Fixed #107
Is tslib even regression tested with the most popular TypeScript libraries?
1.13.0 is out and should fix things, 1.12.0 has been deprecated. 2.0.0 can be opted into for TypeScript 3.9 users.
@DanielRosenwasser tslib@2.0.0 still fails https://github.com/typeorm/typeorm/issues/6054#issuecomment-643776357
@weswigham @rbuckton any clues?
This is the main reason: https://github.com/typeorm/typeorm/issues/6054#issuecomment-627568058
They have two lines in their index.ts
file causing the issue:
https://github.com/typeorm/typeorm/blob/defa9bced0b5d1258e4f50d5c590978e6d3324d3/src/index.ts#L105
export * from "./entity-manager/EntityManager";
https://github.com/typeorm/typeorm/blob/defa9bced0b5d1258e4f50d5c590978e6d3324d3/src/index.ts#L141
export {EntityManager} from "./entity-manager/EntityManager";
We aren't tracking the re-export in the same way we do a local export:
I think this is an issue for the compiler/emitter, not tslib
. We really should also have something like an exports.Foo = void 0;
assignment at the top of the file like we do for Bar
, just so we don't attempt to re-export it later.
input
// @target: esnext
// @module: commonjs
// @importHelpers: true
export * from "./other";
export { Foo } from "./other";
export class Bar {}
actual output
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Bar = void 0;
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./other"), exports);
var other_1 = require("./other");
Object.defineProperty(exports, "Foo", { enumerable: true, get: function () { return other_1.Foo; } });
class Bar {
}
exports.Bar = Bar;
expected output
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Bar = exports.Foo = void 0;
// ^^^^^^^^^^^^^
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./other"), exports);
var other_1 = require("./other");
Object.defineProperty(exports, "Foo", { enumerable: true, get: function () { return other_1.Foo; } });
class Bar {
}
exports.Bar = Bar;
cough https://github.com/microsoft/TypeScript/pull/38809 cough
Maybe wanna review that and backport to 3.9
After upgrading tslib to 1.12, I get the following error message when requiring 'typeorm'(which requiring tslib@^1.9.0)
It seems like there's breaking changes in
tslib.__exportStar()
that defining getter instead of defining properties on target object. Resulting that once a symbol has already been exported byexport * from './other-files'
indirectly, the above error will be thrown when it is explicitly exported again in same file.