-
Notifications
You must be signed in to change notification settings - Fork 67
[TCGC] Warn when @alternateType with external type is applied to model property #3784
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
base: main
Are you sure you want to change the base?
Conversation
- Added diagnostic "external-type-on-model-property" in lib.ts - Added validation in $alternateType decorator to check if source is ModelProperty with external type - Added test case to verify warning is reported - External type on model properties is not supported and should warn users Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com>
Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com>
commit: |
|
@copilot Please also update the doc for this decorator and use |
- Added important note about external types not being applicable to model properties - Added example showing invalid usage (external type on model property) - Added example showing correct usage (external type on type definition) - Updated both decorators.tsp and generated docs in website Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com>
Updated the decorator documentation in both |
Plan: Check for external type on model property
$alternateTypedecorator to check when external type is used on ModelPropertySummary
This PR adds a warning when
@alternateTypedecorator with external type information is applied to model properties.Problem: According to the issue, using
@@alternateType(FieldWithExternalType.name, { identity: "crate::models::HandWrittenType" }, "rust")doesn't work and should warn the user.Solution: Added validation in the
$alternateTypedecorator that:ModelPropertyidentityproperty)external-type-on-model-propertyChanges:
src/lib.ts: Added new diagnostic message "external-type-on-model-property"src/decorators.ts: Added validation check in$alternateTypedecorator before processing external typestest/decorators/alternate-type.test.ts: Added test case to verify the warning is correctly reported.chronus/changes/: Added changelog entrylib/decorators.tsp: Updated decorator documentation with important note and invalid/valid exampleswebsite/.../decorators.md: Updated generated documentation in websiteTest: Added test case
should warn when external type is applied to model propertythat verifies:external-type-on-model-propertyDocumentation Updates:
Note: External types should be applied to the type definition itself (Scalar, Model, Enum, or Union) instead of model properties, as shown in the existing external type tests.
Code Review: ✅ No issues found
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.