Skip to content

Commit 0092a08

Browse files
committed
Use Record type in place of Object in typescript files
1 parent b3f37fa commit 0092a08

File tree

4 files changed

+24
-17
lines changed

4 files changed

+24
-17
lines changed

smithy-typescript-codegen/src/main/resources/software/amazon/smithy/typescript/codegen/protocol-test-form-urlencoded-stub.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,27 @@
22
* Returns a map of key names that were un-equal to value objects showing the
33
* discrepancies between the components.
44
*/
5-
const compareEquivalentFormUrlencodedBodies = (expectedBody: string, generatedBody: string): Object => {
6-
const fromEntries = (components: string[][]): { [key: string]: string } => {
7-
const parts: { [key: string]: string } = {};
5+
const compareEquivalentFormUrlencodedBodies = (
6+
expectedBody: string,
7+
generatedBody: string
8+
): Object => {
9+
const fromEntries = (components: string[][]): Record<string, string> => {
10+
const parts: Record<string, string> = {};
811

9-
components.forEach(component => {
12+
components.forEach((component) => {
1013
parts[component[0]] = component[1];
1114
});
1215

1316
return parts;
1417
};
1518

1619
// Generate to k:v maps from query components
17-
const expectedParts = fromEntries(expectedBody.split("&").map(part => part.trim().split("=")));
18-
const generatedParts = fromEntries(generatedBody.split("&").map(part => part.trim().split("=")));
20+
const expectedParts = fromEntries(
21+
expectedBody.split("&").map((part) => part.trim().split("="))
22+
);
23+
const generatedParts = fromEntries(
24+
generatedBody.split("&").map((part) => part.trim().split("="))
25+
);
1926

2027
return compareParts(expectedParts, generatedParts);
21-
}
28+
};

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)