diff --git a/docs/api.md b/docs/api.md
index 9bcf3e2cb..0bd5d9e16 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -1338,9 +1338,21 @@ the resulting error and output will not be passed to the `parse()` callback (the
***Note:*** `parse()` should be called only once when [`command()`](#command) is called with a handler
returning a promise. If your use case requires `parse()` to be called several times, any asynchronous
-operation performed in a command handler should not result in the handler returning a promise
+operation performed in a command handler should not result in the handler returning a promise.
-.parsed
+.parseAsync([args], [context], [parseCallback])
+------------
+
+Identical to `.parse()` except always returns a promise for a parsed argv
+object, regardless of whether an async builder, handler, or middleware is used.
+
+.parseSync([args], [context], [parseCallback])
+------------
+
+Identical to `.parse()` except an exception is thrown if an asynchronous
+builder, handler, or middleware is used.
+
+.parsed [DEPRECATED]
------------
If the arguments have not been parsed, this property is `false`.
diff --git a/lib/yargs-factory.ts b/lib/yargs-factory.ts
index 54c1c3ba8..5ef10e8f3 100644
--- a/lib/yargs-factory.ts
+++ b/lib/yargs-factory.ts
@@ -1082,6 +1082,31 @@ export class YargsInstance {
}
return parsed;
}
+ parseAsync(
+ args?: string | string[],
+ shortCircuit?: object | ParseCallback | boolean,
+ _parseFn?: ParseCallback
+ ): Promise {
+ const maybePromise = this.parse(args, shortCircuit, _parseFn);
+ if (!isPromise(maybePromise)) {
+ return Promise.resolve(maybePromise);
+ } else {
+ return maybePromise;
+ }
+ }
+ parseSync(
+ args?: string | string[],
+ shortCircuit?: object | ParseCallback | boolean,
+ _parseFn?: ParseCallback
+ ): Arguments {
+ const maybePromise = this.parse(args, shortCircuit, _parseFn);
+ if (isPromise(maybePromise)) {
+ throw new YError(
+ '.parseSync() must not be used with asynchronous builders, handlers, or middleware'
+ );
+ }
+ return maybePromise;
+ }
parserConfiguration(config: Configuration) {
argsert('