MaxMEllon / type-dungeon

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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
Check out the answer.

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;
Check out the answer.

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
Check out the answer.

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);
Check out the answer.

LICENSE

MIT

About

License:MIT License


Languages

Language:TypeScript 100.0%