Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Tracked by #2320
MaryGao opened this issue May 8, 2024 · 2 comments · Fixed by #2654
Closed
Tracked by #2320

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

MaryGao opened this issue May 8, 2024 · 2 comments · Fixed by #2654
Assignees
Labels
HRLC P1 priority 1

Comments

@MaryGao
Copy link
Member

MaryGao commented May 8, 2024

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

@qiaozha
Copy link
Member

qiaozha commented May 8, 2024

need further discussion on the typespec best practice.

@qiaozha qiaozha added p0 priority 0 HRLC labels May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HRLC P1 priority 1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants