-
-
Couldn't load subscription status.
- Fork 151
Open
Description
🐞 Bug Report
Describe the bug
Using OptionalDeep on an object that contains any breaks the generated type.
Reproduce the bug
type MyType = {
foo: string;
bar: any;
};
type OptionalType = O.Partial<MyType, 'deep'>;
const t: OptionalType = {
foo: 'ok',
bar: {
// ts error: type 'string' is not assignable to type 'OptionalDeep<any>'.
bar: 'baz',
},
};
// OptionalType evaluates to:
type OptionalType = {
foo?: string | undefined;
bar?: OptionalDeep<any> | undefined;
}Expected behavior
OptionalDeep<any> should evaluate to any.
type OptionalType = {
foo?: string | undefined;
bar?: any;
}Possible Solution
Change OptionalDeep to:
export declare type OptionalDeep<O> = O extends object ? {
[K in keyof O]?: OptionalDeep<O[K]>;
} : O;Screenshots
after proposed fix:
bayoudhi
Metadata
Metadata
Assignees
Labels
No labels

