2
0
Эх сурвалжийг харах

improve isPopulated and getIdForRef

Yuki Takei 2 жил өмнө
parent
commit
0d44eec554

+ 2 - 2
packages/core/src/interfaces/common.ts

@@ -10,11 +10,11 @@ export type Ref<T> = string | T & HasObjectId;
 
 
 export type Nullable<T> = T | null | undefined;
 export type Nullable<T> = T | null | undefined;
 
 
-export const isPopulated = <T>(ref: Ref<T>): ref is T & HasObjectId => {
+export const isPopulated = <T>(ref: T & HasObjectId | Ref<T>): ref is T & HasObjectId => {
   return !(typeof ref === 'string');
   return !(typeof ref === 'string');
 };
 };
 
 
-export const getIdForRef = <T>(ref: Ref<T>): string => {
+export const getIdForRef = <T>(ref: T & HasObjectId | Ref<T>): string => {
   return isPopulated(ref)
   return isPopulated(ref)
     ? ref._id
     ? ref._id
     : ref;
     : ref;