From 124ff9b99cf8b51bebccbb8b02b2e629ca85bc49 Mon Sep 17 00:00:00 2001 From: "Jiao Di (MSFT)" <80496810+v-jiaodi@users.noreply.github.com> Date: Thu, 1 Aug 2024 20:28:45 +0800 Subject: [PATCH] Fix build error (#2722) * fix moinitor build error * update --------- Co-authored-by: Mary Gao --- packages/typespec-ts/src/modular/buildCodeModel.ts | 8 ++++---- packages/typespec-ts/src/utils/modelUtils.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/typespec-ts/src/modular/buildCodeModel.ts b/packages/typespec-ts/src/modular/buildCodeModel.ts index e49eb71059..8f9698d4c0 100644 --- a/packages/typespec-ts/src/modular/buildCodeModel.ts +++ b/packages/typespec-ts/src/modular/buildCodeModel.ts @@ -1231,17 +1231,17 @@ function applyEncoding( function mergeFormatAndEncoding( format: string | undefined, - encoding: string, + encoding: string | undefined, encodeAsFormat: string | undefined -): string { +): string | undefined { switch (format) { case undefined: - return encodeAsFormat ?? encoding; + return encodeAsFormat ?? encoding ?? format; case "date-time": return encoding; case "duration": default: - return encodeAsFormat ?? encoding; + return encodeAsFormat ?? encoding ?? format; } } diff --git a/packages/typespec-ts/src/utils/modelUtils.ts b/packages/typespec-ts/src/utils/modelUtils.ts index b802db3fa8..a57f496a0e 100644 --- a/packages/typespec-ts/src/utils/modelUtils.ts +++ b/packages/typespec-ts/src/utils/modelUtils.ts @@ -298,17 +298,17 @@ function applyEncoding( function mergeFormatAndEncoding( format: string | undefined, - encoding: string, + encoding: string | undefined, encodeAsFormat: string | undefined -): string { +): string | undefined { switch (format) { case undefined: - return encodeAsFormat ?? encoding; + return encodeAsFormat ?? encoding ?? format; case "date-time": return encoding; case "duration": default: - return encodeAsFormat ?? encoding; + return encodeAsFormat ?? encoding ?? format; } }