Skip to content

Commit cb04546

Browse files
committed
Domain annotations: do not crash when structure has no models
1 parent f973876 commit cb04546

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/app/domain-annotations/prop.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,17 @@ namespace DomainAnnotations {
5757
}
5858

5959
export function getDomainTypes(structure?: Structure): string[] {
60-
if (!structure) return _emptyArray;
61-
const prop = DomainAnnotationsProvider.get(structure.models[0]).value;
60+
const model = structure?.models[0];
61+
if (!model) return _emptyArray;
62+
const prop = DomainAnnotationsProvider.get(model).value;
6263
if (!prop || !prop.data) return _emptyArray;
6364
return prop.data.domainTypes;
6465
}
6566

6667
export function getDomainNames(structure?: Structure): string[][] {
67-
if (!structure) return [];
68-
const prop = DomainAnnotationsProvider.get(structure.models[0]).value;
68+
const model = structure?.models[0];
69+
if (!model) return [];
70+
const prop = DomainAnnotationsProvider.get(model).value;
6971
if (!prop || !prop.data) return [];
7072
return prop.data.domainNames;
7173
}

0 commit comments

Comments
 (0)