From 7f1ea6f0cc3da333e099cf428760d965a40a5354 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Wed, 28 Aug 2019 12:38:55 -0700 Subject: [PATCH] chore(repository): workaround for recursive DeepPartial error TS2321: Excessive stack depth comparing types 'DataObject' and 'DataObject'. See https://github.com/microsoft/TypeScript/issues/21592 --- packages/repository/src/common-types.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/repository/src/common-types.ts b/packages/repository/src/common-types.ts index 2d4d5a3860ab..df640c5553a6 100644 --- a/packages/repository/src/common-types.ts +++ b/packages/repository/src/common-types.ts @@ -49,7 +49,11 @@ export interface AnyObject { * An extension of the built-in Partial type which allows partial values * in deeply nested properties too. */ -export type DeepPartial = {[P in keyof T]?: DeepPartial}; +// FIXME(rfeng): https://github.com/microsoft/TypeScript/issues/21592#issuecomment-496723647 +// export type DeepPartial = {[P in keyof T]?: DeepPartial}; +export type DeepPartial = { + [P in keyof T]?: T[P] extends never ? DeepPartial : DeepPartial; +}; /** * Type alias for strongly or weakly typed objects of T