diff --git a/packages/stack-shared/src/config/schema.ts b/packages/stack-shared/src/config/schema.ts index fc8aeac4e..ac450aaf8 100644 --- a/packages/stack-shared/src/config/schema.ts +++ b/packages/stack-shared/src/config/schema.ts @@ -324,14 +324,14 @@ const environmentConfigDefaults = {} as const satisfies DefaultsType ({ - containedPermissionIds: {}, + containedPermissionIds: (key: string) => undefined, description: undefined, scope: undefined, }), defaultPermissions: { - teamCreator: {}, - teamMember: {}, - signUp: {}, + teamCreator: (key: string) => undefined, + teamMember: (key: string) => undefined, + signUp: (key: string) => undefined, }, }, @@ -416,12 +416,19 @@ type _DeepOmitDefaultsImpl = T extends object ? ( ) : T; type DeepOmitDefaults = _DeepOmitDefaultsImpl, U>; type DefaultsType = DeepReplaceAllowFunctionsForObjects, IntersectAll<{ [K in keyof U]: DeepReplaceFunctionsWithObjects }>>>; -typeAssertIs, c: 456 } }, [{ a: { c: 456 } }]>, { a: { b: Record | ((key: string) => 123) } }>()(); +typeAssertIs, c: 456 } }, [{ a: { c: 456 } }]>, { a: { b: ((key: string) => 123) | Record & ((key: string) => 123) } }>()(); -type DeepReplaceAllowFunctionsForObjects = T extends object ? { [K in keyof T]: DeepReplaceAllowFunctionsForObjects } | (string extends keyof T ? (arg: Exclude) => DeepReplaceAllowFunctionsForObjects : never) : T; -type ReplaceFunctionsWithObjects = T & (T extends (arg: infer K extends string) => infer R ? Record & object : unknown); +type DeepReplaceAllowFunctionsForObjects = T extends object + ? ( + string extends keyof T + ? ((arg: Exclude) => DeepReplaceAllowFunctionsForObjects) & ({ [K in keyof T]?: DeepReplaceAllowFunctionsForObjects } | {}) + : { [K in keyof T]: DeepReplaceAllowFunctionsForObjects } + ) + : + T; +type ReplaceFunctionsWithObjects = T & (T extends (arg: infer K extends string) => infer R ? Record & object : unknown); type DeepReplaceFunctionsWithObjects = T extends object ? { [K in keyof ReplaceFunctionsWithObjects]: DeepReplaceFunctionsWithObjects[K]> } : T; -typeAssertIs number) }>, { a: { b: 123, [key: string]: number } }>()(); +typeAssertIs number) }>, { a: { b: 123, [key: string]: number | undefined } }>()(); function deepReplaceFunctionsWithObjects(obj: any): any { return mapValues({ ...obj }, v => (isObjectLike(v) ? deepReplaceFunctionsWithObjects(v as any) : v));