microsoft / microsoft/TypeScript
Type aliases not being resolved for some functions types
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
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. https://github.com/Microsoft/TypeScript/issues/13095#issuecomment-268627521 and https://github.com/Microsoft/TypeScript/issues/16798#issuecomment-324753135). 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Playground reproduction and inspect the Quick Info output for thisDoesnt versus thisResolves. Trace how the TypeScript type checker or language service presents the Pick result, then verify that the displayed type is { a: number, b: number } without changing the underlying type behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers, developer-experience
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100