TypeScript
Learn TypeScript by typing real, typed code.
Practice the parts of TypeScript that trip people up: interfaces vs. types, generics, discriminated unions, and how the compiler narrows a type through your control flow. You type genuine, well-typed snippets and an AI tutor unpacks each line — what a mapped type does, why an assertion is a smell — so the type system stops fighting you and starts helping.
Progress0 / 682 solved · 0/50 sections
best wpm
0
avg wpm
0
accuracy
0%
runs
0
level
1
rating
1000
Run TypeScript on your machine
1. Install the toolchain
npm i -g typescript tsx2. Save your code as hello.ts, then compile & run
npx tsx hello.ts # or: tsc hello.ts && node hello.jsprogress by section
1Fundamentals0/5start →
2Strings In Depth0/18start →
Case and trimmingStrings are immutableRepeatThe string typeSearch a stringPad to a widthReplace textsplit and joinTrim one sideCharacter with at()Typed helperCompare for sortingConvert to and from numbersIterate charactersSlice a substringMatch a patternTemplate literal typesTemplate types over unions
3Values & References0/18start →
AliasingCopy an arrayconst blocks rebindingReference identityPrimitives are safereadonly propertiesValue vs referenceMutation via referencereadonly parameterReadonly<T>Reassigning a parameterShallow copyconst assertionsObject.freezeFreeze is shallowReturn new vs mutateShallow copy shares nestedstructuredClone
4Slices & Arrays0/18Unlock →
5Data structures0/8Unlock →
6Iterators0/20Unlock →
7Traits0/21Unlock →
Interface as a traitDefaults via spreadInterface with methodsAbstract methods via interfaceAn add methodA Cloneable interfaceA Comparable interfaceAn Equatable interfaceA conversion factoryA composite map keyAccept anything convertibleStructural typingCustom toStringA callable interfaceInterface extends interfaceIndex signaturesIterable via a generatorA fallible conversionA generic interfaceA typed IteratorIntersection types for mixins
8Generics0/20Unlock →
Generic classConstraint with extendsGeneric functionGeneric interfaceTwo type parametersGeneric union typeUtility typesInterface-constrained genericDefault type parameterGeneric over iterableskeyof & indexed accessGeneric methodsGeneric minConditional typeGeneric with a key functionMapped typeBranded typeGenerics preserve typesinfer in a conditionalVariadic tuple types
9Lifetimes0/20Unlock →
Block scopeA program-long constantStrings are immutableClosures capture by referenceA function valueDropping a referencereadonly fieldsReadonlyArrayA closure keeps state aliveAn IIFE scopePer-iteration captureReturning a closureVariable shadowingA typed WeakMapusing + Symbol.disposeNested using scopesA WeakRefawait usingA FinalizationRegistryA generator holds its input
10Closures0/20Unlock →
An arrow functionCapturing the environmentExplicit types & bodyCapturing in a filterMultiple parametersMutating captured stateAn array of functionsCallbacksCapturing a live variableA function type aliasFunction as an argumentClosures drive a pipelineA callback invoked repeatedlyReturning a typed functionsort with a comparatorA stateful closureHigher-order: composeCurryingReturn different functionsMemoize
11Pattern Matching0/20Unlock →
switch on literalsTest then reuse the valueMatch as an expressionDestructure an objectNullable narrowingCase fallthroughRanges with switch(true)Destructure a tupletypeof narrowingMatch an array's shapeDiscriminated unionGuard conditionsthe in operatorinstanceof narrowingRest in destructuringResult unionswitch(true) guard chainExhaustiveness with neverUser-defined type guardNested union
12Error Handling0/20Unlock →
finally for cleanuptry/catch with unknownCustom Error subclassKeep only successesNarrow an unknown errorinstanceof checksRethrowAssertion functionerror.causeAdd context to an errorError with fieldsTyped error unionResult constructorsMap over a ResultResult discriminated unionJSON.parse into a ResultAssert a value's typeCollect into a ResultExhaustive switch with neverChain Results
13Option & Result0/20Unlock →
T | nullNullish coalescingOptional chainingOptional parameterT | undefinedFallback valueFilter a MaybeArray.find is optionalMap a MaybeNarrow out nullNon-null assertionNullish assignmentandThen (flatMap)Compact an arrayNonNullable<T>Optional call and indexMap a ResultResult<T, E>Zip two MaybesChain a Result
14Conversions0/15Unlock →
15Collection Conversions0/19Unlock →
Array to SetUnique and sortedflat and flatMapMap keys to arrayMap values to arrayIterate object entriesPairs to a MapSet to sorted arrayas const tuplesFrequency MapMap keys to a SetMap to pairsMap to ObjectBuild an object from pairsObject to MapTwo arrays to a MapUnique, keeping orderGroup into a MapInvert a Record
16Math0/14Unlock →
17Encoding0/22Unlock →
String to bytesASCII checks and caseBytes to stringChar to code pointDigit charactersNumber basesPercent-decodePercent-encodeBase64 decodeBase64 encodeList code pointsEscape a stringHex decodeHex encodeUnits vs code pointsParse a number in a baseLossy UTF-8 decodeBig-endian bytesCaesar cipherLittle-endian bytesROT13XOR cipher
18Random0/20Unlock →
Random unit floatCoin flipRandom float in a rangeSeed from the clockRandom UUIDSecure random bytesWeighted true/falsePick a random elementRandom integer in a rangeRandom union variantRoll many dicePassword generatorReproducible sequencesSample without replacementFisher-Yates shuffleRandom alphanumeric stringRandom hex tokenSeeded LCGWeighted choiceNormal distribution
19Data I/O0/18Unlock →
Parse CSV into rowsTab-separated valuesBuild a CSV stringSelect one columnCSV into a number matrixSplit off the headerTyped JSON parseWhitespace-separated matrixRead a data fileSerialize records to CSVSkip blanks and commentsPrint an aligned tableWrite CSV to a fileAppend a rowkey=value into a Mapkey=value into a RecordRound-trip write then readDrop unparseable rows
20Linear Algebra0/21Unlock →
Matrix shapeScalar multiplyA matrix of zerosElementwise addArgmax of a vectorDot productFlatten a matrixIdentity matrixOne-hot encodeTraceStack rows (vstack)ReLU and sigmoidColumn sums and meansCosine similarityApply a function elementwiseMatrix times vectorTransposeMatrix multiplyMin-max normalize columnsSoftmaxStandardize columns (z-score)
21Text Processing0/16Unlock →
22Date & Time0/12Unlock →
23Memory0/12Unlock →
24Modules0/20Unlock →
Named exportNamed importImport with an aliasExported constantsDefault exportExport an enumGrouped importNamespace importExport a classexport typeimport typeModule identityTS namespaceA small utility moduleDynamic importExport an interfaceRe-export a bindingBarrel re-exportType-only export listModule augmentation
25Macros0/20Unlock →
Built-in mapped helpersThe Record typeA conditional typeIntrinsic string typeskeyof and indexed accessA mapped typeThe satisfies operatorA template literal typeinfer an element typeA tagged templateTemplate literal over unionsTuple values to a unionA const type parameterExhaustive union checksinfer a return typeKey remapping with asA typed ProxyA class decoratorA method decoratorA recursive type
26Testing0/20Unlock →
A unit testnotStrictEqualstrictEqualTesting string outputCovering both branchesAsserting on an arrayAn async testDeep equalityA test helperTesting a methodTesting undefinedSkipping a testAssert a throwComparing floatsTesting an async errorSubtestsTable-driven testsAssert on the messageA typed expect helperType-level tests
27Algorithms0/8Unlock →
28Sorting Algorithms0/12Unlock →
29Expression Parsing0/6Unlock →
30Idioms0/9Unlock →
31OOP & Traits0/8Unlock →
32Trait Objects0/14Unlock →
An interface-typed arrayDefault method over an interfaceFactory returning an interfaceNarrowing dispatchTake an interface parameterA shared referenceDiscriminated unionAn extended interfaceAn array of functionsReturn an IterableRecover the concrete typePolymorphism via interfaceA read-only viewA handler registry
33Design Patterns0/14Unlock →
35File I/O0/6Unlock →
36Filesystem0/18Unlock →
37Networking0/16Unlock →
38Concurrency0/7Unlock →
39Unsafe & FFI0/14Unlock →
40Commands0/14Unlock →
41Array0/10Unlock →
43String0/10Unlock →
45Interval0/5Unlock →
46Linked List0/6Unlock →
47Tree0/14Unlock →
Maximum Depth of Binary TreeInvert Binary TreeSame TreeLowest Common Ancestor of a BSTBinary Tree Level Order TraversalSubtree of Another TreeImplement Trie (Prefix Tree)Kth Smallest Element in a BSTValidate Binary Search TreeAdd and Search WordConstruct Binary Tree from Preorder and InorderBinary Tree Maximum Path SumSerialize and Deserialize Binary TreeWord Search II