Skip to content

Private Member With Same Name of a Type Parameter #38345

Closed
@hediet

Description

@hediet

TypeScript Version: 3.8.3
Either members with the same name of a type parameter are allowed, or they aren't. The current behavior does not make sense: They are allowed, but the member cannot be private if the class is exported.

Expected behavior:
No error is reported, since T refers to the type parameter T, not the member T.

Actual behavior:
An error is reported:

Return type of public method from exported class has or is using private name 'T'.(4055)

Code

export class Test<T> {
	private get T(): T {
		throw "";
	}

	public test(): T {
		return null as any;
	}
}

Playground Link: Provided

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions