Skip to content

Type aliases not being resolved for some functions types #30312

@gilbert

Description

@gilbert

TypeScript Version: 3.4.0-dev.20190310

Search Terms:

Resolve / flatten / simplify type aliases for function calls

resolve type aliases

Code

let subject = {a:1,b:2,c:3,d:4}

type thisResolves = Pick<typeof subject, 'a' | 'b'>

let thisDoesnt = pick(subject, ['a', 'b'])

declare function pick<T, K extends keyof T>(obj: T, keys: K[]): Pick<T,K>

Expected behavior:

The Quick Info type of thisDoesnt resolves to { a: number, b: number}

Actual behavior:

The Quick Info type of thisDoesnt resolves to Pick<{ a: number, b: number, c: number, d: number}, 'a' | 'b'>

Playground Link: here

Related Issues:

I've seen in other issues that type aliases are eagerly resolved (e.g. #13095 (comment) and #16798 (comment)). This is a case where that behavior is useful, since reading through a lot of Pick<Foo<Bar<... in VS Code makes it difficult to figure out the true source of a type error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions