Menu
CoddyTech
Course

TypeScript for C++ Developers

Learn JavaScript runtime semantics and TypeScript structural contracts from C++. Compare value copies, callbacks, variants and containers, then build typed modules and a validated order-processing tool.

C++ and TypeScript side by side

The same program in C++ and in TypeScript, from the lessons of this course.

  1. Run TypeScript

    C++ compiles translation units and links an executable starting at main. TypeScript compiles to JavaScript and this course executes it on Node. The checker erases annotations before execution. No JavaScript prerequisite is assumed; the locked main reads JSON…

    C++
    1#include <iostream>2#include <string>3#include <vector>4#include <map>5#include <optional>6#include <variant>7#include <algorithm>8#include <functional>9#include <tuple>10#include <cctype>11
    12int main() {13    std::cout << std::boolalpha;14    std::string name="Ada";15    std::cout << "Hello, " << name << "!\n";16}
    TypeScript
    1const name: string = "Ada";2console.log(`Hello, ${name}!`);
  2. Numbers and Conversion

    C++ std::stoi throws on failed conversion or range errors; its position output is needed to reject a partially parsed string. JavaScript Number returns NaN for invalid text and zero for blank strings. Check blankness and finiteness before adding; + can…

    C++
    1#include <iostream>2#include <string>3#include <vector>4#include <map>5#include <optional>6#include <variant>7#include <algorithm>8#include <functional>9#include <tuple>10#include <cctype>11
    12int main() {13    std::cout << std::boolalpha;14    std::size_t used=0;15    int value=std::stoi("12", &used);16    std::cout << value+3 << "\n";17}
    TypeScript
    1const value: number = Number("12");2console.log(value + 3);
  3. Arrays and Slice

    C++ vector operator[] does not check bounds, while at throws; iterator ranges can construct independent vectors. JavaScript arrays resize and missing indexed reads yield undefined. Slice copies a range with exclusive end and negative-offset support, whereas…

    C++
    1#include <iostream>2#include <string>3#include <vector>4#include <map>5#include <optional>6#include <variant>7#include <algorithm>8#include <functional>9#include <tuple>10#include <cctype>11
    12int main() {13    std::cout << std::boolalpha;14    std::vector<int> values{1,2,3,4};15    std::vector<int> middle(values.begin()+1,values.end()-1);16    std::cout << "[" << middle[0] << "," << middle[1] << "]\n";17}
    TypeScript
    1const values: number[] = [1, 2, 3, 4];2console.log(JSON.stringify(values.slice(1, -1)));
  4. For-of and Array Values

    A C++ range-for loop visits elements; its declaration decides whether each binding is a copy or reference. For-in is key enumeration, not the equivalent collection-value loop. Braces and block scope are familiar; declare the accumulator with let and each loop…

    C++
    1#include <iostream>2#include <string>3#include <vector>4#include <map>5#include <optional>6#include <variant>7#include <algorithm>8#include <functional>9#include <tuple>10#include <cctype>11
    12int main() {13    std::cout << std::boolalpha;14    std::vector<int> values{3,-1,2};15    int total=0;16    for(int n:values) if(n>0) total+=n;17    std::cout << total << "\n";18}
    TypeScript
    1let total: number = 0;2for (const value of [3, -1, 2]) { if (value > 0) total += value; }3console.log(total);
  5. Truthiness Is Not Emptiness

    A C++ vector has no implicit boolean conversion; test empty or size explicitly. JavaScript permits arrays in conditions and even empty arrays are truthy. This source explicitly tests non-emptiness and prints false; the TypeScript Boolean([]) example prints…

    C++
    1#include <iostream>2#include <string>3#include <vector>4#include <map>5#include <optional>6#include <variant>7#include <algorithm>8#include <functional>9#include <tuple>10#include <cctype>11
    12int main() {13    std::cout << std::boolalpha;14    std::vector<int> values;15    std::cout << !values.empty() << "\n";16}
    TypeScript
    1const value: unknown = [];2console.log(Boolean(value));
  6. Annotations and Inference

    C++ distinguishes integral and floating-point types and applies arithmetic conversions to mixed expressions. TypeScript number uses JavaScript binary floating-point arithmetic. For the later order project, integer cents avoid accidental assumptions about…

    C++
    1#include <iostream>2#include <string>3#include <vector>4#include <map>5#include <optional>6#include <variant>7#include <algorithm>8#include <functional>9#include <tuple>10#include <cctype>11
    12int main() {13    std::cout << std::boolalpha;14    double price=2.5;15    int count=4;16    std::cout << price*count << "\n";17}
    TypeScript
    1const price: number = 2.5;2const count = 4;3console.log(price * count);

Syllabus

12 chapters48 lessons1 project48 challenges96 quiz questions

Start Here

1 lesson

Final Challenges

2 lessons

More courses for C++ developers

Learn TypeScript from another language

Frequently asked questions

Who is TypeScript for C++ Developers for?

For people who already write C++ and want to learn TypeScript. Each lesson starts from C++ 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 C++ basics: variables, conditions, loops, functions and collections.

How many lessons does TypeScript for C++ Developers have?

TypeScript for C++ Developers contains 48 interactive lessons you can complete at your own pace.

What does TypeScript for C++ Developers cover?

The course is organized into chapters covering: Start Here, Runtime Values, Runtime Collections, Runtime Control Flow, and more.

Is TypeScript for C++ Developers free?

Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.

Coddy programming languages illustration

Start TypeScript for C++ Developers for free

Get started