TypeScript for R Developers
Learn the JavaScript runtime and TypeScript contracts from R. Compare vectors, named lists, missing values, lexical closures and scalar APIs, then build typed modules and a validated order-processing tool.
R and TypeScript side by side
The same program in R and in TypeScript, from the lessons of this course.
Run TypeScript
R evaluates expressions in environments and does not use TypeScript-style static parameter annotations. TypeScript also erases types, but this course runner checks and compiles TypeScript before Node executes it. R vector operations and lexical functions need…
R1name <- "Ada"2cat(sprintf("Hello, %s!\n", name))TypeScript1const name: string = "Ada";2console.log(`Hello, ${name}!`);Numbers and Conversion
R as.numeric returns NA with a warning for many invalid strings, so conversion requires missingness and finiteness checks. JavaScript Number returns NaN instead, and unexpectedly converts blank text to zero. Validate blankness and finiteness explicitly. A…
R1value <- as.numeric("12")2cat(value + 3, "\n", sep="")TypeScript1const value: number = Number("12");2console.log(value + 3);Arrays and Slice
R vectors use one-based indexes; negative indexes exclude positions instead of counting backward. JavaScript arrays start at zero, and slice uses an exclusive end with negative offsets. Use at(-1) or an explicit length-based index for the final JavaScript…
R1values <- c(1, 2, 3, 4)2middle <- values[2:(length(values)-1)]3cat("[", paste(middle, collapse=","), "]\n", sep="")TypeScript1const values: number[] = [1, 2, 3, 4];2console.log(JSON.stringify(values.slice(1, -1)));For-of and Array Values
R for iterates the elements of a vector or list; JavaScript for-of supplies array values. JavaScript for-in enumerates keys, not numeric elements. There is no built-in range syntax required here: for-of already supplies each element. R vectorized alternatives…
R1total <- 02for (value in c(3, -1, 2)) { if (value > 0) total <- total + value }3cat(total, "\n", sep="")TypeScript1let total: number = 0;2for (const value of [3, -1, 2]) { if (value > 0) total += value; }3console.log(total);Truthiness Is Not Emptiness
R collection emptiness needs an explicit length check; if cannot use a length-zero logical condition as a false value. JavaScript empty arrays and objects are truthy. The source nonempty test and target Boolean conversion intentionally ask different…
R1values <- list()2cat(tolower(as.character(length(values) > 0)), "\n", sep="")TypeScript1const value: unknown = [];2console.log(Boolean(value));Annotations and Inference
R distinguishes integer storage from double storage, and ordinary numeric literals are usually doubles. TypeScript number uses JavaScript floating-point arithmetic for both whole and fractional values. BigInt is a separate runtime type outside these…
R1price <- 2.5; count <- 4L2cat(price * count, "\n", sep="")TypeScript1const price: number = 2.5;2const count = 4;3console.log(price * count);
Syllabus
12 chapters48 lessons1 project48 challenges96 quiz questionsStart Here
1 lessonRuntime Values
4 lessonsRuntime Collections
4 lessonsRuntime Control Flow
4 lessonsRuntime Edge Cases
4 lessonsTyped Contracts
5 lessonsTyped Flow
5 lessonsTyped Functions
5 lessonsTyped Collections
5 lessonsReliable Modules and Objects
5 lessonsProject: Typed Orders
4 lessonsFinal Challenges
2 lessonsFrequently asked questions
Who is TypeScript for R Developers for?
For people who already write R and want to learn TypeScript. Each lesson starts from R you know and shows how TypeScript does the same thing, so you skip the beginner basics.
Do I need to know TypeScript already?
No. The course starts with your first TypeScript program. You need R basics: variables, conditions, loops, functions and collections.
How many lessons does TypeScript for R Developers have?
TypeScript for R Developers contains 48 interactive lessons you can complete at your own pace.
What does TypeScript for R Developers cover?
The course is organized into chapters covering: Start Here, Runtime Values, Runtime Collections, Runtime Control Flow, and more.
Is TypeScript for R Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.