Skip to content

Nested conditional generic types yields boolean not assignable to true | false | undefined. #22630

@Griffork

Description

@Griffork

TypeScript Version: 2.8RC

Search Terms:

Code

image

End of friday, so I don't have enough time to make a proper repro, hopefully this will be enough to go by:

 type RecursivePartial<T> = { [param in keyof T]?: T[param] extends object ? RecursivePartial<T[param]> : T[param] }; interface UpdateValue<T> { $set: T extends object? RecursivePartial<T>: T; } interface ArrayUpdate<T> { $wildcard: WriteQuery<T>; } export type TypeWriteQuery<T> = T extends Array<infer U> ? Partial<ArrayUpdate<U>> : T extends object ? WriteQuery<T> : Partial<UpdateValue<T>> ; export type WriteQuery<T> = { [param in keyof T]?: TypeWriteQuery<T[param]> }; ///----- Erroring code: interface Approved { approved: boolean; } var check = <WriteQuery<Approved>>{ approved: { $set: true } };

Expected behavior:
Works fine (unless I've made another mistake).

Actual behavior:
Errors that boolean isn't assignable to true | false | undefined because boolean isn't assignable to false.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions