Skip to content

Commit 226c731

Browse files
committed
chore: use union type on LoadedConfigSelectors
1 parent a66eda9 commit 226c731

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

packages/middleware-flexible-checksums/src/NODE_REQUEST_CHECKSUM_CALCULATION_CONFIG_OPTIONS.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import { SelectorType, stringUnionSelector } from "./stringUnionSelector";
66
export const ENV_REQUEST_CHECKSUM_CALCULATION = "AWS_REQUEST_CHECKSUM_CALCULATION";
77
export const CONFIG_REQUEST_CHECKSUM_CALCULATION = "request_checksum_calculation";
88

9-
export const NODE_REQUEST_CHECKSUM_CALCULATION_CONFIG_OPTIONS: LoadedConfigSelectors<string> = {
9+
export const NODE_REQUEST_CHECKSUM_CALCULATION_CONFIG_OPTIONS: LoadedConfigSelectors<RequestChecksumCalculation> = {
1010
environmentVariableSelector: (env) =>
11+
// @ts-expect-error Type 'string | undefined' is not assignable to type 'RequestChecksumCalculation | undefined'.
1112
stringUnionSelector(env, ENV_REQUEST_CHECKSUM_CALCULATION, RequestChecksumCalculation, SelectorType.ENV),
1213
configFileSelector: (profile) =>
14+
// @ts-expect-error Type 'string | undefined' is not assignable to type 'RequestChecksumCalculation | undefined'.
1315
stringUnionSelector(profile, CONFIG_REQUEST_CHECKSUM_CALCULATION, RequestChecksumCalculation, SelectorType.CONFIG),
1416
default: DEFAULT_REQUEST_CHECKSUM_CALCULATION,
1517
};
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import { LoadedConfigSelectors } from "@smithy/node-config-provider";
22

3-
import { DEFAULT_RESPONSE_CHECKSUM_VALIDATION, RequestChecksumCalculation } from "./constants";
3+
import { DEFAULT_RESPONSE_CHECKSUM_VALIDATION, ResponseChecksumValidation } from "./constants";
44
import { SelectorType, stringUnionSelector } from "./stringUnionSelector";
55

66
export const ENV_RESPONSE_CHECKSUM_VALIDATION = "AWS_RESPONSE_CHECKSUM_VALIDATION";
77
export const CONFIG_RESPONSE_CHECKSUM_VALIDATION = "response_checksum_validation";
88

9-
export const NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS: LoadedConfigSelectors<string> = {
9+
export const NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS: LoadedConfigSelectors<ResponseChecksumValidation> = {
1010
environmentVariableSelector: (env) =>
11-
stringUnionSelector(env, ENV_RESPONSE_CHECKSUM_VALIDATION, RequestChecksumCalculation, SelectorType.ENV),
11+
// @ts-expect-error Type 'string | undefined' is not assignable to type 'ResponseChecksumValidation | undefined'.
12+
stringUnionSelector(env, ENV_RESPONSE_CHECKSUM_VALIDATION, ResponseChecksumValidation, SelectorType.ENV),
1213
configFileSelector: (profile) =>
13-
stringUnionSelector(profile, CONFIG_RESPONSE_CHECKSUM_VALIDATION, RequestChecksumCalculation, SelectorType.CONFIG),
14+
// @ts-expect-error Type 'string | undefined' is not assignable to type 'ResponseChecksumValidation | undefined'.
15+
stringUnionSelector(profile, CONFIG_RESPONSE_CHECKSUM_VALIDATION, ResponseChecksumValidation, SelectorType.CONFIG),
1416
default: DEFAULT_RESPONSE_CHECKSUM_VALIDATION,
1517
};

packages/middleware-flexible-checksums/src/stringUnionSelector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const stringUnionSelector = (
1515
key: string,
1616
union: Record<string, string>,
1717
type: SelectorType
18-
) => {
18+
): (typeof union)[keyof typeof union] | undefined => {
1919
if (!(key in obj)) return undefined;
2020

2121
const value = obj[key]!.toUpperCase();

0 commit comments

Comments
 (0)