Skip to content

Commit b926581

Browse files
authored
fix: broken ChecksumConfiguration and ConditionalRecursiveTransformExact interface in TS < 4.4 (#926)
* fix: broken ChecksumConfiguration interface in TS < 4.4 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 * fix(types): conditional generic types in TS<4.1 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.
1 parent 2d9473c commit b926581

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

.changeset/eleven-kids-decide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@smithy/types": patch
3+
---
4+
5+
fix: broken ChecksumConfiguration interface in TS < 4.4 and conditional generic types in TS<4.1

packages/types/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"node": ">=14.0.0"
3131
},
3232
"typesVersions": {
33-
"<4.0": {
33+
"<=4.0": {
3434
"dist-types/*": [
3535
"dist-types/ts3.4/*"
3636
]

packages/types/src/extensions/checksum.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,21 @@ export interface ChecksumAlgorithm {
2121
}
2222

2323
/**
24-
* @internal
24+
* @deprecated unused.
2525
*/
26-
export interface ChecksumConfiguration {
27-
addChecksumAlgorithm(algo: ChecksumAlgorithm): void;
28-
checksumAlgorithms(): ChecksumAlgorithm[];
29-
26+
type ChecksumConfigurationLegacy = {
3027
/**
3128
* @deprecated unused.
3229
*/
33-
[other: string | number]: any;
30+
[other in string | number]: any;
31+
};
32+
33+
/**
34+
* @internal
35+
*/
36+
export interface ChecksumConfiguration extends ChecksumConfigurationLegacy {
37+
addChecksumAlgorithm(algo: ChecksumAlgorithm): void;
38+
checksumAlgorithms(): ChecksumAlgorithm[];
3439
}
3540

3641
/**

0 commit comments

Comments
 (0)