Skip to content
0:00 / 0:00

#typescriptcompiler#turingcompleteness#fizzbuzz

[Online Meetup] Problem Solving Using the TypeScript Compiler - Gal Schlezinger

Wix Engineering Tech Talks

8K subscribers • 2 videos on Hallway

YouTube
  • Recommended by 1 person: 1 in engineering communities.
  • Presented by Gal Schlezinger

Advanced. Deep dive for people who know the field.

1.7K views6 years ago1 recommendation

Programming languagesComputer scienceTypeScriptLanguage design and type systemsComputation and complexity

Gal Schlezinger demonstrates how to solve FizzBuzz entirely within the TypeScript type system using recursive and conditional types.

“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... Watch Gal 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 is 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 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 does 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.

Why it's here

1 person recommends this

What people say. Recommended as a fun and technical demonstration of TypeScript's Turing-complete type system.

u/galstarxin r/typescript • Recommends

Problem Solving with the TypeScript Compiler (Recorded Meetup/Webinar talk)

u/galstarxin r/typescript • Mentions

On “I’m going to give a free and remote talk about problem solving with TypeScript compiler!”

Hey friend. Took almost a month but here's the recording! link to this video