Skip to content

Problem Solving using the TypeScript Compiler

Photo of Morad Stern
Hosted By
Morad S.
Problem Solving using the TypeScript Compiler

Details

Please notice:

  • The meetup will be online and the talk will be in English.
  • Link to the event will only be visible to people who RSVP.
  • The online meetup will be help on April 2, 16:00, Israel Time Zone, GMT +3:00

// Problem Solving using the TypeScript Compiler - Gal Schlezinger

“Here’s a simple coding task,” the interviewer says — “You can use any language you want”. “Any language..?”, I smirked. Little did he know that TypeScript’s type system is Turing complete...

Let’s reveal how to solve FizzBuzz in the type system itself, by getting the solution with no runtime code whatsoever!

TypeScript’s type system is very powerful and can express very exciting things. This technical-yet-humorous talk will be done almost entirely hands-on, in an editor, inside a .d.ts file. By using a certain amount of generics, recursive types, and conditional types, we will code together:

type FizzBuzzNth that resolves into a literal of “Fizz” for multiplications of 3, “Buzz” for multiplications of 5, and “FizzBuzz” for multiplications of 15. Otherwise, resolves into the given N

  • A small “test framework” to test that our types work correctly
  • Logic constructs, such as And and If
  • Linked lists
  • …all that, without running our code once — TypeScript’s language server will do it for us.

// Bio:
Heavy Rocker from Israel, Gal develops performance tools and developer tools for front-end developers at Wix. Believes in open source. Plays punk rock since high school. Interested in type systems and type-safe languages.

Follow Gal on Twitter: @galstar

https://twitter.com/galstar

Photo of Meetups at Wix group
Meetups at Wix
See more events
Online event
This event has passed