arktypea
arktype9mo ago
jack

type narrow issue on result

i have this really basic function

function validateTokens(
  tokens: Partial<Tokens> | undefined
): Result<typeof Tokens.infer, ArkErrors> {
  const validated = Tokens(tokens);

  if (validated instanceof ArkErrors) { // also tried type.errors
    return err(validated);
  }

  return ok(validated);
}


as far as I know, before upgrading the package, this worked fine more or less

however, now there's simply no type narrowing. validated shows the same type inside of the if check, as well as after it

am i doing something clearly wrong here?
Was this page helpful?