Skip to content

fix: broken ChecksumConfiguration and ConditionalRecursiveTransformExact interface in TS < 4.4 #926

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

Merged
merged 6 commits into from
Sep 12, 2023

Conversation

AllanZhengYP
Copy link
Contributor

@AllanZhengYP AllanZhengYP commented Sep 12, 2023

This PR fixes the following 2 issues:

"TS1337: An index signature parameter type cannot be a union type. Consider using a mapped object type instead. 

[other: string | number]: any;". 
  • The referred type ConditionalRecursiveTransformExact<T, FromType, ToType> uses
    conditional generic type that is only supported in TS>=4.1. However the typesVersions
    directs consumers' TSC 4.0 to the types with this definition, hence consumers will see
    following error:
error TS2315: Type 'ConditionalRecursiveTransformExact' is not generic.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Before TS 4.4, TS does not allow the index signature as union type. Consuming library with this interface will cause error:
"TS1337: An index signature parameter type cannot be a union type. Consider using a mapped object type instead.
[other: string | number]: any;". This issue was fixed in TS 4.4: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-4.html#symbol-and-template-string-pattern-index-signatures

Fixing this issue so it won't break users with TSC < 4.4
@AllanZhengYP AllanZhengYP requested review from a team as code owners September 12, 2023 00:37
@stocaaro
Copy link

Related issue: #876

The referred type `ConditionalRecursiveTransformExact<T, FromType, ToType>` uses
conditional generic type that is only supported in TS>=4.1. However the typesVersions
directs consumers' TSC 4.0 to the types with this definition, hence consumers will see
following error:

error TS2315: Type 'ConditionalRecursiveTransformExact' is not generic.

Changing the typesVersions directive resolves the issue.
@AllanZhengYP AllanZhengYP changed the title fix: broken ChecksumConfiguration interface in TS < 4.4 fix: broken ChecksumConfiguration and ConditionalRecursiveTransformExact interface in TS < 4.4 Sep 12, 2023
Copy link
Contributor

@srchase srchase left a comment

Choose a reason for hiding this comment

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

nit: The second changeset entry isn't needed. The first one covers the whole PR for this package.

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.

5 participants