Skip to content

Commit 18ae2f9

Browse files
committed
chore(core/httpAuthSchemes): fix type declaration of resolved credentials
1 parent 8be4f2a commit 18ae2f9

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

packages/core/src/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { setCredentialFeature } from "@aws-sdk/core/client";
2-
import { AttributedAwsCredentialIdentity } from "@aws-sdk/types";
2+
import type { AttributedAwsCredentialIdentity, MergeFunctions } from "@aws-sdk/types";
33
import {
44
doesIdentityRequireRefresh,
55
isIdentityExpired,
@@ -81,9 +81,8 @@ export interface AwsSdkSigV4AuthResolvedConfig {
8181
/**
8282
* Resolved value for input config {@link AwsSdkSigV4AuthInputConfig.credentials}
8383
* This provider MAY memoize the loaded credentials for certain period.
84-
* See {@link MemoizedProvider} for more information.
8584
*/
86-
credentials: AwsCredentialIdentityProvider;
85+
credentials: MergeFunctions<AwsCredentialIdentityProvider, MemoizedProvider<AwsCredentialIdentity>>;
8786
/**
8887
* Resolved value for input config {@link AwsSdkSigV4AuthInputConfig.signer}
8988
*/
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Exact } from "@smithy/types";
2+
3+
import type { MergeFunctions } from "./function";
4+
5+
{
6+
const function1 = ({ a }: { a: boolean }) => ({ a: a });
7+
const function2 = ({ b }: { b: boolean }) => ({ b: b });
8+
9+
const function3: MergeFunctions<typeof function1, typeof function2> = null as any;
10+
11+
// it should merge the first arg and return value objects of function1 and function2
12+
// into function3.
13+
14+
type assert0 = Exact<typeof function3, ({ a, b }: { a: boolean; b: boolean }) => { a: boolean; b: boolean }>;
15+
const assert0: assert0 = true as const;
16+
}

packages/types/src/function.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Resolves a function that accepts both the object argument fields of F1 and F2.
3+
* The function returns an intersection of what F1 and F2 return.
4+
*
5+
* @public
6+
*/
7+
export type MergeFunctions<F1, F2> = F1 extends (arg: infer A1) => infer R1
8+
? F2 extends (arg: infer A2) => infer R2
9+
? (arg: A1 & A2) => R1 & R2
10+
: never
11+
: never;

packages/types/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export * from "./endpoint";
1313
export * from "./eventStream";
1414
export * from "./extensions";
1515
export * from "./feature-ids";
16+
export * from "./function";
1617
export * from "./http";
1718
export * from "./identity";
1819
export * from "./logger";

0 commit comments

Comments
 (0)