@azure-tools/typespec-ts 0.54.0-alpha.20260601.2 → 0.54.0-dev.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/CHANGELOG.md +0 -11
  2. package/README.md +0 -4
  3. package/dist/src/contextManager.js +3 -3
  4. package/dist/src/contextManager.js.map +1 -1
  5. package/dist/src/framework/hooks/binder.js +19 -20
  6. package/dist/src/framework/hooks/binder.js.map +1 -1
  7. package/dist/src/framework/hooks/sdkTypes.js +1 -2
  8. package/dist/src/framework/hooks/sdkTypes.js.map +1 -1
  9. package/dist/src/framework/load-static-helpers.js +7 -8
  10. package/dist/src/framework/load-static-helpers.js.map +1 -1
  11. package/dist/src/framework/reference.js +1 -1
  12. package/dist/src/framework/reference.js.map +1 -1
  13. package/dist/src/index.d.ts.map +1 -1
  14. package/dist/src/index.js +34 -45
  15. package/dist/src/index.js.map +1 -1
  16. package/dist/src/modular/buildClassicalClient.js +14 -15
  17. package/dist/src/modular/buildClassicalClient.js.map +1 -1
  18. package/dist/src/modular/buildClassicalOperationGroups.js +4 -3
  19. package/dist/src/modular/buildClassicalOperationGroups.js.map +1 -1
  20. package/dist/src/modular/buildClientContext.js +1 -2
  21. package/dist/src/modular/buildClientContext.js.map +1 -1
  22. package/dist/src/modular/buildModularOptions.js +4 -5
  23. package/dist/src/modular/buildModularOptions.js.map +1 -1
  24. package/dist/src/modular/buildOperations.js +1 -2
  25. package/dist/src/modular/buildOperations.js.map +1 -1
  26. package/dist/src/modular/buildProjectFiles.js +1 -2
  27. package/dist/src/modular/buildProjectFiles.js.map +1 -1
  28. package/dist/src/modular/buildRestorePoller.js +1 -2
  29. package/dist/src/modular/buildRestorePoller.js.map +1 -1
  30. package/dist/src/modular/buildRootIndex.d.ts.map +1 -1
  31. package/dist/src/modular/buildRootIndex.js +9 -14
  32. package/dist/src/modular/buildRootIndex.js.map +1 -1
  33. package/dist/src/modular/buildSubpathIndex.js +1 -2
  34. package/dist/src/modular/buildSubpathIndex.js.map +1 -1
  35. package/dist/src/modular/emitLoggerFile.js +2 -2
  36. package/dist/src/modular/emitLoggerFile.js.map +1 -1
  37. package/dist/src/modular/emitModels.js +32 -46
  38. package/dist/src/modular/emitModels.js.map +1 -1
  39. package/dist/src/modular/emitModelsOptions.js +1 -1
  40. package/dist/src/modular/emitModelsOptions.js.map +1 -1
  41. package/dist/src/modular/emitSamples.js +34 -30
  42. package/dist/src/modular/emitSamples.js.map +1 -1
  43. package/dist/src/modular/emitTests.js +4 -6
  44. package/dist/src/modular/emitTests.js.map +1 -1
  45. package/dist/src/modular/helpers/classicalOperationHelpers.js +42 -42
  46. package/dist/src/modular/helpers/classicalOperationHelpers.js.map +1 -1
  47. package/dist/src/modular/helpers/clientHelpers.js +20 -25
  48. package/dist/src/modular/helpers/clientHelpers.js.map +1 -1
  49. package/dist/src/modular/helpers/clientOptionHelpers.js +1 -1
  50. package/dist/src/modular/helpers/clientOptionHelpers.js.map +1 -1
  51. package/dist/src/modular/helpers/exampleValueHelpers.d.ts.map +1 -1
  52. package/dist/src/modular/helpers/exampleValueHelpers.js +39 -32
  53. package/dist/src/modular/helpers/exampleValueHelpers.js.map +1 -1
  54. package/dist/src/modular/helpers/namingHelpers.js +3 -5
  55. package/dist/src/modular/helpers/namingHelpers.js.map +1 -1
  56. package/dist/src/modular/helpers/operationHelpers.js +75 -99
  57. package/dist/src/modular/helpers/operationHelpers.js.map +1 -1
  58. package/dist/src/modular/helpers/typeHelpers.js +3 -5
  59. package/dist/src/modular/helpers/typeHelpers.js.map +1 -1
  60. package/dist/src/modular/serialization/buildDeserializerFunction.js +11 -14
  61. package/dist/src/modular/serialization/buildDeserializerFunction.js.map +1 -1
  62. package/dist/src/modular/serialization/buildSerializerFunction.js +17 -20
  63. package/dist/src/modular/serialization/buildSerializerFunction.js.map +1 -1
  64. package/dist/src/modular/serialization/buildXmlSerializerFunction.js +31 -40
  65. package/dist/src/modular/serialization/buildXmlSerializerFunction.js.map +1 -1
  66. package/dist/src/modular/serialization/serializeUtils.d.ts.map +1 -1
  67. package/dist/src/modular/serialization/serializeUtils.js +24 -25
  68. package/dist/src/modular/serialization/serializeUtils.js.map +1 -1
  69. package/dist/src/modular/type-expressions/get-enum-expression.js +1 -2
  70. package/dist/src/modular/type-expressions/get-enum-expression.js.map +1 -1
  71. package/dist/src/modular/type-expressions/get-model-expression.js +5 -6
  72. package/dist/src/modular/type-expressions/get-model-expression.js.map +1 -1
  73. package/dist/src/modular/type-expressions/get-nullable-expression.js +2 -3
  74. package/dist/src/modular/type-expressions/get-nullable-expression.js.map +1 -1
  75. package/dist/src/modular/type-expressions/get-type-expression.js +2 -4
  76. package/dist/src/modular/type-expressions/get-type-expression.js.map +1 -1
  77. package/dist/src/rlc-common/buildClient.js +26 -30
  78. package/dist/src/rlc-common/buildClient.js.map +1 -1
  79. package/dist/src/rlc-common/buildClientDefinitions.js +6 -5
  80. package/dist/src/rlc-common/buildClientDefinitions.js.map +1 -1
  81. package/dist/src/rlc-common/buildIndexFile.js +2 -3
  82. package/dist/src/rlc-common/buildIndexFile.js.map +1 -1
  83. package/dist/src/rlc-common/buildIsUnexpectedHelper.js +12 -10
  84. package/dist/src/rlc-common/buildIsUnexpectedHelper.js.map +1 -1
  85. package/dist/src/rlc-common/buildLogger.js +1 -2
  86. package/dist/src/rlc-common/buildLogger.js.map +1 -1
  87. package/dist/src/rlc-common/buildMethodShortcuts.js +1 -1
  88. package/dist/src/rlc-common/buildMethodShortcuts.js.map +1 -1
  89. package/dist/src/rlc-common/buildObjectTypes.js +38 -60
  90. package/dist/src/rlc-common/buildObjectTypes.js.map +1 -1
  91. package/dist/src/rlc-common/buildParameterTypes.js +12 -15
  92. package/dist/src/rlc-common/buildParameterTypes.js.map +1 -1
  93. package/dist/src/rlc-common/buildPollingHelper.js +7 -8
  94. package/dist/src/rlc-common/buildPollingHelper.js.map +1 -1
  95. package/dist/src/rlc-common/buildResponseTypes.js +4 -5
  96. package/dist/src/rlc-common/buildResponseTypes.js.map +1 -1
  97. package/dist/src/rlc-common/helpers/apiVersionUtil.js +5 -6
  98. package/dist/src/rlc-common/helpers/apiVersionUtil.js.map +1 -1
  99. package/dist/src/rlc-common/helpers/importsUtil.js +9 -12
  100. package/dist/src/rlc-common/helpers/importsUtil.js.map +1 -1
  101. package/dist/src/rlc-common/helpers/nameConstructors.js +2 -4
  102. package/dist/src/rlc-common/helpers/nameConstructors.js.map +1 -1
  103. package/dist/src/rlc-common/helpers/nameUtils.js +9 -10
  104. package/dist/src/rlc-common/helpers/nameUtils.js.map +1 -1
  105. package/dist/src/rlc-common/helpers/operationHelpers.js +10 -21
  106. package/dist/src/rlc-common/helpers/operationHelpers.js.map +1 -1
  107. package/dist/src/rlc-common/helpers/packageUtil.js +3 -6
  108. package/dist/src/rlc-common/helpers/packageUtil.js.map +1 -1
  109. package/dist/src/rlc-common/helpers/schemaHelpers.js +2 -6
  110. package/dist/src/rlc-common/helpers/schemaHelpers.js.map +1 -1
  111. package/dist/src/rlc-common/helpers/typeUtil.js +4 -8
  112. package/dist/src/rlc-common/helpers/typeUtil.js.map +1 -1
  113. package/dist/src/rlc-common/helpers/valueGenerationUtil.js +4 -7
  114. package/dist/src/rlc-common/helpers/valueGenerationUtil.js.map +1 -1
  115. package/dist/src/rlc-common/metadata/buildApiExtractorConfig.js +2 -3
  116. package/dist/src/rlc-common/metadata/buildApiExtractorConfig.js.map +1 -1
  117. package/dist/src/rlc-common/metadata/buildChangelogFile.js +1 -2
  118. package/dist/src/rlc-common/metadata/buildChangelogFile.js.map +1 -1
  119. package/dist/src/rlc-common/metadata/buildESLintConfig.js +3 -4
  120. package/dist/src/rlc-common/metadata/buildESLintConfig.js.map +1 -1
  121. package/dist/src/rlc-common/metadata/buildPackageFile.js +19 -23
  122. package/dist/src/rlc-common/metadata/buildPackageFile.js.map +1 -1
  123. package/dist/src/rlc-common/metadata/buildReadmeFile.js +25 -25
  124. package/dist/src/rlc-common/metadata/buildReadmeFile.js.map +1 -1
  125. package/dist/src/rlc-common/metadata/buildRollupConfig.js +1 -2
  126. package/dist/src/rlc-common/metadata/buildRollupConfig.js.map +1 -1
  127. package/dist/src/rlc-common/metadata/buildSampleEnvFile.js +3 -4
  128. package/dist/src/rlc-common/metadata/buildSampleEnvFile.js.map +1 -1
  129. package/dist/src/rlc-common/metadata/buildTestConfig.js +3 -4
  130. package/dist/src/rlc-common/metadata/buildTestConfig.js.map +1 -1
  131. package/dist/src/rlc-common/metadata/buildTsConfig.js +6 -8
  132. package/dist/src/rlc-common/metadata/buildTsConfig.js.map +1 -1
  133. package/dist/src/rlc-common/metadata/buildVitestConfig.js +2 -3
  134. package/dist/src/rlc-common/metadata/buildVitestConfig.js.map +1 -1
  135. package/dist/src/rlc-common/metadata/buildWarpConfig.js +2 -3
  136. package/dist/src/rlc-common/metadata/buildWarpConfig.js.map +1 -1
  137. package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.js +1 -1
  138. package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.js.map +1 -1
  139. package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.js +2 -3
  140. package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.js.map +1 -1
  141. package/dist/src/rlc-common/metadata/packageJson/packageCommon.js +2 -2
  142. package/dist/src/rlc-common/metadata/packageJson/packageCommon.js.map +1 -1
  143. package/dist/src/rlc-common/metadata/utils.js +1 -2
  144. package/dist/src/rlc-common/metadata/utils.js.map +1 -1
  145. package/dist/src/rlc-common/test/buildRecordedClient.js +2 -3
  146. package/dist/src/rlc-common/test/buildRecordedClient.js.map +1 -1
  147. package/dist/src/rlc-common/test/buildSampleTest.js +2 -3
  148. package/dist/src/rlc-common/test/buildSampleTest.js.map +1 -1
  149. package/dist/src/rlc-common/test/buildSnippets.js +4 -5
  150. package/dist/src/rlc-common/test/buildSnippets.js.map +1 -1
  151. package/dist/src/rlc-common/transformSampleGroups.js +23 -23
  152. package/dist/src/rlc-common/transformSampleGroups.js.map +1 -1
  153. package/dist/src/transform/transform.js +20 -18
  154. package/dist/src/transform/transform.js.map +1 -1
  155. package/dist/src/transform/transformApiVersionInfo.js +7 -7
  156. package/dist/src/transform/transformApiVersionInfo.js.map +1 -1
  157. package/dist/src/transform/transformHelperFunctionDetails.js +2 -3
  158. package/dist/src/transform/transformHelperFunctionDetails.js.map +1 -1
  159. package/dist/src/transform/transformParameters.js +15 -22
  160. package/dist/src/transform/transformParameters.js.map +1 -1
  161. package/dist/src/transform/transformPaths.js +9 -12
  162. package/dist/src/transform/transformPaths.js.map +1 -1
  163. package/dist/src/transform/transformResponses.js +10 -14
  164. package/dist/src/transform/transformResponses.js.map +1 -1
  165. package/dist/src/transform/transformSchemas.js +17 -22
  166. package/dist/src/transform/transformSchemas.js.map +1 -1
  167. package/dist/src/transform/transfromRLCOptions.js +23 -22
  168. package/dist/src/transform/transfromRLCOptions.js.map +1 -1
  169. package/dist/src/utils/clientUtils.js +6 -11
  170. package/dist/src/utils/clientUtils.js.map +1 -1
  171. package/dist/src/utils/credentialUtils.js +1 -2
  172. package/dist/src/utils/credentialUtils.js.map +1 -1
  173. package/dist/src/utils/crossLanguageDef.js +6 -6
  174. package/dist/src/utils/crossLanguageDef.js.map +1 -1
  175. package/dist/src/utils/emitUtil.js +1 -1
  176. package/dist/src/utils/emitUtil.js.map +1 -1
  177. package/dist/src/utils/fileSystemUtils.d.ts +2 -0
  178. package/dist/src/utils/fileSystemUtils.d.ts.map +1 -1
  179. package/dist/src/utils/fileSystemUtils.js +24 -5
  180. package/dist/src/utils/fileSystemUtils.js.map +1 -1
  181. package/dist/src/utils/importHelper.js +1 -2
  182. package/dist/src/utils/importHelper.js.map +1 -1
  183. package/dist/src/utils/modelUtils.js +78 -104
  184. package/dist/src/utils/modelUtils.js.map +1 -1
  185. package/dist/src/utils/namespaceUtils.js +4 -5
  186. package/dist/src/utils/namespaceUtils.js.map +1 -1
  187. package/dist/src/utils/operationUtil.js +38 -46
  188. package/dist/src/utils/operationUtil.js.map +1 -1
  189. package/dist/src/utils/parameterUtils.js +7 -11
  190. package/dist/src/utils/parameterUtils.js.map +1 -1
  191. package/dist/tsconfig.tsbuildinfo +1 -1
  192. package/package.json +38 -41
  193. package/src/index.ts +11 -10
  194. package/src/modular/buildRootIndex.ts +0 -1
  195. package/src/modular/emitSamples.ts +1 -3
  196. package/src/modular/helpers/exampleValueHelpers.ts +2 -6
  197. package/src/modular/serialization/serializeUtils.ts +0 -1
  198. package/src/rlc-common/buildClientDefinitions.ts +1 -0
  199. package/src/utils/fileSystemUtils.ts +29 -5
  200. package/static/static-helpers/pollingHelpers.ts +3 -3
  201. package/static/static-helpers/serialization/get-binary-response-browser.mts +3 -1
  202. package/static/static-helpers/serialization/get-binary-stream-response-browser.mts +1 -3
  203. package/static/static-helpers/serialization/xml-helpers.ts +1 -1
  204. package/static/static-helpers/simplePollerHelpers.ts +1 -1
@@ -78,7 +78,6 @@ export function getSendPrivateFunction(dpgContext, method, clientType, client) {
78
78
  };
79
79
  }
80
80
  export function getDeserializePrivateFunction(context, method) {
81
- var _a, _b, _c, _d, _e, _f, _g, _h;
82
81
  const operation = method[1];
83
82
  const { name } = getOperationName(operation);
84
83
  const dependencies = useDependencies();
@@ -108,11 +107,11 @@ export function getDeserializePrivateFunction(context, method) {
108
107
  returnType = buildLroReturnType(context, operation);
109
108
  }
110
109
  }
111
- else if (isPagingOnly && (restResponse === null || restResponse === void 0 ? void 0 : restResponse.type)) {
110
+ else if (isPagingOnly && restResponse?.type) {
112
111
  // For paging operations, use the full response model (e.g., _OperationListResult)
113
112
  // instead of just the array element type
114
113
  returnType = {
115
- name: (_a = restResponse.name) !== null && _a !== void 0 ? _a : "",
114
+ name: restResponse.name ?? "",
116
115
  type: getTypeExpression(context, restResponse.type)
117
116
  };
118
117
  }
@@ -128,7 +127,7 @@ export function getDeserializePrivateFunction(context, method) {
128
127
  // the return type must include undefined to reflect that possibility.
129
128
  const baseType = getTypeExpression(context, response.type);
130
129
  returnType = {
131
- name: (_b = response.name) !== null && _b !== void 0 ? _b : "",
130
+ name: response.name ?? "",
132
131
  type: response.optional ? `${baseType} | undefined` : baseType
133
132
  };
134
133
  }
@@ -160,12 +159,12 @@ export function getDeserializePrivateFunction(context, method) {
160
159
  statements.push(`const expectedStatuses = ${getExpectedStatuses(operation)};`);
161
160
  statements.push(`if(!expectedStatuses.includes(result.status)){`, `${getExceptionThrowStatement(context, operation)}`, "}");
162
161
  const deserializedType = isLroOnly || isLroAndPaging
163
- ? (_d = (_c = operation === null || operation === void 0 ? void 0 : operation.lroMetadata) === null || _c === void 0 ? void 0 : _c.finalResponse) === null || _d === void 0 ? void 0 : _d.result
164
- : isPagingOnly && (restResponse === null || restResponse === void 0 ? void 0 : restResponse.type)
162
+ ? operation?.lroMetadata?.finalResponse?.result
163
+ : isPagingOnly && restResponse?.type
165
164
  ? restResponse.type
166
165
  : response.type;
167
166
  const lroSubSegments = isLroOnly
168
- ? (_f = (_e = operation === null || operation === void 0 ? void 0 : operation.lroMetadata) === null || _e === void 0 ? void 0 : _e.finalResponse) === null || _f === void 0 ? void 0 : _f.resultSegments
167
+ ? operation?.lroMetadata?.finalResponse?.resultSegments
169
168
  : undefined;
170
169
  let lroSubPath;
171
170
  if (lroSubSegments && lroSubSegments.length > 0) {
@@ -189,7 +188,7 @@ export function getDeserializePrivateFunction(context, method) {
189
188
  // This only applies to non-LRO, non-paging operations where the deserialized type
190
189
  // comes from response.type (not from LRO metadata or paging).
191
190
  const needsBodyGuard = response.optional && !isLroOnly && !isLroAndPaging && !isPagingOnly;
192
- const contentTypes = (_h = (_g = operation.operation.responses[0]) === null || _g === void 0 ? void 0 : _g.contentTypes) !== null && _h !== void 0 ? _h : [];
191
+ const contentTypes = operation.operation.responses[0]?.contentTypes ?? [];
193
192
  const isXml = isXmlPayload(contentTypes);
194
193
  const isDualFormat = hasDualFormatSupport(contentTypes);
195
194
  const isMultipart = isMultipartPayload(contentTypes);
@@ -337,10 +336,9 @@ export function getDeserializePrivateFunction(context, method) {
337
336
  * or enable-storage-compat is enabled.
338
337
  */
339
338
  export function getDeserializeHeadersPrivateFunction(context, operation) {
340
- var _a, _b;
341
339
  const responseHeaders = getResponseHeaders(operation.operation.responses);
342
- const isResponseHeadersEnabled = ((_a = context.rlcOptions) === null || _a === void 0 ? void 0 : _a.includeHeadersInResponse) === true;
343
- const isStorageCompatEnabled = ((_b = context.rlcOptions) === null || _b === void 0 ? void 0 : _b.enableStorageCompat) === true;
340
+ const isResponseHeadersEnabled = context.rlcOptions?.includeHeadersInResponse === true;
341
+ const isStorageCompatEnabled = context.rlcOptions?.enableStorageCompat === true;
344
342
  // Only generate if headers exist and a relevant feature is enabled
345
343
  if (responseHeaders.length === 0 ||
346
344
  (!isResponseHeadersEnabled && !isStorageCompatEnabled)) {
@@ -371,7 +369,6 @@ export function getDeserializeHeadersPrivateFunction(context, operation) {
371
369
  };
372
370
  }
373
371
  function getExceptionDetails(context, operation) {
374
- var _a;
375
372
  const customized = [];
376
373
  let defaultDeserializer;
377
374
  let defaultXmlDeserializer;
@@ -391,7 +388,7 @@ function getExceptionDetails(context, operation) {
391
388
  }
392
389
  // Check if the exception type has XML serialization support
393
390
  // Use exception contentTypes when available, otherwise check the type itself
394
- const exceptionContentTypes = (_a = exception.contentTypes) !== null && _a !== void 0 ? _a : [];
391
+ const exceptionContentTypes = exception.contentTypes ?? [];
395
392
  const exceptionIsXml = isXmlPayload(exceptionContentTypes);
396
393
  const exceptionIsDualFormat = hasDualFormatSupport(exceptionContentTypes);
397
394
  const typeHasXml = exception.type.kind === "model" && hasXmlSerialization(exception.type);
@@ -443,13 +440,12 @@ function getExceptionDetails(context, operation) {
443
440
  * Collects and deduplicates all response headers from operation exceptions.
444
441
  */
445
442
  function getExceptionResponseHeaders(exceptions) {
446
- var _a, _b;
447
443
  const headerMap = new Map();
448
- for (const exception of exceptions !== null && exceptions !== void 0 ? exceptions : []) {
449
- for (const header of (_a = exception.headers) !== null && _a !== void 0 ? _a : []) {
444
+ for (const exception of exceptions ?? []) {
445
+ for (const header of exception.headers ?? []) {
450
446
  if (shouldSkipHeaderSerialization(header))
451
447
  continue;
452
- const key = (_b = header.serializedName) !== null && _b !== void 0 ? _b : header.name;
448
+ const key = header.serializedName ?? header.name;
453
449
  if (!headerMap.has(key)) {
454
450
  headerMap.set(key, header);
455
451
  }
@@ -462,8 +458,7 @@ function getExceptionResponseHeaders(exceptions) {
462
458
  * Only generated when exception headers are present and include-headers-in-response is enabled.
463
459
  */
464
460
  export function getDeserializeExceptionHeadersPrivateFunction(context, operation) {
465
- var _a;
466
- const isResponseHeadersEnabled = ((_a = context.rlcOptions) === null || _a === void 0 ? void 0 : _a.includeHeadersInResponse) === true;
461
+ const isResponseHeadersEnabled = context.rlcOptions?.includeHeadersInResponse === true;
467
462
  if (!isResponseHeadersEnabled) {
468
463
  return undefined;
469
464
  }
@@ -505,11 +500,10 @@ function getExceptionDeserializeExpr(exception) {
505
500
  return `isXml ? ${exception.xmlDeserializer}(result.body) : ${exception.deserializer}(result.body)`;
506
501
  }
507
502
  function getExceptionThrowStatement(context, operation) {
508
- var _a;
509
503
  const statements = [];
510
504
  const createRestErrorReference = resolveReference(useDependencies().createRestError);
511
505
  const { customized, defaultDeserializer, defaultXmlDeserializer, defaultIsXmlOnly } = getExceptionDetails(context, operation);
512
- const isResponseHeadersEnabled = ((_a = context.rlcOptions) === null || _a === void 0 ? void 0 : _a.includeHeadersInResponse) === true;
506
+ const isResponseHeadersEnabled = context.rlcOptions?.includeHeadersInResponse === true;
513
507
  // Check if exception headers function exists and build the call
514
508
  const exceptionHeaders = getExceptionResponseHeaders(operation.operation.exceptions);
515
509
  const hasExceptionHeaders = isResponseHeadersEnabled && exceptionHeaders.length > 0;
@@ -605,7 +599,7 @@ function getExceptionThrowStatement(context, operation) {
605
599
  function buildClientOptionHeadersCall(exceptions) {
606
600
  const seenProperties = new Set();
607
601
  const assignments = [];
608
- for (const exception of exceptions !== null && exceptions !== void 0 ? exceptions : []) {
602
+ for (const exception of exceptions ?? []) {
609
603
  if (!exception.type || exception.type.kind !== "model") {
610
604
  continue;
611
605
  }
@@ -628,7 +622,7 @@ function buildClientOptionHeadersCall(exceptions) {
628
622
  * based on @clientOption("restErrorCodeHeader", ...) on exception model types.
629
623
  */
630
624
  function buildRestErrorCodeAssignment(exceptions) {
631
- for (const exception of exceptions !== null && exceptions !== void 0 ? exceptions : []) {
625
+ for (const exception of exceptions ?? []) {
632
626
  if (!exception.type || exception.type.kind !== "model") {
633
627
  continue;
634
628
  }
@@ -641,29 +635,24 @@ if (restErrorCodeValue !== undefined) { error.code = restErrorCodeValue; }`;
641
635
  return undefined;
642
636
  }
643
637
  function getOptionalParamsName(parameters) {
644
- var _a, _b;
645
- return ((_b = (_a = parameters.filter((p) => { var _a; return (_a = p.type) === null || _a === void 0 ? void 0 : _a.toString().endsWith("operationOptions__"); })[0]) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : "options");
638
+ return (parameters.filter((p) => p.type?.toString().endsWith("operationOptions__"))[0]?.name ?? "options");
646
639
  }
647
640
  function getOperationSignatureParameters(context, method, clientType) {
648
641
  const operation = method[1];
649
642
  const optionsType = resolveReference(refkey(method[1], "operationOptions"));
650
643
  const parameters = new Map();
651
644
  operation.parameters
652
- .filter((p) => {
653
- var _a;
654
- return p.onClient === false &&
655
- p.type.kind !== "constant" &&
656
- ((_a = operation.operation.parameters.filter((param) => {
657
- var _a, _b;
658
- return (param.methodParameterSegments.length === 1 &&
659
- ((_a = param.methodParameterSegments[0]) === null || _a === void 0 ? void 0 : _a.length) === 1 &&
660
- ((_b = param.methodParameterSegments[0]) === null || _b === void 0 ? void 0 : _b[0]) === p);
661
- })[0]) === null || _a === void 0 ? void 0 : _a.kind) !== "cookie" &&
662
- !p.optional &&
663
- !(p.isGeneratedName &&
664
- (p.name === "contentType" || p.name === "accept")) && // skip tcgc generated contentType and accept header parameter
665
- getClientOptions(p, "headerCollectionPrefix") === undefined;
666
- } // skip headers with collection prefix
645
+ .filter((p) => p.onClient === false &&
646
+ p.type.kind !== "constant" &&
647
+ operation.operation.parameters.filter((param) => {
648
+ return (param.methodParameterSegments.length === 1 &&
649
+ param.methodParameterSegments[0]?.length === 1 &&
650
+ param.methodParameterSegments[0]?.[0] === p);
651
+ })[0]?.kind !== "cookie" &&
652
+ !p.optional &&
653
+ !(p.isGeneratedName &&
654
+ (p.name === "contentType" || p.name === "accept")) && // skip tcgc generated contentType and accept header parameter
655
+ getClientOptions(p, "headerCollectionPrefix") === undefined // skip headers with collection prefix
667
656
  )
668
657
  .map((p) => {
669
658
  return {
@@ -689,7 +678,6 @@ function getOperationSignatureParameters(context, method, clientType) {
689
678
  * This operation builds and returns the function declaration for an operation.
690
679
  */
691
680
  export function getOperationFunction(context, method, clientType) {
692
- var _a, _b, _c, _d, _e;
693
681
  const operation = method[1];
694
682
  // Extract required parameters
695
683
  const parameters = getOperationSignatureParameters(context, method, clientType);
@@ -710,8 +698,8 @@ export function getOperationFunction(context, method, clientType) {
710
698
  const response = operation.response;
711
699
  const responseHeaders = getResponseHeaders(operation.operation.responses);
712
700
  const hasHeaderOnlyResponse = !response.type && responseHeaders.length > 0;
713
- const isResponseHeadersEnabled = ((_a = context.rlcOptions) === null || _a === void 0 ? void 0 : _a.includeHeadersInResponse) === true;
714
- const isStorageCompatEnabled = ((_b = context.rlcOptions) === null || _b === void 0 ? void 0 : _b.enableStorageCompat) === true;
701
+ const isResponseHeadersEnabled = context.rlcOptions?.includeHeadersInResponse === true;
702
+ const isStorageCompatEnabled = context.rlcOptions?.enableStorageCompat === true;
715
703
  // Track the raw body type separately for storage-compat (before header merging)
716
704
  const hasResponseBody = !!response.type;
717
705
  let bodyType = "void";
@@ -738,7 +726,7 @@ export function getOperationFunction(context, method, clientType) {
738
726
  // Build a composite type that includes both model and additional header properties
739
727
  const baseCompositeType = buildCompositeResponseType(context, type, responseHeaders);
740
728
  returnType = {
741
- name: (_c = type.name) !== null && _c !== void 0 ? _c : "",
729
+ name: type.name ?? "",
742
730
  type: response.optional
743
731
  ? `${baseCompositeType} | undefined`
744
732
  : baseCompositeType
@@ -747,7 +735,7 @@ export function getOperationFunction(context, method, clientType) {
747
735
  else {
748
736
  const baseType = getTypeExpression(context, type);
749
737
  returnType = {
750
- name: (_d = type.name) !== null && _d !== void 0 ? _d : "",
738
+ name: type.name ?? "",
751
739
  type: response.optional ? `${baseType} | undefined` : baseType
752
740
  };
753
741
  }
@@ -824,7 +812,7 @@ export function getOperationFunction(context, method, clientType) {
824
812
  // doing a UTF-8 decode on the raw bytes.
825
813
  // For binary wrap, use getBinaryStreamResponse which preserves blobBody/readableStreamBody properties.
826
814
  // For non-wrapped binary, use getBinaryResponse which buffers the body into Uint8Array.
827
- if (((_e = response === null || response === void 0 ? void 0 : response.type) === null || _e === void 0 ? void 0 : _e.kind) === "bytes" && response.type.encode === "bytes") {
815
+ if (response?.type?.kind === "bytes" && response.type.encode === "bytes") {
828
816
  const streamableMethodVarName = generateLocallyUniqueName("streamableMethod", paramNames);
829
817
  statements.push(`const ${streamableMethodVarName} = _${name}Send(${sendParameterList});`);
830
818
  const binaryHelper = wrapReturn && wrapReturnIsBinary
@@ -921,9 +909,9 @@ function getLroOnlyOperationFunction(context, method, clientType, optionalParamN
921
909
  "original-uri",
922
910
  "operation-location"
923
911
  ];
924
- const resourceLocationConfig = (lroMetadata === null || lroMetadata === void 0 ? void 0 : lroMetadata.finalStateVia) &&
925
- allowedFinalLocation.includes(lroMetadata === null || lroMetadata === void 0 ? void 0 : lroMetadata.finalStateVia)
926
- ? `resourceLocationConfig: "${lroMetadata === null || lroMetadata === void 0 ? void 0 : lroMetadata.finalStateVia}",`
912
+ const resourceLocationConfig = lroMetadata?.finalStateVia &&
913
+ allowedFinalLocation.includes(lroMetadata?.finalStateVia)
914
+ ? `resourceLocationConfig: "${lroMetadata?.finalStateVia}",`
927
915
  : "";
928
916
  const apiVersion = getApiVersionExpression(context, operation);
929
917
  const statements = [];
@@ -945,7 +933,6 @@ function getLroOnlyOperationFunction(context, method, clientType, optionalParamN
945
933
  };
946
934
  }
947
935
  function getLroAndPagingOperationFunction(context, method, clientType, optionalParamName = "options") {
948
- var _a;
949
936
  const operation = method[1];
950
937
  const parameters = getOperationSignatureParameters(context, method, clientType);
951
938
  const { name, fixme = [] } = getOperationName(operation, context);
@@ -969,7 +956,7 @@ function getLroAndPagingOperationFunction(context, method, clientType, optionalP
969
956
  "original-uri",
970
957
  "operation-location"
971
958
  ];
972
- const resourceLocationConfig = ((_a = operation.lroMetadata) === null || _a === void 0 ? void 0 : _a.finalStateVia) &&
959
+ const resourceLocationConfig = operation.lroMetadata?.finalStateVia &&
973
960
  allowedLocations.includes(operation.lroMetadata.finalStateVia)
974
961
  ? `resourceLocationConfig: "${operation.lroMetadata.finalStateVia}",`
975
962
  : "";
@@ -1033,17 +1020,15 @@ function buildLroReturnType(context, operation) {
1033
1020
  return { name: "", type: "void" };
1034
1021
  }
1035
1022
  function buildLroPagingReturnType(context, operation) {
1036
- var _a, _b;
1037
- if (((_a = operation.response.type) === null || _a === void 0 ? void 0 : _a.kind) === "array") {
1023
+ if (operation.response.type?.kind === "array") {
1038
1024
  return {
1039
- name: (_b = operation.response.type.valueType.name) !== null && _b !== void 0 ? _b : "",
1025
+ name: operation.response.type.valueType.name ?? "",
1040
1026
  type: getTypeExpression(context, operation.response.type.valueType)
1041
1027
  };
1042
1028
  }
1043
1029
  return { name: "", type: "void" };
1044
1030
  }
1045
1031
  function getPagingOnlyOperationFunction(context, method, clientType) {
1046
- var _a;
1047
1032
  const operation = method[1];
1048
1033
  // Extract required parameters
1049
1034
  const parameters = getOperationSignatureParameters(context, method, clientType);
@@ -1053,7 +1038,7 @@ function getPagingOnlyOperationFunction(context, method, clientType) {
1053
1038
  if (response.type && response.type.kind === "array") {
1054
1039
  const type = response.type;
1055
1040
  returnType = {
1056
- name: (_a = type.valueType.name) !== null && _a !== void 0 ? _a : "",
1041
+ name: type.valueType.name ?? "",
1057
1042
  type: getTypeExpression(context, type.valueType)
1058
1043
  };
1059
1044
  }
@@ -1077,13 +1062,17 @@ function getPagingOnlyOperationFunction(context, method, clientType) {
1077
1062
  const options = [];
1078
1063
  // TODO: follow up on https://github.com/Azure/typespec-azure/issues/2103
1079
1064
  const nextLinkSegments = operation.pagingMetadata.nextLinkSegments;
1080
- const nextLinkName = nextLinkSegments === null || nextLinkSegments === void 0 ? void 0 : nextLinkSegments.map((property) => {
1065
+ const nextLinkName = nextLinkSegments
1066
+ ?.map((property) => {
1081
1067
  return property.name;
1082
- }).join(".");
1068
+ })
1069
+ .join(".");
1083
1070
  const itemSegments = operation.response.resultSegments;
1084
- const itemName = itemSegments === null || itemSegments === void 0 ? void 0 : itemSegments.map((property) => {
1071
+ const itemName = itemSegments
1072
+ ?.map((property) => {
1085
1073
  return property.name;
1086
- }).join(".");
1074
+ })
1075
+ .join(".");
1087
1076
  // Check for nextLinkVerb from TCGC pagingMetadata (supports @Legacy.nextLinkVerb decorator)
1088
1077
  const nextLinkMethod = operation.pagingMetadata.nextLinkVerb;
1089
1078
  const apiVersion = getApiVersionExpression(context, operation);
@@ -1276,9 +1265,8 @@ function buildBodyParameter(context, bodyParameter, optionalParamName = "options
1276
1265
  return `\nbody: ${serializedBody.startsWith(nullOrUndefinedPrefix) ? "" : nullOrUndefinedPrefix}${serializedBody},`;
1277
1266
  }
1278
1267
  function getEncodingFormat(type) {
1279
- var _a;
1280
1268
  const supportedFormats = ["base64url", "base64", "byte"];
1281
- if (!supportedFormats.includes((_a = type.format) !== null && _a !== void 0 ? _a : "")) {
1269
+ if (!supportedFormats.includes(type.format ?? "")) {
1282
1270
  return "base64";
1283
1271
  }
1284
1272
  return type.format;
@@ -1287,7 +1275,6 @@ function getEncodingFormat(type) {
1287
1275
  * This function helps with renames, translating client names to rest api names
1288
1276
  */
1289
1277
  export function getParameterMap(context, param, paramAccessor) {
1290
- var _a;
1291
1278
  // Use lowercase for header names since HTTP headers are case-insensitive
1292
1279
  const serializedName = param.kind === "header"
1293
1280
  ? getHeaderSerializedName(param)
@@ -1298,7 +1285,7 @@ export function getParameterMap(context, param, paramAccessor) {
1298
1285
  // Special case for api-version parameters with default values
1299
1286
  if (param.isApiVersionParam && param.clientDefaultValue) {
1300
1287
  // For multi-service, use only the default value (don't reference context.apiVersion)
1301
- if ((_a = context.rlcOptions) === null || _a === void 0 ? void 0 : _a.isMultiService) {
1288
+ if (context.rlcOptions?.isMultiService) {
1302
1289
  return `"${serializedName}": "${param.clientDefaultValue}"`;
1303
1290
  }
1304
1291
  return `"${serializedName}": ${param.onClient ? "context." : ""}${param.name} ?? "${param.clientDefaultValue}"`;
@@ -1355,15 +1342,14 @@ function getContentTypeValue(param, optionalParamName = "options") {
1355
1342
  * For client-level parameters (onClient), preserve the HTTP parameter's own flag.
1356
1343
  */
1357
1344
  function getEffectiveOptional(param) {
1358
- var _a, _b;
1359
1345
  // For client-level parameters, the HTTP parameter's optional flag is authoritative
1360
1346
  if (param.onClient) {
1361
1347
  return Boolean(param.optional);
1362
1348
  }
1363
1349
  // For method-level parameters with a direct mapping to a single method param,
1364
1350
  // use the method parameter's optional flag (correctly reflects @@override changes)
1365
- if (((_a = param.methodParameterSegments) === null || _a === void 0 ? void 0 : _a.length) === 1 &&
1366
- ((_b = param.methodParameterSegments[0]) === null || _b === void 0 ? void 0 : _b.length) === 1) {
1351
+ if (param.methodParameterSegments?.length === 1 &&
1352
+ param.methodParameterSegments[0]?.length === 1) {
1367
1353
  const methodParam = param.methodParameterSegments[0][0];
1368
1354
  if (methodParam) {
1369
1355
  return Boolean(methodParam.optional);
@@ -1428,14 +1414,13 @@ function getDefaultValue(param) {
1428
1414
  * Extracts the path parameters
1429
1415
  */
1430
1416
  function getPathParameters(operation, optionalParamName = "options") {
1431
- var _a;
1432
1417
  if (!operation.operation.parameters) {
1433
1418
  return [];
1434
1419
  }
1435
1420
  const pathParams = [];
1436
1421
  for (const param of operation.operation.parameters) {
1437
1422
  if (param.kind === "path") {
1438
- const methodParam = (_a = param.methodParameterSegments[0]) === null || _a === void 0 ? void 0 : _a[0];
1423
+ const methodParam = param.methodParameterSegments[0]?.[0];
1439
1424
  if (methodParam) {
1440
1425
  pathParams.push(`"${param.serializedName}": ${getPathParamExpr(param, getDefaultValue(param), optionalParamName)}`);
1441
1426
  }
@@ -1654,10 +1639,9 @@ export function getSerializationExpression(context, property, propertyPath, enab
1654
1639
  }
1655
1640
  }
1656
1641
  export function getRequestModelProperties(context, modelPropertyType, propertyPath = "body", overrides, enableFlatten = true) {
1657
- var _a;
1658
1642
  const props = [];
1659
1643
  const allParents = getAllAncestors(modelPropertyType);
1660
- const properties = (_a = getAllProperties(context, modelPropertyType, allParents)) !== null && _a !== void 0 ? _a : [];
1644
+ const properties = getAllProperties(context, modelPropertyType, allParents) ?? [];
1661
1645
  if (properties.length <= 0) {
1662
1646
  return [];
1663
1647
  }
@@ -1685,10 +1669,9 @@ export function getRequestModelMapping(context, modelPropertyType, propertyPath
1685
1669
  return getRequestModelProperties(context, modelPropertyType, propertyPath, overrides, enableFlatten).map(([name, value]) => `"${name}": ${value}`);
1686
1670
  }
1687
1671
  export function getPropertySerializedName(property) {
1688
- var _a, _b;
1689
- return ((_b = (property.kind === "property"
1690
- ? (_a = property.serializationOptions.json) === null || _a === void 0 ? void 0 : _a.name
1691
- : property.serializedName)) !== null && _b !== void 0 ? _b : property.name);
1672
+ return ((property.kind === "property"
1673
+ ? property.serializationOptions.json?.name
1674
+ : property.serializedName) ?? property.name);
1692
1675
  }
1693
1676
  /**
1694
1677
  * Get the serialized name for a header parameter, normalized to lowercase.
@@ -1750,7 +1733,6 @@ export function getResponseMapping(context, type, propertyPath = "result.body",
1750
1733
  * Converts JavaScript values to their serialized wire format for HTTP requests.
1751
1734
  */
1752
1735
  export function serializeRequestValue(context, type, clientValue, required, format, serializedName, isTopLevel = false) {
1753
- var _a, _b, _c, _d, _e;
1754
1736
  const getSdkType = useSdkTypes();
1755
1737
  const dependencies = useDependencies();
1756
1738
  const nullOrUndefinedPrefix = isTypeNullable(type) || getOptionalForType(type) || !required
@@ -1761,7 +1743,7 @@ export function serializeRequestValue(context, type, clientValue, required, form
1761
1743
  // plainDate always uses ISO8601 format (YYYY-MM-DD)
1762
1744
  return `${nullOrUndefinedPrefix}${clientValue}.toISOString().split('T')[0]`;
1763
1745
  case "utcDateTime":
1764
- switch ((_a = type.encode) !== null && _a !== void 0 ? _a : format) {
1746
+ switch (type.encode ?? format) {
1765
1747
  case "rfc7231":
1766
1748
  return `${nullOrUndefinedPrefix}${clientValue}.toUTCString()`;
1767
1749
  case "unixTimestamp":
@@ -1791,7 +1773,7 @@ export function serializeRequestValue(context, type, clientValue, required, form
1791
1773
  if (format) {
1792
1774
  const formatHelper = getCollectionFormatHelper(format);
1793
1775
  if (formatHelper) {
1794
- if ((format === null || format === void 0 ? void 0 : format.toLowerCase()) === KnownCollectionFormat.Multi) {
1776
+ if (format?.toLowerCase() === KnownCollectionFormat.Multi) {
1795
1777
  return `${nullOrUndefinedPrefix}${formatHelper}(${serializedValue}, "${serializedName}")`;
1796
1778
  }
1797
1779
  return `${nullOrUndefinedPrefix}${formatHelper}(${serializedValue})`;
@@ -1807,8 +1789,8 @@ export function serializeRequestValue(context, type, clientValue, required, form
1807
1789
  if (format !== "binary" && format !== "bytes") {
1808
1790
  const uint8ArrayToStringReference = resolveReference(dependencies.uint8ArrayToString);
1809
1791
  return required
1810
- ? `${getNullableCheck(clientValue, type)} ${uint8ArrayToStringReference}(${clientValue}, "${(_b = getEncodingFormat({ format })) !== null && _b !== void 0 ? _b : "base64"}")`
1811
- : `${nullOrUndefinedPrefix} ${uint8ArrayToStringReference}(${clientValue}, "${(_c = getEncodingFormat({ format })) !== null && _c !== void 0 ? _c : "base64"}")`;
1792
+ ? `${getNullableCheck(clientValue, type)} ${uint8ArrayToStringReference}(${clientValue}, "${getEncodingFormat({ format }) ?? "base64"}")`
1793
+ : `${nullOrUndefinedPrefix} ${uint8ArrayToStringReference}(${clientValue}, "${getEncodingFormat({ format }) ?? "base64"}")`;
1812
1794
  }
1813
1795
  return clientValue;
1814
1796
  case "union":
@@ -1817,7 +1799,7 @@ export function serializeRequestValue(context, type, clientValue, required, form
1817
1799
  }
1818
1800
  else if (isSpecialHandledUnion({
1819
1801
  ...type,
1820
- isNonExhaustive: (_e = (_d = context.rlcOptions) === null || _d === void 0 ? void 0 : _d.experimentalExtensibleEnums) !== null && _e !== void 0 ? _e : false
1802
+ isNonExhaustive: context.rlcOptions?.experimentalExtensibleEnums ?? false
1821
1803
  })) {
1822
1804
  const sdkType = getSdkType(type.__raw);
1823
1805
  const serializerRefkey = refkey(sdkType, "serializer");
@@ -1993,7 +1975,7 @@ export function deserializeResponseValue(context, type, restValue, required, for
1993
1975
  case "bytes":
1994
1976
  if (format !== "binary" && format !== "bytes") {
1995
1977
  return `${nullOrUndefinedPrefix}typeof ${restValue} === 'string'
1996
- ? ${stringToUint8ArrayReference}(${restValue}, "${format !== null && format !== void 0 ? format : "base64"}")
1978
+ ? ${stringToUint8ArrayReference}(${restValue}, "${format ?? "base64"}")
1997
1979
  : ${restValue}`;
1998
1980
  }
1999
1981
  return restValue;
@@ -2040,7 +2022,7 @@ export function getAllProperties(context, type, parents) {
2040
2022
  if (!type) {
2041
2023
  return [];
2042
2024
  }
2043
- parents === null || parents === void 0 ? void 0 : parents.forEach((p) => {
2025
+ parents?.forEach((p) => {
2044
2026
  getAllProperties(context, p).forEach((prop) => {
2045
2027
  propertiesMap.set(prop.name, prop);
2046
2028
  });
@@ -2165,13 +2147,12 @@ export function getExpectedStatuses(operation) {
2165
2147
  * @returns The apiVersion expression string, or undefined if no apiVersion query param exists
2166
2148
  */
2167
2149
  function getApiVersionExpression(dpgContext, operation) {
2168
- var _a;
2169
2150
  const queryApiVersionParam = operation.operation.parameters.find((p) => p.kind === "query" && p.isApiVersionParam);
2170
2151
  if (!queryApiVersionParam) {
2171
2152
  return undefined;
2172
2153
  }
2173
2154
  // For multi-service, use only the default value (don't reference context.apiVersion)
2174
- if ((_a = dpgContext.rlcOptions) === null || _a === void 0 ? void 0 : _a.isMultiService) {
2155
+ if (dpgContext.rlcOptions?.isMultiService) {
2175
2156
  return queryApiVersionParam.clientDefaultValue
2176
2157
  ? `"${queryApiVersionParam.clientDefaultValue}"`
2177
2158
  : undefined;
@@ -2188,13 +2169,12 @@ function getApiVersionExpression(dpgContext, operation) {
2188
2169
  * @returns Array of unique response headers
2189
2170
  */
2190
2171
  export function getResponseHeaders(responses) {
2191
- var _a, _b;
2192
2172
  const headerMap = new Map();
2193
- for (const response of responses !== null && responses !== void 0 ? responses : []) {
2194
- for (const header of (_a = response.headers) !== null && _a !== void 0 ? _a : []) {
2173
+ for (const response of responses ?? []) {
2174
+ for (const header of response.headers ?? []) {
2195
2175
  if (shouldSkipHeaderSerialization(header))
2196
2176
  continue;
2197
- const key = (_b = header.serializedName) !== null && _b !== void 0 ? _b : header.name;
2177
+ const key = header.serializedName ?? header.name;
2198
2178
  if (!headerMap.has(key)) {
2199
2179
  headerMap.set(key, header);
2200
2180
  }
@@ -2262,8 +2242,7 @@ function buildHeaderOnlyResponseType(context, headers) {
2262
2242
  */
2263
2243
  function buildHeaderOnlyResponseValue(context, headers) {
2264
2244
  const props = headers.map((header) => {
2265
- var _a;
2266
- const headerName = ((_a = header.serializedName) !== null && _a !== void 0 ? _a : header.name).toLowerCase();
2245
+ const headerName = (header.serializedName ?? header.name).toLowerCase();
2267
2246
  const key = normalizeModelPropertyName(context, header);
2268
2247
  const value = deserializeResponseHeadersValue(context, header.type, `result.headers[${JSON.stringify(headerName)}]`, !header.optional, getEncodeForType(header.type), 0);
2269
2248
  return `${key}: ${value}`;
@@ -2302,12 +2281,11 @@ export function getOperationResponseTypeName(method) {
2302
2281
  * - any / unknown (no treatAsRecord) → HLC PropertyKind.Primitive
2303
2282
  */
2304
2283
  function isWrappableType(context, type) {
2305
- var _a;
2306
2284
  if (type.kind === "array" && type.valueType.kind === "model")
2307
2285
  return false;
2308
2286
  if (type.kind === "dict" || type.kind === "model")
2309
2287
  return false;
2310
- if (type.kind === "unknown" && ((_a = context.rlcOptions) === null || _a === void 0 ? void 0 : _a.treatUnknownAsRecord))
2288
+ if (type.kind === "unknown" && context.rlcOptions?.treatUnknownAsRecord)
2311
2289
  return false;
2312
2290
  return true;
2313
2291
  }
@@ -2318,11 +2296,10 @@ function isHeadOperation(operation) {
2318
2296
  return operation.operation.verb.toLowerCase() === "head";
2319
2297
  }
2320
2298
  function isHeadAsBooleanOperation(operation) {
2321
- var _a;
2322
2299
  if (!isHeadOperation(operation))
2323
2300
  return false;
2324
2301
  // @responseAsBool: TCGC promotes response.type to SdkBuiltInType { kind: "boolean" }
2325
- if (((_a = operation.response.type) === null || _a === void 0 ? void 0 : _a.kind) === "boolean")
2302
+ if (operation.response.type?.kind === "boolean")
2326
2303
  return true;
2327
2304
  return false;
2328
2305
  }
@@ -2331,19 +2308,18 @@ function isHeadAsBooleanOperation(operation) {
2331
2308
  * Returns an object with `shouldWrap` (whether to wrap) and `isBinary` (whether it's a binary response).
2332
2309
  */
2333
2310
  export function checkWrapNonModelReturn(context, operation) {
2334
- var _a, _b, _c, _d, _e;
2335
2311
  const noWrap = { shouldWrap: false, isBinary: false };
2336
2312
  // LRO+paging and paging-only operations are not wrapped
2337
2313
  if (isLroAndPagingOperation(operation) || isPagingOnlyOperation(operation)) {
2338
2314
  return noWrap;
2339
2315
  }
2340
2316
  // Only if the feature flag is enabled
2341
- if (!((_a = context.rlcOptions) === null || _a === void 0 ? void 0 : _a.wrapNonModelReturn)) {
2317
+ if (!context.rlcOptions?.wrapNonModelReturn) {
2342
2318
  return noWrap;
2343
2319
  }
2344
2320
  // For LRO-only operations, check the final result type from LRO metadata
2345
2321
  if (isLroOnlyOperation(operation)) {
2346
- const lroResultType = (_c = (_b = operation.lroMetadata) === null || _b === void 0 ? void 0 : _b.finalResponse) === null || _c === void 0 ? void 0 : _c.result;
2322
+ const lroResultType = operation.lroMetadata?.finalResponse?.result;
2347
2323
  if (!lroResultType) {
2348
2324
  return noWrap; // void LRO - no wrap needed
2349
2325
  }
@@ -2360,7 +2336,7 @@ export function checkWrapNonModelReturn(context, operation) {
2360
2336
  }
2361
2337
  return noWrap; // void return type - no wrap needed
2362
2338
  }
2363
- const contentTypes = (_e = (_d = operation.operation.responses[0]) === null || _d === void 0 ? void 0 : _d.contentTypes) !== null && _e !== void 0 ? _e : [];
2339
+ const contentTypes = operation.operation.responses[0]?.contentTypes ?? [];
2364
2340
  // bytes with binary content type → binary wrap (isBinary=true)
2365
2341
  // HLC: bytes → binary payload → separate binary handling
2366
2342
  if (type.__raw &&