Skip to content

invalid code generated with target "es2015" and "system" modules #6426

@FlorianDold

Description

@FlorianDold

The following code

export class MyClass { }

export function myFunction() {
    return new MyClass();
}

is compiled (with tsc test.ts -m system --target es2015) to

System.register([], function(exports_1) {
    "use strict";
    var MyClass;
    function myFunction() {
        return new MyClass();
    }
    exports_1("myFunction", myFunction);
    return {
        setters:[],
        execute: function() {
            class MyClass {
            }
            exports_1("MyClass", MyClass);
        }
    }
});

which is wrong, since the actual definition of MyClass is not in scope of myFunction anymore.

Compiling down to es5 works as expected with respect to the scope of the class.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions