Skip to content

Commit

Permalink
fix(@angular-devkit/build-optimizer): prefix renamed extended classes (
Browse files Browse the repository at this point in the history
  • Loading branch information
filipesilva authored and vikerman committed Feb 7, 2019
1 parent e113c44 commit 67986ed
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function testPrefixClasses(content: string) {
exportVarSetter, multiLineComment,
/\(/, multiLineComment,
/\s*function \(_super\) {/, newLine,
/\w*\.?__extends\(\w+, _super\);/,
/\S*\.?__extends\(\S+, _super\);/,
],
].map(arr => new RegExp(arr.map(x => x.source).join(''), 'm'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,40 @@ describe('prefix-classes', () => {
expect(tags.oneLine`${transform(input)}`).toEqual(tags.oneLine`${output}`);
});

it('prefix TS 2.5 - 2.6 renamed downlevel class with extends', () => {
const input = tags.stripIndent`
var NgModuleFactory$1 = /** @class */ (function (_super) {
__extends(NgModuleFactory$$1, _super);
function NgModuleFactory$$1(moduleType) {
var _this = _super.call(this) || this;
_this.moduleType = moduleType;
return _this;
}
NgModuleFactory$$1.prototype.create = function (parentInjector) {
return new NgModuleRef$1(this.moduleType, parentInjector);
};
return NgModuleFactory$$1;
}(NgModuleFactory));
`;
const output = tags.stripIndent`
var NgModuleFactory$1 = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(NgModuleFactory$$1, _super);
function NgModuleFactory$$1(moduleType) {
var _this = _super.call(this) || this;
_this.moduleType = moduleType;
return _this;
}
NgModuleFactory$$1.prototype.create = function (parentInjector) {
return new NgModuleRef$1(this.moduleType, parentInjector);
};
return NgModuleFactory$$1;
}(NgModuleFactory));
`;

expect(testPrefixClasses(input)).toBeTruthy();
expect(tags.oneLine`${transform(input)}`).toEqual(tags.oneLine`${output}`);
});

it('prefix TS 2.5 - 2.6 downlevel class with static variable', () => {
const input = tags.stripIndent`
var StaticTestCase = /** @class */ (function () {
Expand Down

0 comments on commit 67986ed

Please sign in to comment.