Menu
CoddyTech
Course

TypeScript for Go Developers

Learn TypeScript and the JavaScript runtime from Go: values, control flow, callbacks, typed collections, validation and object modules. Build a connected order-processing project and port two source programs.

Go and TypeScript side by side

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

  1. Run TypeScript

    Go compiles packages with a main function. TypeScript instead emits JavaScript executed by Node, and its types are erased. This course introduces JavaScript variables, arrays, objects and functions without assuming prior JavaScript knowledge.

    Go
    1package main2import (3"fmt"4)5
    6func main() {7name:="Ada"8fmt.Printf("Hello, %s!\n",name)9}
    TypeScript
    1const name: string = "Ada";2console.log(`Hello, ${name}!`);3export {};
  2. Numbers and Conversion

    Go strconv.Atoi returns a value and error; the caller checks the error. JavaScript Number instead can yield NaN, and blank text converts to zero. Explicit conversion and validation replace the Go error-return pattern here.

    Go
    1package main2import (3"fmt"4"strconv"5)6
    7func main() {8n,err:=strconv.Atoi("12")9if err!=nil { panic(err) }10fmt.Println(n+3)11}
    TypeScript
    1const value: number = Number("12");2console.log(value + 3);3export {};
  3. Arrays and Slice

    Go slicing creates a view of the same backing array; JavaScript slice creates a new outer array. Both exclude the end bound, but JavaScript out-of-range bracket reads return undefined rather than a Go bounds panic.

    Go
    1package main2import (3"fmt"4"encoding/json"5)6
    7func emit(v any) { b,err:=json.Marshal(v); if err!=nil { panic(err) }; fmt.Println(string(b)) }8
    9func main() {10values:=[]int{1,2,3,4}11emit(values[1:3])12}
    TypeScript
    1const values: number[] = [1, 2, 3, 4];2console.log(JSON.stringify(values.slice(1, -1)));3export {};
  4. For-of and Array Values

    Go range over a slice yields index and value. JavaScript for-of yields values; for-in enumerates keys and is not Go range. Use entries when you need both index and value.

    Go
    1package main2import (3"fmt"4)5
    6func main() {7total:=08for _,value:=range []int{3,-1,2} {if value>0 {total+=value}}9fmt.Println(total)10}
    TypeScript
    1let total: number = 0;2for (const value of [3, -1, 2]) { if (value > 0) total += value; }3console.log(total);4export {};
  5. Truthiness Is Not Emptiness

    Go conditions require bool, so slice length or nil must be tested explicitly. JavaScript treats an empty array as true. The source nonempty check and target truthiness check intentionally differ; translating collection conditions requires a deliberate length…

    Go
    1package main2import (3"fmt"4)5
    6func main() {7values:=[]int{}8fmt.Println(len(values)>0)9}
    TypeScript
    1const value: unknown = [];2console.log(Boolean(value));3export {};
  6. Annotations and Inference

    Go distinguishes integer widths and floating-point types and requires explicit conversions in mixed arithmetic. TypeScript number uses JavaScript floating-point arithmetic. Annotating a count as number does not provide Go integer overflow or division…

    Go
    1package main2import (3"fmt"4)5
    6func main() {7price:=2.58count:=49fmt.Println(price*float64(count))10}
    TypeScript
    1const price: number = 2.5;2const count = 4;3console.log(price * count);4export {};

Syllabus

12 chapters48 lessons1 project48 challenges96 quiz questions

Start Here

1 lesson

Final Challenges

2 lessons

More courses for Go developers

Learn TypeScript from another language

Frequently asked questions

Who is TypeScript for Go Developers for?

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

How many lessons does TypeScript for Go Developers have?

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

What does TypeScript for Go Developers cover?

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

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

Get started