Intro
What is Type Challenges? Type Challenges is a collection of typescript type system puzzles.
This project is aimed at helping you better understand how the type system works, writing your own utilities, or just having fun with the challenges. We are also trying to form a community that you can ask questions and get answers you have faced in the real world - they may become part of the challenges!
View the original github repository for more information.
#
Why built thisI always forget how I solved these puzzles, but when I try to figure out how, it's hard to find by Type Challenges UI.
Type Challenges depends on github repository pages which makes hard to jump between different sites.
So I build this site collect all actions of challenge into one place, provides at least one solution and extra type information without navigate to other places.
Start with the Hello World
example.
#
Hello World#
IntroductionHello, World!
In Type Challenges, we use the type system itself to do the assertion.
For this challenge, you will need to change the following code to make the tests pass (no type check errors).
ts
// expected to be stringtype HelloWorld = any;
ts
// expected to be stringtype HelloWorld = any;
note
Go back to the original Type Challenges puzzle start page.
View on GitHub#
Start pointtsTry
/* _____________ Your Code Here _____________ */typeHelloWorld = any; // expected to be a stringÂ/* _____________ Test Cases _____________ */typecases = [Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <HelloWorld , string>>]Â
tsTry
/* _____________ Your Code Here _____________ */typeHelloWorld = any; // expected to be a stringÂ/* _____________ Test Cases _____________ */typecases = [Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <HelloWorld , string>>]Â
note
Go to the Type Challenges typescript playground page.
take the challengetip
this site build with shiki-twoslash
in which markdown code samples are powered by the syntax engine of visual studio code mixed with the typescript compiler’s information
code snippets show type information like this
tsTry
/* _____________ Your Code Here _____________ */typeHelloWorld = any; // expected to be a stringÂ/* _____________ Test Cases _____________ */typecases = [Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <HelloWorld , string>>]Â
tsTry
/* _____________ Your Code Here _____________ */typeHelloWorld = any; // expected to be a stringÂ/* _____________ Test Cases _____________ */typecases = [Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <HelloWorld , string>>]Â
#
my solutionsSpoiler warning // Click to reveal answer
note
Go to the Type Challenges issues to share your answer and other community answers.
share your answerview more solutions