Typescript incorrectly infer the types for Readonly optional properties. #18902
Copy link
Copy link
Closed
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed
Description
Activity
- changed the title
[-]Typescript incorrectly infer the types for Readonly members.[/-][+]Typescript incorrectly infer the types for Readonly optional properties.[/+]on Oct 3, 2017 - addedDesign LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed
on Oct 3, 2017 Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
- locked and limited conversation to collaborators
on Jun 14, 2018
Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed
TypeScript Version: 2.5.3) / 2.6.0-dev.20170930
Code
https://github.com/dryganets/typescript-bug/blob/master/index.ts
I expect this code to compile.
This example is
Expected behavior:
type guard
reduces the type from string|undefined to string.
Actual behavior:
type is still string|undefined after check.
The bug doesn't repro if I use the slightly different syntax:
But we have some places in the app where the former syntax is required.