Introduction to TypeScript

What is it?

Why should I care?

How do I use it?

Who is this guy?

Craig Burton

Software Engineer

PlatformQ

I make web stuff.

What is TypeScript?

A superset of JavaScript

Includes tomorrow's JS features today

What is TypeScript?

Adds static typing- A Good Thing™

        
          // JavaScript
          function findOne(data, config){ 
            // What is data? What is config? BOB! How many 
            // times have I told you to document your code?!
            /* ... */ 
          }
        
        
          // TypeScript
          function findOne(data: Person[], config: SearchConfig): Person { 
            // We know what data and config are, super helpful!
            // This can be even cooler. Just wait till the live demo!
            /* ... */ 
          }
        
      

Why should I care?

JavaScript was never designed for large apps.

Documentation takes time. (both writing and reading)

Developers are *lazy. .  . except for me. I'm a go-getter!

*Really, we're just very busy.

The available tooling is amazing.

How do I use it?

Install typescript:

          $ npm install typescript
        

You write JavaScript.

          
            function foo(a){ /* do stuff */ }
          
        

How do I use it?

And then you add type annotations.

          
            function foo(a: string){ /* do stuff */ }
          
        

Win.

Live demo!

Conclusion

TypeScript is a really powerful extension of JavaScript.

It can be used anywhere JS can be, because it compiles to JS.

It adds a huge degree of maintainability to large apps.

It speeds up development.

Thank you

Craig Burton

Software Engineer

PlatformQ