Skip to content

Unnecessary widening of function argument's type #19682

@timocov

Description

@timocov

TypeScript Version: 2.6.1 (2.7.0-dev.20171102)

Code

type Nominal<Kind extends string, Type> = Type & {
    [Symbol.species]: Kind;
};

type A = Nominal<'A', string>;

declare const a: Set<A>;
declare const b: Set<A>;

const c1 = Array.from(a).concat(Array.from(b)); // Argument of type 'string[]' is not assignable to parameter of type 'Nominal<"A", string> | ReadonlyArray<Nominal<"A", string>>'.
const c2 = Array.from(a).concat(Array.from<A>(b)); // OK

const aa = Array.from(a);
const bb = Array.from(b);
const cc = aa.concat(bb); // OK

Expected behavior:
No errors.

Actual behavior:
With Array.from(a).concat(Array.from(b)) we have an error Argument of type 'string[]' is not assignable to parameter of type 'Nominal<"A", string> | ReadonlyArray<Nominal<"A", string>>'.

In 2.5.3 it works fine.

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