Fix: `resolveUsage` shouldn't include model `extends` (#1485)

This commit is contained in:
Timothee Guerin 2023-01-03 10:04:53 -08:00 коммит произвёл GitHub
Родитель 61646b27bd
Коммит 87c5d833de
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 12 добавлений и 3 удалений

Просмотреть файл

@ -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 () => {