⚠️ Available starting with v10.3.0
The method checks that the entity’s method is compatible with the provided type and casts this to shared entity type. It’s available on Ref, Doc Collection, and Group.
this
Ref
Doc
Collection
Group
export interface NameFields { firstName: string; lastName: string;} function rename(entity: Typesaurus.SharedEntity<NameFields>, name: string) { const [firstName = "", lastName = ""] = name.split(" "); return entity.update({ firstName, lastName });} // Check that the user model is compatible with `NameFields`rename(userDoc.as<NameFields>());
The method returns this casted to Typesaurus.SharedRef or Typesaurus.SharedDoc.
Typesaurus.SharedRef
Typesaurus.SharedDoc
→ Read more about sharing functionality