Skip to content

Erroneous compiler error when using generic intersection type as generic class parameter #14022

Description

@jacamera

TypeScript Version: 2.1.6 and 2.2.0-dev.20170212

Code

class Foo<T> {
	f(x: Partial<T>) { }
}
class Bar<T> extends Foo<T & { a: number }> {
	constructor() {
		super();
		this.f({ a: 0 });
	}
}

Expected behavior:
Code compiles without error. Worked fine with 2.2.0-dev.20161204 and broke on 2.2.0-dev.20161205.

Actual behavior:
The following error is generated:

main.ts(7,10): error TS2345: Argument of type '{ a: 0; }' is not assignable to parameter of type 'Partial<T & { a: number; }>'.

Metadata

Metadata

Assignees

Labels

Design LimitationConstraints of the existing architecture prevent this from being fixed

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