You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Close typespec one filed an issue in typespec-azure repo.
Offline discussed with @ArcturusZhang and we think anomymous model may not be a good practice and we should encourage to give a name for models especially for exposed public APIs.
Most of downstreaming language emitters may not have ability to handle inline expressions like typespec so they need to GUESS a name for anomymous models. This could introduce uncertainty if downstreaming name rule is different and for example the name rule introduced breakings between m4 and tcgc and one issue happened in common types is tracked here.
Even we could find a name rule and these names could be fragile and it would be changed with its context or code order if conflicting happened.
For example in TCGC we try to guess this name according to context, including parent model name + property name + model type. So the name could be changed once any of these factors changed. Also we may name some models during conflicting and any code order changes would impact the generated code.
model Ab {
c: {
foo: string;
};
}
// vs
model A {
b: {
c: {
foo: string;
};
};
}
Can we add a linter to discourage the anonymous model in typespec? Especially in azure could we avoid using anonymous model then?
Check that this issue is about the Azure libraries for typespec. For feature request in the typespec language or core libraries file it in the TypeSpec repo
Clear and concise description of the problem
Close typespec one filed an issue in typespec-azure repo.
Offline discussed with @ArcturusZhang and we think anomymous model may not be a good practice and we should encourage to give a name for models especially for exposed public APIs.
Most of downstreaming language emitters may not have ability to handle inline expressions like typespec so they need to GUESS a name for anomymous models. This could introduce uncertainty if downstreaming name rule is different and for example the name rule introduced breakings between m4 and tcgc and one issue happened in common types is tracked here.
Even we could find a name rule and these names could be fragile and it would be changed with its context or code order if conflicting happened.
For example in TCGC we try to guess this name according to context, including
parent model name + property name + model type
. So the name could be changed once any of these factors changed. Also we may name some models during conflicting and any code order changes would impact the generated code.Can we add a linter to discourage the anonymous model in typespec? Especially in azure could we avoid using anonymous model then?
Checklist
The text was updated successfully, but these errors were encountered: