autorest.typescript icon indicating copy to clipboard operation
autorest.typescript copied to clipboard

isUnexpected not working if one model is a subset of another model

Open MaryGao opened this issue 9 months ago • 2 comments

See pr https://github.com/Azure/autorest.typescript/pull/2501/files Generated code: https://github.com/kazrael2119/autorest.typescript/blob/deviceregistry-modular/packages/typespec-test/test/DeviceRegistry.Management/generated/typespec-ts/src/rest/isUnexpected.ts#L82

In following OperationStatusGetDefaultResponse is a subset of OperationStatusGet200Response so the helper fail to type narrowing.

export function isUnexpected(
  response: OperationStatusGet200Response | OperationStatusGetDefaultResponse,
): response is OperationStatusGetDefaultResponse;

image

Finally causing the modular code failed to compile. image

MaryGao avatar May 08 '24 06:05 MaryGao