You're Not My Type

 

 

Ben Paddock

@_pads

Hello!

 

  • Software Developer @ Talis
  • Working on Angular 5 (\w TypeScript) project

Coming Up

 

  • JS type system primer
  • Why care about types?
  • TypeScript

Types of Types

 

  • Dynamic/loose typing
  • Static/strict typing

Dynamic Typing

let string = 'a string'; // valid
string = true; // yup, valid
string = 0; // still valid
string = {}; // you guessed it...

Primitive Types

 

  • null
  • undefined
  • Boolean
  • Number
  • String
  • Symbol (ES6+)

Function

 

const foo = function() { 
  console.log('bar'); 
};

typeof foo
"function"

Object

 

typeof {}
"object"
typeof []
"object"
typeof new Map()
"object"

Why Care about Types?

 

  • Bugs
  • Documentation
  • Fewer tests

Enter TypeScript

 

  • Superset language
  • Pre-runtime enforcement
  • Compiles to JS
  • Enforce as much or as little as you like

Features

 

  • Static/inference typing
  • Custom types
  • Intersection/union types
  • Interfaces
  • Enums
  • Generics (<T>)
  • OO features
    • public/protected/private
    • abstract classes

Let's Play!

You're Not My Type

By Ben Paddock

You're Not My Type

The first in a series about JavaScript testing.

  • 279