Skip to content

jozr/typescript-workshops

Repository files navigation

TypeScript Workshops

Intro

This repository serves as an introduction to TypeScript. After reading through the documentation and completing the challenges, you should have a basic grasp of how the language works.

Setup

VSCode is a great editor for TypeScript. It has great navigation for the language and includes numerous extensions for both JavaScript and Typescript.

Ensure you have npm installed via Homebrew or via Node.

Then install local packages from the root of the project.

npm install

Folders

Basic Types

In the basic-types/ folder, there is some documentation on basic types and data structures. These come from https://www.typescriptlang.org/. Go through each file and experiment with the code.

TSC Playground

TypeScript is compiled into JavaScript for both the browser and Node.js. The tsc-playground/ folder contains an index.ts file that can be compiled into valid JavaScript.

npm run compile-typescript

This command will output an index.js file. You can play around with different compilation flags. See documentation on that here.

Gimme It

Here's a simple Kata to familiarize yourself with the syntax of the language.

Get all tests passing by removing x from xit and running the tests.

npm test gimme-it/

Two Fer

This challenge requires string interpolation and input/return typing for functions.

npm test two-fer/

*Taken from an Exercism challenge

Space Age

This challenge requires more complex typing.

npm test space-age/

*Taken from an Exercism challenge

AWS Lambda

This folder contains some basic set up for a potential AWS Lambda written in TypeScript.

The goal is to create a deployable package for an AWS Lambda for a supported Node.js runtime.

Let's imagine there's an endpoint site.com/users/{user_id}. This is proxied through AWS API Gateway and parsed into an event for AWS Lambda consumption.

The handler can accept the following event:

{
  ...
  "pathParameters": {
    "user_id": "abc123"
  }
}

and return the response:

{
  "statusCode": 200,
  "body": "{\"user\":{\"id\":\"abc123\",\"email\":\"[email protected]\"}}"
}

The following steps are recommended:

  1. Create a test (TDD!)
  2. Pass the test
    1. Hint: npm test aws-lambda/
  3. Resolve all required types
  4. Compile the TypeScript source code
    1. Hint: npx tsc
  5. Zip up the file for AWS
    1. Hint: chmod +x .pack_for_aws/run

About

learn TypeScript ❤️

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •