Preface
Introduction
Who This Book Is For
How to Use This Book
What This Book Is Not
A Note on Runtime
About the Author
Chapter 1: Getting Started
Installing Node.js and a TypeScript Runner
Your First TypeScript Program
Template Literals: String Interpolation
Variables: const and let
Type Annotations (Your First Taste)
Functions
Arrow Functions
The Entry Point
tsconfig.json: Project Configuration
Chapter Exercises
Summary
Chapter 1 Quiz
3 attempts allowed
Chapter 2: Types & Type Annotations
The Basic Types
Type Annotations
Type Inference
null and undefined
Union Types
Literal Types and Enums
Type Aliases
any and unknown
Type Assertions
Chapter Exercises
Summary
Chapter 2 Quiz
3 attempts allowed
Chapter 3: Arrays, Tuples & Iteration
Typed Arrays
Mixed-Type Arrays
Tuples
readonly Arrays and Tuples
Iteration: for…of (The Each Replacement)
forEach: Each with an Index
Traditional for Loop (C-Style)
map: Transform Every Element
filter: Select Elements
reduce: Aggregate Values
some and every: Predicate Checks
Spread and Rest: The Splat Operator
Chapter Exercises
Summary
Chapter 3 Quiz
3 attempts allowed
Chapter 4: Objects, Records & Maps
Object Types: The Hash Replacement
Optional Properties
Index Signatures: Hash-Like Objects
Record
: Typed Hash Map
: When Keys Are Dynamic Set: Unique Collections
Object Destructuring: Hash Splat
Spread: Merging Objects
readonly Properties
Chapter Exercises
Summary
Chapter 4 Quiz
3 attempts allowed
Chapter 5: Functions Deep Dive
Function Declarations vs Arrow Functions
Typed Parameters and Return Types
Optional and Default Parameters
Rest Parameters: Ruby’s Splat
Callbacks and Function Types
Void and Never Return Types
Function Overloads
Chapter Exercises
Summary
Chapter 5 Quiz
3 attempts allowed
Chapter 6: Classes
A Ruby Class, Translated
Access Modifiers: public, private, protected
JavaScript Private Fields (#)
Parameter Properties (Shorthand)
Inheritance: extends
Abstract Classes
Getters and Setters
this and Arrow Functions
Chapter Exercises
Summary
Chapter 6 Quiz
3 attempts allowed
Chapter 7: Interfaces & Type Aliases
Interfaces: The Basics
interface vs type
Extending Interfaces
Optional and readonly Properties in Interfaces
Index Signatures in Interfaces
Structural Typing in Practice
When Interfaces Feel Like Ruby Modules
Chapter Exercises
Summary
Chapter 7 Quiz
3 attempts allowed
Chapter 8: Modules & Package Management
import and export: The New require
Named Exports vs Default Exports
Re-exports and Barrel Files
package.json: The Gemfile
npm, Yarn, and pnpm
node_modules and the Magic of Resolution
Your First TypeScript Project (Walkthrough)
Step 1: Initialize the Project
Step 2: Add a Runtime Dependency
Step 3: Write the Code
Step 4: Add a Run Script
What Just Happened?
tsconfig.json Paths: Module Aliases
Installing Type Definitions
Chapter Exercises
Summary
Chapter 8 Quiz
3 attempts allowed
Chapter 9: Error Handling
try/catch/finally: The Direct Mapping
Typed Catch with instanceof
Custom Error Classes
The TypeScript Way: Errors as Values
Strict Null Checks: Eliminating NoMethodError on nil
Optional Chaining: Safe Navigation
Nullish Coalescing: The || Alternative
Chapter Exercises
Summary
Chapter 9 Quiz
3 attempts allowed
Chapter 10: Async Programming
The Event Loop
Callbacks and Callback Hell
Promises: The Foundation
async/await: Write Async Code That Looks Synchronous
The async Main Function
Async Iteration
Ruby Threads vs TypeScript Promises
Chapter Exercises
Summary
Chapter 10 Quiz
3 attempts allowed
Chapter 11: JSON & Type Narrowing
JSON.stringify: Value to JSON
JSON.parse: JSON to Value (and the any Problem)
Type Assertions: Trust Me
Type Guards: Prove It at Runtime
Zod: Schema Validation
Discriminated Unions: The JSON Pattern
Working with Unknown JSON Shapes
Chapter Exercises
Summary
Chapter 11 Quiz
3 attempts allowed
Chapter 12: Generics & Utility Types
The Problem Generics Solve
Generic Functions
Generic Interfaces and Types
Generic Constraints
Built-in Utility Types
Partial — Make all properties optional
Required — Make all properties required
Pick
— Select specific properties Omit
— Remove specific properties Record
— Map keys to values Pick
& Omit — Composing Types ReturnType — Extract the return type of a function
Awaited — Unwrap a Promise type
Generics vs Duck Typing
Chapter Exercises
Summary
Chapter 12 Quiz
3 attempts allowed
Final Exam
Final Exam
2 attempts allowed
Appendix A: Ruby ↔ TypeScript Quick Reference
Syntax & Structure
Variables & Types
Data Structures
Functions & Methods
Error Handling
Concurrency & Async
Modules & Packages
Common Patterns
TypeScript CLI Cheat Sheet
File Layout
Appendix B: Exercise Answers
Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 8
Chapter 9
Chapter 10
Chapter 11
Chapter 12
Glossary
Acknowledgements
Credits
From Ruby to TypeScript: The Course
Bring your Ruby skills to typed, modern TypeScript, from types to generics.
Learn TypeScript by comparing it with the Ruby you already know. Chapter quizzes and a final exam lead to a certificate.
Minimum price
$149
$149
You pay
Author earns
About
About the Course
From Ruby to TypeScript
Bring your Ruby skills to typed, modern TypeScript, from types to generics.
What You'll Learn
✔ Set up TypeScript and add type annotations
✔ Use arrays, tuples, objects, records and maps
✔ Write functions and classes
✔ Design with interfaces and type aliases
✔ Organize code with modules and packages
✔ Handle errors and write async code
✔ Parse JSON safely with type narrowing
✔ Use generics and utility types
Who Is This Course For?
Ruby developers moving into front-end or Node.js work with TypeScript.
Prerequisites
Solid Ruby experience. Basic JavaScript familiarity helps but isn't required.
Why This Course?
Each TypeScript feature is shown next to its Ruby equivalent, so you learn the type system without starting from zero.
How It Works
- 12 chapters, each ending with a 5-question multiple-choice quiz (3 attempts, best score counts)
- A 20-question final exam covering the whole course
- 80 quiz questions in total
- Score 70% to pass; 85% or more earns honors
- Pass to receive a certificate of completion
Written by Joel Bryan Juliano.
This course is included in this track...
Instructor
About the Instructor
Hi, I'm Joel.
I am Dutch-Filipino Software Engineer with 20+ years of experience.
And with over 20 years in the game, I’ve seen it all and loved every minute of it.
My journey has taken me through a variety of industries, from sports streaming to cybersecurity, both in the private sector and for the Dutch government, and everything in between.
Along the way, I’ve picked up a diverse set of skills and experiences, in which I document into books.
Material
Course Material
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Write and Publish on Leanpub
You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!
Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.
Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.
