metadevpro / openapi3-ts

TS Model & utils for creating and exposing OpenAPI 3.x contracts.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add "isDereferencedObject" helper method

nathanwinder opened this issue · comments

/**
 * Type gate to ensure an object has been de-referenced.
 * 
 * @param obj The object to check.
 */
function isDereferencedObject<T extends object | ReferenceObject>(
  obj: T
): obj is Exclude<T, ReferenceObject> {
   return !isReferenceObject(obj);
}

Using !isReferenceObject(obj) has the same effect so no need for this extra API