microsoft / microsoft/TypeScript
Type inference regression due to circular type definition
Open
Nobody has claimed this yet.
Needs Investigation
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 3.8.0-dev.20200115
Search Terms:
circular type
Code
Replace
type DeepPartial<T> =
T extends Message ? PartialMessage<T> :
T;
type PartialMessage<T extends Message> = { [K in keyof T]?: DeepPartial<T[K]> };
with
type DeepPartial<T> =
T extends Message ? { [K in keyof T]?: DeepPartial<T[K]> } :
T;
Expected behavior:
Both works.
Actual behavior:
Type 'typeof SubMessage' is not assignable to type 'FieldValueType<SubMessage>'.
The types returned by 'from(...)' are incompatible between these types.
Property 'n' is missing in type 'Message' but required in type 'SubMessage'.(2322)
Playground Link:
Without circular type definition
Related Issues:
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 by reproducing the two Playground examples with TypeScript 3.8.0-dev.20200115, then check whether the issue still occurs in the latest published version or typescript@next. Done means the circular and non-circular DeepPartial definitions both type-check without the reported assignability error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100