Skip to content

Regression: Argument of type ... is not assignable to parameter of type ... #29505

Closed
@asfernandes

Description

@asfernandes

This were working without error in TypeScript 3.0.1 but is not working on 3.2.4.

The select function is intended to accept only property names of type string in the last argument, but in 3.2.4 it does not accept any string.

It gives error: [ts] Argument of type '"value"' is not assignable to parameter of type 'XX extends XX ? "value" : never'. [2345]

export type FilterPropsByType<T, TT> = {
	[K in keyof T]: T[K] extends TT ? K : never
}[keyof T];

function select<
	T extends string | number,
	TList extends object,
	TValueProp extends FilterPropsByType<TList, T>
>(
	property: T, list: TList[], valueProp: TValueProp
)
{
	//
}

export function func<XX extends string>(x: XX, tipos: { value: XX }[]) {
	select(x, tipos, 'value');
}

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions