This is pretty confusing indeed. For one, in the promise terminology the "resolved" state does not mean the same as "fulfilled" - a resolved promise can have been resolved with a value so that it eventually rejects. However, I don't think that is what the sentence
Thenable objects that arise along the then()
chain are always resolved
even refers to. "To be resolved" does not mean the state of the thenable object, which is not known in general. Promises do have states that are well-defined and the specification describes how promise objects transition between these states. Thenable objects on the other hand are not characterised by anything apart from their .then()
method, which is called with two callbacks and may do anything it wants. So unless it is a promise, a thenable object does not have a state that distinguishes pending, fulfilled and rejected, and we don't talk about it "being resolved" either.
So what else does the sentence mean then? I don't know the intention of the author but I can make a guess:
- it might mean that any thenable objects arising along the chain are used as the argument to resolve a promise. This is a bit sloppy, as it's the promise which is being
resolve()
d with the thenable, not the thenable object. But still, calling Promise.resolve(thenable)
might be simplified to "resolving the thenable".
- it might mean that the result is extracted. Here the verb "resolve" is not used in its JavaScript-specific meaning, but rather in the general sense - like in "solving an equation" or "resolving a domain name". Not only is a provider
resolve()
ing a Promise
with a value, but a consumer is resolving a promise to a value. This might take multiple steps, but in the end we are getting the eventual result value (or rejection) - not as a return value from a function call, rather as a callback argument in continuation-passing style, but still. In this same sense, we can resolve a thenable object to its result value, and that resolved value is what the chained promise gets settled with.