Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around TypeScript limitation with the PartialDeep type #296

Merged
merged 1 commit into from Oct 17, 2021

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.

@@ -4,7 +4,7 @@ import {PartialDeep} from '../index';
const foo = {
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