Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Fields with initial values in classes are reported as undefined #226

Closed
@bluetech

Description

@bluetech

What version of TypeScript are you using?

2.2.2

What version of typescript-eslint-parser are you using?

2.1.0

What code were you trying to parse?

class Foo {
    public x = 5;
}

const foo = new Foo();
console.log(foo.x);

What did you expect to happen?

x is identified as a member of Foo.

What happened?

<...>/foo.ts
  2:12  error  'x' is not defined  no-undef

Thanks (I hope this wasn't reported before).

BTW, here is the es5 output, for anyone not familiar with this syntax:

var Foo = (function () {
    function Foo() {
        this.x = 5;
    }
    return Foo;
}());
var foo = new Foo();
console.log(foo.x);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions