Fix: `resolveUsage` shouldn't include model `extends` (#1485)
This commit is contained in:
Родитель
61646b27bd
Коммит
87c5d833de
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"packageName": "@cadl-lang/compiler",
|
||||||
|
"comment": "Fix: `resolveUsages` shouldn't include base model",
|
||||||
|
"type": "none"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"packageName": "@cadl-lang/compiler"
|
||||||
|
}
|
|
@ -108,7 +108,6 @@ function navigateReferencedTypes(
|
||||||
callback(type);
|
callback(type);
|
||||||
navigateIterable(type.properties, callback, visited);
|
navigateIterable(type.properties, callback, visited);
|
||||||
navigateIterable(type.derivedModels, callback, visited);
|
navigateIterable(type.derivedModels, callback, visited);
|
||||||
type.baseModel && navigateReferencedTypes(type.baseModel, callback, visited);
|
|
||||||
type.indexer?.value && navigateReferencedTypes(type.indexer.value, callback, visited);
|
type.indexer?.value && navigateReferencedTypes(type.indexer.value, callback, visited);
|
||||||
break;
|
break;
|
||||||
case "ModelProperty":
|
case "ModelProperty":
|
||||||
|
|
|
@ -92,14 +92,14 @@ describe("compiler: helpers: usage resolver", () => {
|
||||||
deepStrictEqual(usages, { inputs: [], outputs: ["Foo", "Bar"] });
|
deepStrictEqual(usages, { inputs: [], outputs: ["Foo", "Bar"] });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("track model referenced via base model in returnType", async () => {
|
it("doesn't track model referenced via base model in returnType", async () => {
|
||||||
const usages = await getUsages(`
|
const usages = await getUsages(`
|
||||||
model Bar {}
|
model Bar {}
|
||||||
model Foo extends Bar {}
|
model Foo extends Bar {}
|
||||||
op test(): Foo;
|
op test(): Foo;
|
||||||
`);
|
`);
|
||||||
|
|
||||||
deepStrictEqual(usages, { inputs: [], outputs: ["Foo", "Bar"] });
|
deepStrictEqual(usages, { inputs: [], outputs: ["Foo"] });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("track model referenced via child model in returnType", async () => {
|
it("track model referenced via child model in returnType", async () => {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче