Skip to content

Commit af76579

Browse files
committed
Use Record type in place of Object in SSDK libs
1 parent b3f37fa commit af76579

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

smithy-typescript-ssdk-libs/server-apigateway/src/lambda.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export function convertVersion1Response(response: HttpResponse): APIGatewayProxy
7777
};
7878
}
7979
function convertResponseHeaders(headers: HeaderBag) {
80-
const retVal: { [key: string]: string[] } = {};
80+
const retVal: Record<string, string[]> = {};
8181
for (const [key, val] of Object.entries(headers)) {
8282
retVal[key] = val.split(",").map((v) => v.trim());
8383
}
@@ -93,7 +93,7 @@ function hasVersion(event: any): event is Record<"version", string> {
9393
}
9494

9595
function convertMultiValueHeaders(multiValueHeaders: APIGatewayProxyEventMultiValueHeaders | null) {
96-
const retVal: { [key: string]: string } = {};
96+
const retVal: Record<string, string> = {};
9797

9898
if (multiValueHeaders === null) {
9999
return retVal;
@@ -112,7 +112,7 @@ function convertMultiValueHeaders(multiValueHeaders: APIGatewayProxyEventMultiVa
112112
// but first we need to split up generated client and servers so we can have different
113113
// language version targets.
114114
function convertHeaders(headers: APIGatewayProxyEventHeaders): HeaderBag {
115-
const retVal: { [key: string]: string } = {};
115+
const retVal: Record<string, string> = {};
116116

117117
for (const [key, val] of Object.entries(headers)) {
118118
if (val !== undefined) {
@@ -128,7 +128,7 @@ function convertMultiValueQueryStringParameters(params: APIGatewayProxyEventMult
128128
return undefined;
129129
}
130130

131-
const retVal: { [key: string]: string[] } = {};
131+
const retVal: Record<string, string[]> = {};
132132

133133
for (const [key, val] of Object.entries(params)) {
134134
if (val !== undefined) {

smithy-typescript-ssdk-libs/server-common/src/unique.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import * as util from "util";
2020
* A shortcut for JSON and Smithy primitives, as well as documents and Smithy-
2121
* modeled structures composed of those primitives
2222
*/
23-
export type Input = { [key: string]: Input } | Array<Input> | Date | Uint8Array | string | number | boolean | null;
23+
export type Input = Record<string, Input> | Array<Input> | Date | Uint8Array | string | number | boolean | null;
2424

2525
/**
2626
* Returns an array of duplicated values in the input. This is equivalent to using

smithy-typescript-ssdk-libs/server-common/src/validation/validators.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,13 @@ export class CompositeCollectionValidator<T> implements MultiConstraintValidator
9090
}
9191
}
9292

93-
export class CompositeMapValidator<T> implements MultiConstraintValidator<{ [key: string]: T }> {
94-
private readonly referenceValidator: MultiConstraintValidator<{ [key: string]: T }>;
93+
export class CompositeMapValidator<T> implements MultiConstraintValidator<Record<string, T>> {
94+
private readonly referenceValidator: MultiConstraintValidator<Record<string, T>>;
9595
private readonly keyValidator: MultiConstraintValidator<string>;
9696
private readonly valueValidator: MultiConstraintValidator<T>;
9797

9898
constructor(
99-
referenceValidator: MultiConstraintValidator<{ [key: string]: T }>,
99+
referenceValidator: MultiConstraintValidator<Record<string, T>>,
100100
keyValidator: MultiConstraintValidator<string>,
101101
valueValidator: MultiConstraintValidator<T>
102102
) {
@@ -105,7 +105,7 @@ export class CompositeMapValidator<T> implements MultiConstraintValidator<{ [key
105105
this.valueValidator = valueValidator;
106106
}
107107

108-
validate(input: { [key: string]: T } | undefined | null, path: string): ValidationFailure[] {
108+
validate(input: Record<string, T> | undefined | null, path: string): ValidationFailure[] {
109109
const retVal: ValidationFailure[] = [];
110110
retVal.push(...this.referenceValidator.validate(input, path));
111111
if (input !== null && input !== undefined) {
@@ -175,7 +175,7 @@ export class EnumValidator implements SingleConstraintValidator<string, EnumVali
175175
}
176176
}
177177

178-
type LengthCheckable = string | { length: number } | { [key: string]: any };
178+
type LengthCheckable = string | { length: number } | Record<string, any>;
179179

180180
export class LengthValidator implements SingleConstraintValidator<LengthCheckable, LengthValidationFailure> {
181181
private readonly min?: number;

0 commit comments

Comments
 (0)