Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Arrow function: Block-scoped variable used before its declaration #14822

Copy link
Copy link
@endel

Description

@endel
Issue body actions

It's not possible to use arrow functions + inheritance anymore.

More info: https://basarat.gitbooks.io/typescript/content/docs/arrow-functions.html#tip-arrow-functions-and-inheritance

TypeScript Version: 2.2.1 / nightly (2.2.0-dev.201xxxxx)

Code

// A *self-contained* demonstration of the problem follows...
class Base {
    f = () => {
        console.log("one");
    }
}

class Child extends Base {
    super_f = this.f;
    f = () => {
        this.super_f();
        console.log("two");
    }
}

let c = new Child();
c.f();

Expected behavior:

Should output

one
two

Actual behavior:

index.ts(8,20): error TS2448: Block-scoped variable 'f' used before its declaration.
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.