Type Dungeon
to-strict
Play this with TypeScript playground !
// Edit the right hand side to match the following expected type conditions.
type Strict<T> = unknown;
// Expected
type SomeObjectType = {
name?: string;
age?: number;
};
declare const strictObj: Strict<SomeObjectType>;
const name: string = strictObj.name; // typeof name should not be undefined / null
const age: number = strictObj.age; // typeof age should not be undefined / null
awaited
Play this with TypeScript playground !
// Edit the right hand side to match the following expected type conditions.
type Awaited<T> = any;
type P1 = Promise<string>;
type P2 = Promise<Promise<string>>;
// expected
type S1 = Awaited<P1>; // should be string;
type S2 = Awaited<P2>; // shuuld be string too;
curry
Play this with TypeScript playground !
// Complete the function type to match the following expected type condition.
declare function curry(fn: Function): any;
// Expected
const add = (a: number, b: number) => a + b;
const bound = curry(add)(1);
bound(); // should throw error
bound(100, 100); // should throw error
const value: number = bound(100); // should NOT throw error
randomize
Play this with TypeScript playground !
// Complete the `Random` type.
type Random = unknown;
declare const random: Random;
const a = { value: 1 } as const;
const b = { value: 2 } as const;
const c = { value: 3 } as const;
// Expected:
// The `random` return type should be assignable this type annotation.
const value: { value: 1 } | { value: 2 } | { value: 3 } = random(a, b, c);
LICENSE
MIT