@scalar/typebox
Version:
Json Schema Type Builder with Static Type Resolution for TypeScript
8 lines (7 loc) • 372 B
JavaScript
import { CreateType } from '../create/type.mjs';
import { Never } from '../never/index.mjs';
import * as KindGuard from '../guard/kind.mjs';
/** `[JavaScript]` Extracts the InstanceType from the given Constructor type */
export function InstanceType(schema, options) {
return (KindGuard.IsConstructor(schema) ? CreateType(schema.returns, options) : Never(options));
}