counterfact
Version:
Generate a TypeScript-based mock server from an OpenAPI spec in seconds — with stateful routes, hot reload, and REPL support.
12 lines (11 loc) • 380 B
text/typescript
/**
* Creates a new type from `Base` that omits any keys whose value type is
* `never`. This is used to strip unavailable builder methods (those that
* don't apply to the current response shape) from the fluent response builder.
*/
export type OmitValueWhenNever<Base> = Pick<
Base,
{
[Key in keyof Base]: [Base[Key]] extends [never] ? never : Key;
}[keyof Base]
>;