Skip to content

Literal type not inferred correctly when using generics #10685

Closed
@OliverJAsh

Description

@OliverJAsh

Version 2.0.2

type A = 'a'
const z: A[] = ['a']; // fine as expected

// how come 'a' cannot be inferred as type `A`?
const x: A[] = Array.from(['a'])  // Error: Type 'string' not assignable to 'a'

// my workaround (without creating a variable):
const y: A[] = Array.from([_.identity<A>('a')])

I think this may be related to #10676

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design LimitationConstraints of the existing architecture prevent this from being fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions