Learning to Love TypeScript with React

A presentation at Granite State Code Camp in November 2020 in by Kemet Dugue

Slide 1

Slide 1

Learning to Love TypeScript with React Kemet Dugue kemetdugue kdugue

Slide 2

Slide 2

Agenda 1. Introduction 2. (Brief) Overview of TypeScript 3. Using TypeScript with React 4. TypeScript Usage within Microsoft Teams 5. Deciding to Use TypeScript 6. Resources

Slide 3

Slide 3

About Me ● Interests: lo-fi house, tennis, and cats ● Engineer at ● Related Tech: Since 2016 Since 2017 Since 2020 (<3) Chucky the (unpredictable) orange tabby

Slide 4

Slide 4

(mention opinions and q&A format here….)

Slide 5

Slide 5

(Brief) Overview of TypeScript

Slide 6

Slide 6

Slide 7

Slide 7

What is TypeScript ??? ● Strongly typed ● Compiles to JavaScript ● Superset of JavaScript ● Unique features: interfaces, enumerations, compilation error detection, earlier access to new JS features (optional chaining), and so much more !!

Slide 8

Slide 8

TypeScript Code examples!

Slide 9

Slide 9

Using TypeScript with React

Slide 10

Slide 10

Using TypeScript with React ● All the TypeScript features can be used within a React project: interfaces, enumerations, generics ● Plus more! ○ Improved code navigation (component definition look ups easier!) ○ Improved intellisense (existing methods and fields)

Slide 11

Slide 11

React TypeScript Code examples!

Slide 12

Slide 12

TypeScript Usage Within Microsoft Teams

Slide 13

Slide 13

What is Microsoft Teams ??? ● Collaborative communication tool for work and personal environments ● Central Hub integrated with other Microsoft services (OneDrive, Microsoft Office, Outlook) ● 500+ 3rd party apps (Invision, Polly, Asana, etc) + app developer platform

Slide 14

Slide 14

Some Stats + 115 million DAU (Daily Active Users) + 300,000 organizations (tenants) + 2.9 million meetings per day _______________________________________ Consistency, efficiency, and ship velocity

Slide 15

Slide 15

Client (Oversimplified) ● Angular (2017) → React (new features and conversion) ● React: performant UI rendering, support for mobile (React Native) ● 200+ open source libraries

Slide 16

Slide 16

Benefits of TypeScript w/ React within Teams ● Documentation (prop discoverability, definition look up) ● Narrowed Test Focus ● Frictionless Developing ● Tooling ● Restriction Allows for Consistency and Maintainability

Slide 17

Slide 17

Deciding to use TypeScript

Slide 18

Slide 18

Disadvantages of Using TypeScript ● Bloated Code ● False sense of security (unreliable types) ● Unnecessary typing (guidelines) ● Third party libraries (definitely need a definition file)

Slide 19

Slide 19

Use Cases for TypeScript When To Use When Not To Use Large codebase, large dev team Small codebase Production-scale app Small app, Prototyping, Hacking away No time for tests Fast iterative development process Performance extremely important

Slide 20

Slide 20

Resources ● TypeScript: https://www.typescriptlang.org/docs/ ● Setting Up TypeScript with React: https://create-react-app.dev/docs/adding-typescript/ ● DefinitelyTyped Github Repo: repo for Type Definitions https://github.com/DefinitelyTyped/DefinitelyTyped ● React + TypeScript Cheat sheet: https://github.com/typescript-cheatsheets/react ● TypeScript Deep Dive (book): https://basarat.gitbook.io/typescript/

Slide 21

Slide 21

Thank you Sponsors

Slide 22

Slide 22

Questions????