User-474980206 posted
When your promise code calls resolve, it can pass the result for the promise, or a new promise that when resolved returns the value. So if to resolve, your code needs to maker another async call it can return a new promise.
so in example 1, your resolve returns the value.
in example 2, your resolve, resolves the current promise and returns a new pre-resolved promise. While typically the callback to a then return the value, if it’s a promise it supports returning the new promise. You just added extra fluff.
But as storage.get() returns a promise to begin with all the new promise code is extra fluff. It just needs to be
get tokenValid(): Promise<Boolean> {
return this.storage.get('expiresAt')
.then((expiresAt) => {
return(Date.now() < expiresAt);
};
}