Skip to content

ES6 transpilation of async + super call moves properties from unquoted->quoted #21088

Closed
@mprobst

Description

@mprobst

TypeScript Version: Version 2.7.0-dev.20180109

Code

class A {
  test() {}
}

class B extends A {
  async test() {
    return super.test();
  }
}

Expected behavior:

TypeScript should not emit code that accesses properties by string name, as this breaks optimizers such as Closure Compiler or Uglify with property renaming enabled.

Actual behavior:

class A {
    test() { }
}
class B extends A {
    test() {
        const _super = name => super[name];
        return __awaiter(this, void 0, void 0, function* () {
            return _super("test").call(this);
        });
    }
}

_super("test") boils down to super['test'], which breaks when test was renamed by an optimizing compiler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: TransformsRelates to the public transform APINeeds ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions