Hard
Simple Vue
Implement a simpiled version of a Vue-like typing support.
By providing a function name `SimpleVu
Currying 1
TypeScript 4.0 is recommended in this challenge
[Currying](https://en.wikipedia.org/wiki/Curryi
Union to Intersection
Implement the advanced util type UnionToIntersection<U>
For example
type I = UnionToInte
Get Required
Implement the advanced util type GetRequired<T>
, which remains all the required fields
For exam
Get Optional
Implement the advanced util type GetOptional<T>
, which remains all the optional fields
For exam
Required Keys
Implement the advanced util type RequiredKeys<T>
, which picks all the required keys into a union
Optional Keys
Implement the advanced util type OptionalKeys<T>
, which picks all the optional keys into a union
Capitalize Words
Implement CapitalizeWords<T>
which converts the first letter of each word of a string to upp
CamelCase
Implement CamelCase<T>
which converts snake_case
string to camelCase
.
For example
ty
C-printf Parser
There is a function in C language: printf
. This function allows us to print something with forma
Vue Basic Props
**This challenge continues from 6 - Simple Vue, you should finish that one firs
IsAny
Sometimes it's useful to detect if you have a value with any
type. This is especially helpful wh
Typed Get
The get
function in lodash is a quite convenient helper f
String to Number
Convert a string literal to a number, which behaves like Number.parseInt
.
Tuple Filter
Implement a type FilterOut<T, F>
that filters out items of the given type F
from the tuple T
Tuple to Enum Object
The enum is an original syntax of TypeScript (it does not exist in JavaScript). So it is converted
printf
Implement Format<T extends string>
generic.
For example,
type FormatCase1 = Format<"%sab
Deep object to unique
TypeScript has structural type system, but sometimes you want a function to accept only some previ
Length of String 2
Implement a type LengthOfString<S>
that calculates the length of the template string (as in [298
Union to Tuple
Implement a type, UnionToTuple
, that converts a union to a tuple.
As we know, union is an unord
String Join
Create a type-safe string join utility which can be used like so:
const hyphenJoiner = join
DeepPick
Implement a type DeepPick, that extends Utility types Pick
.
A type takes two arguments.
For ex
Pinia
Create a type-level function whose types is similar to Pinia lib
Camelize
Implement Camelize which converts object from snake_case to to camelCase
Camelize<{ some_
Drop String
Drop the specified chars from a string.
For example:
type Butterfly = DropString<'foobar!'
Split
The well known split()
method splits a string into an array of substrings by looking for a separ
ClassPublicKeys
Implement the generic ClassPublicKeys<T>
which returns all public keys of a class.
For example:
IsRequiredKey
Implement a generic IsRequiredKey<T, K>
that return whether K
are required keys of ``
ObjectFromEntries
Implement the type version of Object.fromEntries
For example:
interface Mode
InorderTraversal
Implement the type version of binary tree inorder traversal.
For example:
const tr
IsPalindrome
Implement type IsPalindrome<T>
to check whether a string or number is palindrome.
For exam
Mutable Keys
Implement the advanced util type MutableKeys, which picks all the mutable (not readonly) keys i
Intersection
Implement the type version of Lodash.intersection with a little difference. Intersection takes
Binary to Decimal
Implement BinaryToDecimal<S>
which takes an exact string type S
consisting 0 and 1 and returns
Object Key Paths
Get all possible paths that could be called by _.get (a lod
Two Sum
Given an array of integers nums
and an integer target
, return true if two numbers such that th
ValidDate
Implement a type ValidDate
, which takes an input type T and returns whether T is a valid date.
Assign
You have a target object and a source array of objects. You need to copy property from source to t
Maximum
Description
Implement the type Maximum
, which takes an input type T
, and returns the
Capitalize Nest Object Keys
Capitalize the key of the object, and if the value is an array, iterate through the objects in the
Replace Union
Given an union of types
and array of type pairs
to replace ([[string, number], [Date, null]]
FizzBuzz
The FizzBuzz problem is a classic test given in coding interviews. The task is simple:
Print in
Run-length encoding
Given a string
sequence of a letters f.e. AAABCCXXXXXXY
. Return run-length encoded string `3AB
Tree path array
Create a type Path
that represents validates a possible path of a tree under the form of an ar
SnakeCase
Create a SnakeCase<T>
generic that turns a string formatted in camelCase into a string forma
IsNegativeNumber
Sometimes when working with numeric literals, we need to rule out (or enforce) that the provided n
OptionalUndefined
Implement the util type OptionalUndefined<T, Props>
that turns all the properties of T
that ca
BitwiseXOR
Implement BitwiseXOR<S1,S2>
which takes two binary string literal type and returns a binary
Unique Items
Some concepts in TypeScript can not be described by types, but can be expressed through type const
Sudoku
Write a type that verifies Sudoku game is solved. This is
Length of String 3
Implement a type LengthOfString<S>
just like Array#length
:
Differing to two previous challeng
Unbox
How can we build a type that "unboxes" arrays, functions, promises, and tuples?
Example:
Binary Addition
Implement BinaryAdd
to add two binary numbers together. The numbers should not be translated out
Take Elements
Implement a type Take<N, Arr>
that returns the first N
elements from an array Arr
. If N
is
Union to Object from key
Find the object containing the key in the union type by the key. It takes two parameters: a union
Valid Sudoku
Sudoku is a famous paper and pencil game. The goal of Sudoku is to fill a 9x9 grid with numbers so