Skip to content

Commit

Permalink
fix: types and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vicary committed Aug 2, 2022
1 parent eb104a2 commit 0993757
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions packages/cloudwatch-metrics/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import cloudwatchMetrics, { Context } from '.'

// use with default options
let middleware = cloudwatchMetrics()
expectType<middy.MiddlewareObj<unknown, any, any, Context>>(middleware)
expectType<middy.MiddlewareObj<unknown, any, Error, Context>>(middleware)

// use with all options
middleware = cloudwatchMetrics({
namespace: 'myApp',
dimensions: [{ Action: 'Buy' }]
})
expectType<middy.MiddlewareObj<unknown, any, any, Context>>(middleware)
expectType<middy.MiddlewareObj<unknown, any, Error, Context>>(middleware)
2 changes: 1 addition & 1 deletion packages/s3-object-response/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ export type Context<TOptions extends Options | undefined> = LambdaContext & {

declare function s3ObjectResponse<TOptions extends Options | undefined> (
options?: TOptions
): middy.MiddlewareObj<unknown, any, any, Context<TOptions>>
): middy.MiddlewareObj<unknown, any, Error, Context<TOptions>>

export default s3ObjectResponse
4 changes: 2 additions & 2 deletions packages/s3-object-response/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import s3ObjectResponse, { Context } from '.'

// use with default options
let middleware = s3ObjectResponse()
expectType<middy.MiddlewareObj<unknown, any, any, Context<undefined>>>(
expectType<middy.MiddlewareObj<unknown, any, Error, Context<undefined>>>(
middleware
)

Expand All @@ -16,6 +16,6 @@ middleware = s3ObjectResponse({
awsClientCapture: captureAWSClient,
disablePrefetch: true
})
expectType<middy.MiddlewareObj<unknown, any, any, Context<undefined>>>(
expectType<middy.MiddlewareObj<unknown, any, Error, Context<undefined>>>(
middleware
)
2 changes: 1 addition & 1 deletion packages/secrets-manager/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ export type Context<TOptions extends Options | undefined> = TOptions extends {

declare function secretsManager<TOptions extends Options | undefined> (
options?: TOptions
): middy.MiddlewareObj<unknown, any, any, Context<TOptions>>
): middy.MiddlewareObj<unknown, any, Error, Context<TOptions>>

export default secretsManager
4 changes: 2 additions & 2 deletions packages/secrets-manager/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { expectType } from 'tsd'
import rdsSigner, { Context } from '.'

// use with default options
expectType<middy.MiddlewareObj<unknown, any, any, Context<undefined>>>(
expectType<middy.MiddlewareObj<unknown, any, Error, Context<undefined>>>(
rdsSigner()
)

Expand All @@ -24,6 +24,6 @@ const options = {
}

// use with all options
expectType<middy.MiddlewareObj<unknown, any, any, Context<typeof options>>>(
expectType<middy.MiddlewareObj<unknown, any, Error, Context<typeof options>>>(
rdsSigner(options)
)
5 changes: 4 additions & 1 deletion packages/ssm/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import { JsonValue } from 'type-fest'
interface Options<S = SSM>
extends MiddyOptions<S, SSM.Types.ClientConfiguration> {}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
type Basename<T> = T extends `${infer _P}/${infer _S}` ? Basename<_S> : T
// eslint-disable-next-line @typescript-eslint/no-unused-vars
type ExtractPaths<T> = T extends `${infer _P}/${infer _S}` ? T : never
// eslint-disable-next-line @typescript-eslint/no-unused-vars
type ExtractSingles<T> = T extends `${infer _P}/${infer _S}` ? never : T

export type Context<TOptions extends Options | undefined> = TOptions extends {
Expand All @@ -21,6 +24,6 @@ export type Context<TOptions extends Options | undefined> = TOptions extends {

declare function ssm<TOptions extends Options> (
options?: TOptions
): middy.MiddlewareObj<unknown, any, any, Context<TOptions>>
): middy.MiddlewareObj<unknown, any, Error, Context<TOptions>>

export default ssm
4 changes: 3 additions & 1 deletion packages/sts/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export type Context<TOptions extends Options | undefined> = TOptions extends {
>
: LambdaContext

declare function sts (options?: Options): middy.MiddlewareObj
declare function sts<TOptions extends Options> (
options?: TOptions
): middy.MiddlewareObj<unknown, any, Error, Context<TOptions>>

export default sts

0 comments on commit 0993757

Please sign in to comment.