Slide 1

Slide 1 text

STATIC TYPECHECKING IN JAVASCRIPT - Tejas Bubane (@tejasbubane)

Slide 2

Slide 2 text

Dynamically Typed vs Statically Typed

Slide 3

Slide 3 text

DYNAMICALLY TYPED ▸ No type definitions to write ▸Throws errors at runtime ▸ e.g. Ruby, Javascript ▸Ease of development, no restrictions ▸ Typechecking at runtime

Slide 4

Slide 4 text

STATICALLY TYPED ▸Types defined explicitly & checked at compile time ▸Catch errors at compile time ▸e.g. Java, Scala, Swift, etc. ▸little overhead of writing types all the time

Slide 5

Slide 5 text

WHY JAVASCRIPT ??? ▸ 1 == “1” => true ▸ true == 1 => true ▸ null == undefined => true ▸ a = 1; b = “1”; a + b; => “11” ▸ this => ???? ▸ typeof NaN => ‘number’ ▸ “1” - “2” => -1 COERCION, GLOBAL VARIABLES, CHANGING SCOPES…..

Slide 6

Slide 6 text

#TRIVIA

Slide 7

Slide 7 text

WHY JAVASCRIPT ?

Slide 8

Slide 8 text

ALTERNATIVES

Slide 9

Slide 9 text

▸ “Understands” Javascript, ES6 and React code ▸ Type inference ▸ Type “flows” through the code

Slide 10

Slide 10 text

FLOW BASIC TYPES

Slide 11

Slide 11 text

FUNCTIONS

Slide 12

Slide 12 text

UNION TYPES

Slide 13

Slide 13 text

MAYBE TYPES

Slide 14

Slide 14 text

INTERFACES

Slide 15

Slide 15 text

INTERFACES

Slide 16

Slide 16 text

IMPORTING & EXPORTING TYPES

Slide 17

Slide 17 text

EXTERNAL TYPEDEFINITIONS ▸ For external dependencies ▸ https://github.com/flowtype/flow-typed/tree/master/ definitions/npm

Slide 18

Slide 18 text

CODE WALKTHROUGH ▸ React Todo Application using FlowTypes ▸ App demo ▸ Github Code

Slide 19

Slide 19 text

QUESTIONS ??

Slide 20

Slide 20 text

THANK YOU