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

support-non-exhaustive-enum #2584

Merged
merged 6 commits into from
Jun 19, 2024
Merged

Conversation

qiaozha
Copy link
Member

@qiaozha qiaozha commented Jun 14, 2024

fixes #2476
fixes #2420

Comment on lines +1204 to +1222
case "enum":
if (!type.isFixed && !type.isNonExhaustive) {
return `${restValue} as ${type.name}`;
}
return restValue;
case "model":
if (type.discriminator) {
const discriminatorProp = type.properties?.filter(
(p) => p.restApiName === type.discriminator
);
if (
discriminatorProp?.length === 1 &&
discriminatorProp[0]?.type.isFixed === false &&
discriminatorProp[0].type.isNonExhaustive === false
) {
return `${restValue} as ${type.name}`;
}
}
return restValue;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joheredi @dgetu this is a new logic related with the deserialization caused by we are not treating exhaustive enum the same in both RLC and Modular layer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! We'll use this as a guide when porting to the new serializers

@qiaozha qiaozha marked this pull request as ready for review June 17, 2024 02:06
@qiaozha qiaozha merged commit fb91d96 into Azure:main Jun 19, 2024
14 checks passed
@qiaozha qiaozha deleted the support-non-exhaustive-enum branch June 19, 2024 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Known* definitions mission in TS Generation [JS] Redesign Extensible Enum generation
2 participants