Skip to content

Runtime crash because wrong order of definitions is not detected #13893

@nponeccop

Description

@nponeccop

TypeScript Version: 2.1.5
Code

export const bar = new Foo()

export class Foo {
}

Expected behavior:

Either a compilation error is thrown or working code is generated

Actual behavior:

The following code is generated:

"use strict";
exports.bar = new Foo();
var Foo = (function () {
    function Foo() {
    }
    return Foo;
}());

It fails at runtime both in Edge and Node because var Foo is not yet defined.

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