Type guards not working when using partial mapped types. #28434
Labels
Bug
A bug in TypeScript
Domain: Control Flow
The issue relates to control flow analysis
Domain: Mapped Types
The issue relates to mapped types
Milestone
TypeScript Version: 3.1.3
Search Terms:
Type Guards, Partial
Code
Expected behavior:
Successful compilation of the above code with
tsc --strictNullChecks
Actual behavior:
Compilation fails with
error TS2339: Property 'name' does not exist on type '{}'
.Interestingly, replacing
type PartialUser = Partial<User>;
withworks as expected. Shouldn't these two definitions of
PartialUser
be functionally equivalent?Playground Link:
https://agentcooper.github.io/typescript-play/?noImplicitAny=false&strictFunctionTypes=false&strictPropertyInitialization=false&noImplicitThis=false&noImplicitReturns=false&alwaysStrict=false#code/C4TwDgpgBA8gRgKygXigbwL5QD5QK4B2AJhAGYCWBERA3AFB2iRQCqAzhAE4rp1T9QIAWwCG5ADYAuKG2CdKAc3oCoBEUIjTZ8gkroZ6jcNAAKIzsHIjx7LjzMWr4gDy3OAPkMB6L1CanzS2s3HjQ6HwFhMXEAfi05RXoI-jUNOJkE3STfAwZSQgBjSwB7AihyNjcACmLEaXgEAEppWqQKqAcgmw5uMP5OCGA8TjK5PAh6DDzCkrKFQbcAOXUIGrrYREbefnJSKCqK6tbGrb6BAaGRqFaAOlSJvigpx4vhsoByd8mgA
The text was updated successfully, but these errors were encountered: