Menu
CoddyTech
Course

TypeScript for Swift Developers

Learn JavaScript runtime semantics and TypeScript structural contracts from Swift. Compare value copies, optionals, closures, generics and protocols, then build typed modules and a validated order-processing tool.

Swift and TypeScript side by side

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

  1. Run TypeScript

    Swift can compile top-level executable code in main.swift, while TypeScript emits JavaScript for Node. TypeScript annotations disappear before execution. No JavaScript prerequisite is assumed: the early lessons teach its runtime before deeper static…

    Swift
    1import Foundation2let name: String = "Ada"3print("Hello, \(name)!")
    TypeScript
    1const name: string = "Ada";2console.log(`Hello, ${name}!`);
  2. Numbers and Conversion

    Swift Int initialization returns an optional for integer text; unwrap only when success is established, as with this fixed literal. JavaScript Number accepts decimals and exponent notation, yields NaN for bad text, and converts blanks to zero. Validate blank…

    Swift
    1import Foundation2let value = Int("12")!3print(value + 3)
    TypeScript
    1const value: number = Number("12");2console.log(value + 3);
  3. Arrays and Slice

    Swift indexed array access checks bounds; dropFirst and dropLast can build the desired subsequence without unsafe index arithmetic. JavaScript array bracket access returns undefined when missing. Slice is a shallow copy with an exclusive end and negative…

    Swift
    1import Foundation2func emit(_ value: Any) {3    let data = try! JSONSerialization.data(withJSONObject: value, options: [.sortedKeys, .fragmentsAllowed])4    print(String(data: data, encoding: .utf8)!)5}6let values = [1,2,3,4]7let middle = Array(values.dropFirst().dropLast())8emit(middle)
    TypeScript
    1const values: number[] = [1, 2, 3, 4];2console.log(JSON.stringify(values.slice(1, -1)));
  4. For-of and Array Values

    Swift for-in visits sequence values, but JavaScript for-in enumerates keys. Translate to for-of. Recommended TypeScript uses let for a reassigned accumulator and const for each iteration binding. Both languages allow braces and block-local declarations.…

    Swift
    1import Foundation2var total = 03for value in [3,-1,2] { if value > 0 { total += value } }4print(total)
    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

    Swift requires a Bool condition, so an array cannot directly serve as an if condition. JavaScript permits an array as a condition and empty arrays are truthy. The source explicitly asks for non-emptiness and prints false, while Boolean([]) in the target…

    Swift
    1import Foundation2let values: [Int] = []3print(!values.isEmpty)
    TypeScript
    1const value: unknown = [];2console.log(Boolean(value));
  6. Annotations and Inference

    Swift distinguishes Int and Double and requires explicit conversion for this mixed arithmetic. TypeScript number uses JavaScript binary floating-point arithmetic for both whole and fractional numbers. A number annotation does not request Int overflow or…

    Swift
    1import Foundation2let price: Double = 2.53let count: Int = 44print(price * Double(count))
    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 Swift developers

Learn TypeScript from another language

Frequently asked questions

Who is TypeScript for Swift Developers for?

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

How many lessons does TypeScript for Swift Developers have?

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

What does TypeScript for Swift Developers cover?

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

Is TypeScript for Swift 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 Swift Developers for free

Get started