Skip to content

Method and field with same name not detected as error #13141

@jeffreymorlan

Description

@jeffreymorlan

TypeScript Version: 2.0.5, 2.1.4, master

Code

class C {
	a(): number { return 0; }
	a: number;
}

Expected behavior:

Since you can't have a method and a field with the same name, there should be a "Duplicate identifier 'a'" error, as there was in TS 1.8, and as there still is if the field comes first.

Actual behavior:

No error. The field takes precedence (.a property has type of number, is not callable).

Metadata

Metadata

Assignees

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