title: Creating a fluent, stateful builder using the TypeScript type system
body: <p>I would like to create a builder which can  represent <code>builder.a().b().build()</code> or <code>builder.b().a().build()</code>, but not <code>builder.a().build()</code>, <code>builder.b().build()</code> or <code>builder.a().a().build()</code>, etc.</p>
  
  <p>Obviously I can do the validation in the build method, but I would like the compiler  to hint at this (and for vs code to provide auto complete). I think the TS type system can represent this using mapped types, unions and intersections, but I can't quite figure it out.</p>
  
  <p>Does anyone know how I could do this? </p>