@serenity-js/core
Version:
The core Serenity/JS framework, providing the Screenplay Pattern interfaces, as well as the test reporting and integration infrastructure
17 lines (15 loc) • 598 B
text/typescript
import type { Question } from './Question';
/**
* Describes the type of answer a given [`Answerable`](https://serenity-js.org/api/core/#Answerable) would
* resolve to when given to [`Actor.answer`](https://serenity-js.org/api/core/class/Actor/#answer).
*
* ```ts
* Answered<Answerable<T>> === T
* ```
*
* @group Questions
*/
export type Answered<T> =
T extends null | undefined ? T : // special case for `null | undefined` when not in `--strictNullChecks` mode
T extends Question<Promise<infer A>> | Question<infer A> | Promise<infer A> ? Awaited<A> :
T;