Skip to content

Work around TypeScript limitation with the PartialDeep type#296

Merged
sindresorhus merged 1 commit intosindresorhus:mainfrom
merrywhether:partialdeep-ts2589
Oct 17, 2021
Merged

Work around TypeScript limitation with the PartialDeep type#296
sindresorhus merged 1 commit intosindresorhus:mainfrom
merrywhether:partialdeep-ts2589

Conversation

@merrywhether
Copy link
Contributor

@merrywhether merrywhether commented Oct 16, 2021

This fixes #295, fixing an edge-case where PartialDeep evaluation can result in infinite depth for specific recursive type situations. This started out trying to add the exact changes from the suggestion, but arrays and tuples behave differently so it got a little more complex.

npm test passes with TS 4.4.4 locally. Verified new test case failed without PartialDeep changes. Added comments following the convention seen in other files, but happy to remove them if they are unnecessary.

baz: 'fred',
bar: {
function: (_: string): void => {}, // eslint-disable-line @typescript-eslint/no-empty-function
function: (_: string): void => undefined,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid eslint magic comment

@sindresorhus sindresorhus changed the title Update PartialDeep to prevent TS2589 error Work around TypeScript limitation with the PartialDeep type Oct 17, 2021
@sindresorhus sindresorhus merged commit 065e764 into sindresorhus:main Oct 17, 2021
@merrywhether merrywhether deleted the partialdeep-ts2589 branch October 17, 2021 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PartialDeep & error TS2589: Type instantiation is excessively deep and possibly infinite

2 participants