makeTypeHintUnionCodec = (readTable, writeTable) => {
  return makeUnionCodec(
    syrupReader => {
      const typeHint = syrupReader.peekTypeHint();
      const codecRef = readTable[typeHint];
      if (!codecRef) {
        const expected = Object.keys(readTable).join(', ');
        throw Error(
          `Unexpected type hint ${quote(typeHint)}, expected one of ${expected}`,
        );
      }
      const codec = resolveCodec(codecRef, syrupReader);
      return codec;
    },
    value => {
      const codecOrGetter = writeTable[typeof value];
      if (!codecOrGetter) {
        const expected = Object.keys(writeTable).join(', ');
        throw Error(
          `Unexpected value type ${quote(typeof value)}, expected one of ${expected}`,
        );
      }
      const codec = resolveCodec(codecOrGetter, value);
      return codec;
    },
  );
}
@param {TypeHintUnionReadTable} readTable
@param {TypeHintUnionWriteTable} writeTable
@returns {SyrupCodec}