Skip to content

Commit dd60984

Browse files
Copilottimovv
andauthored
Fix serializeRecord ESLint violations: missing return type and parameter reassignment (#3741)
* Initial plan * Fix serializeRecord: add return type and avoid parameter reassignment (#3739 Item 1) Co-authored-by: timovv <1787642+timovv@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: timovv <1787642+timovv@users.noreply.github.com> Co-authored-by: Timo van Veenendaal <timov@microsoft.com>
1 parent 9b0987f commit dd60984

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

packages/typespec-test/test/healthInsights_radiologyinsights/generated/typespec-ts/src/static-helpers/serialization/serialize-record.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
export function serializeRecord(item: any, excludes?: string[], serializer?: (item: any) => any) {
5-
excludes = excludes ?? [];
4+
export function serializeRecord(
5+
item: any,
6+
excludes?: string[],
7+
serializer?: (item: any) => any,
8+
): Record<string, any> {
9+
const propertiesToExclude = excludes ?? [];
610
const res: any = {};
711
for (const key of Object.keys(item)) {
8-
if (excludes.includes(key) || item[key] === undefined) {
12+
if (propertiesToExclude.includes(key) || item[key] === undefined) {
913
continue;
1014
}
1115
if (serializer) {

packages/typespec-test/test/openai_generic/generated/typespec-ts/src/static-helpers/serialization/serialize-record.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
export function serializeRecord(item: any, excludes?: string[], serializer?: (item: any) => any) {
5-
excludes = excludes ?? [];
4+
export function serializeRecord(
5+
item: any,
6+
excludes?: string[],
7+
serializer?: (item: any) => any,
8+
): Record<string, any> {
9+
const propertiesToExclude = excludes ?? [];
610
const res: any = {};
711
for (const key of Object.keys(item)) {
8-
if (excludes.includes(key) || item[key] === undefined) {
12+
if (propertiesToExclude.includes(key) || item[key] === undefined) {
913
continue;
1014
}
1115
if (serializer) {

packages/typespec-test/test/openai_non_branded/generated/typespec-ts/src/static-helpers/serialization/serialize-record.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
// Licensed under the MIT License.
22

3-
export function serializeRecord(item: any, excludes?: string[], serializer?: (item: any) => any) {
4-
excludes = excludes ?? [];
3+
export function serializeRecord(
4+
item: any,
5+
excludes?: string[],
6+
serializer?: (item: any) => any,
7+
): Record<string, any> {
8+
const propertiesToExclude = excludes ?? [];
59
const res: any = {};
610
for (const key of Object.keys(item)) {
7-
if (excludes.includes(key) || item[key] === undefined) {
11+
if (propertiesToExclude.includes(key) || item[key] === undefined) {
812
continue;
913
}
1014
if (serializer) {

packages/typespec-ts/static/static-helpers/serialization/serialize-record.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ export function serializeRecord(
22
item: any,
33
excludes?: string[],
44
serializer?: (item: any) => any
5-
) {
6-
excludes = excludes ?? [];
5+
): Record<string, any> {
6+
const propertiesToExclude = excludes ?? [];
77
const res: any = {};
88
for (const key of Object.keys(item)) {
9-
if (excludes.includes(key) || item[key] === undefined) {
9+
if (propertiesToExclude.includes(key) || item[key] === undefined) {
1010
continue;
1111
}
1212
if (serializer) {

0 commit comments

Comments
 (0)