Reputation: 82427
The breeze docs show this to get the property type for a property on an entity:
//get the Person type
var personType = em.metadataStore.getEntityType("Person");
//get the property definition to validate
var websiteProperty = personType.getProperty("website");
But if you are using Typescript this does not work.
The type definitions for MetadataStore.getEntityType
returns an IStructuralType
. But getProperty
is on EntityType
and not on IStructuralType
.
EntityType
does implement IStructuralType
, but there is no guarantee that the IStructuralType
is an EntityType
.
Is this an error in the typing for Breeze? Or is there another way to get this method call?
Upvotes: 0
Views: 82
Reputation: 11720
You have two options:
em.metadataStore.getEntityType("Person") as EntityType;
getEntityType
to return an EntityType
in your .d.ts
fileKeep in mind that changing type information is always safe - the worst you can ever do is cause a TypeScript compile error. This is because all type information is erased. (The exception is changing the name or extends of a class, since that is compiled to js.)
Upvotes: 1