docs/libs/typescript.js
function getPromisedType(promise) {
            //
            //  { // promise
            //      then( // thenFunction
            //          onfulfilled: ( // onfulfilledParameterType
            //              value: T // valueParameterType
            //          ) => any
            //      ): any;
            //  }
            //
            if (isTypeAny(promise)) {
                return undefined;
            }
            if (promise.flags & 131072 /* Reference */) {
                if (promise.target === tryGetGlobalPromiseType()
                    || promise.target === getGlobalPromiseLikeType()) {
                    return promise.typeArguments[0];
                }
            }
            var globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType();
            if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) {
                return undefined;
            }
            var thenFunction = getTypeOfPropertyOfType(promise, "then");
            if (!thenFunction || isTypeAny(thenFunction)) {
                return undefined;
            }
            var thenSignatures = getSignaturesOfType(thenFunction, 0 /* Call */);
            if (thenSignatures.length === 0) {
                return undefined;
            }
            var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 131072 /* NEUndefined */);
            if (isTypeAny(onfulfilledParameterType)) {
                return undefined;
            }
            var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* Call */);
            if (onfulfilledParameterSignatures.length === 0) {
                return undefined;
            }
            return getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), /*subtypeReduction*/ true);
        }
function getPromisedType(promise) {
            //
            //  { // promise
            //      then( // thenFunction
            //          onfulfilled: ( // onfulfilledParameterType
            //              value: T // valueParameterType
            //          ) => any
            //      ): any;
            //  }
            //
            if (isTypeAny(promise)) {
                return undefined;
            }
            if (promise.flags & 131072 /* Reference */) {
                if (promise.target === tryGetGlobalPromiseType()
                    || promise.target === getGlobalPromiseLikeType()) {
                    return promise.typeArguments[0];
                }
            }
            var globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType();
            if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) {
                return undefined;
            }
            var thenFunction = getTypeOfPropertyOfType(promise, "then");
            if (!thenFunction || isTypeAny(thenFunction)) {
                return undefined;
            }
            var thenSignatures = getSignaturesOfType(thenFunction, 0 /* Call */);
            if (thenSignatures.length === 0) {
                return undefined;
            }
            var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 131072 /* NEUndefined */);
            if (isTypeAny(onfulfilledParameterType)) {
                return undefined;
            }
            var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* Call */);
            if (onfulfilledParameterSignatures.length === 0) {
                return undefined;
            }
            return getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), /*subtypeReduction*/ true);
        }
function getPromisedType ( promise ) { // //  { // promise //      then( // thenFunction //          onfulfilled: ( // onfulfilledParameterType //              value: T // valueParameterType //          ) => any //      ): any; //  } // if ( isTypeAny ( promise ) ) { return undefined ; } if ( promise . flags & 131072 /* Reference */ ) { if ( promise . target === tryGetGlobalPromiseType ( ) || promise . target === getGlobalPromiseLikeType ( ) ) { return promise . typeArguments [ 0 ] ; } } var globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType ( ) ; if ( globalPromiseLikeType === emptyObjectType || ! isTypeAssignableTo ( promise , globalPromiseLikeType ) ) { return undefined ; } var thenFunction = getTypeOfPropertyOfType ( promise , "then" ) ; if ( ! thenFunction || isTypeAny ( thenFunction ) ) { return undefined ; } var thenSignatures = getSignaturesOfType ( thenFunction , 0 /* Call */ ) ; if ( thenSignatures . length === 0 ) { return undefined ; } var onfulfilledParameterType = getTypeWithFacts ( getUnionType ( ts . map ( thenSignatures , getTypeOfFirstParameterOfSignature ) ) , 131072 /* NEUndefined */ ) ; if ( isTypeAny ( onfulfilledParameterType ) ) { return undefined ; } var onfulfilledParameterSignatures = getSignaturesOfType ( onfulfilledParameterType , 0 /* Call */ ) ; if ( onfulfilledParameterSignatures . length === 0 ) { return undefined ; } return getUnionType ( ts . map ( onfulfilledParameterSignatures , getTypeOfFirstParameterOfSignature ) , /*subtypeReduction*/ true ) ; }
Gets the "promised type" of a promise.
@param type The type of the promise.
@remarks The "promised type" of a type is the type of the "value" parameter of the "onfulfilled" callback.
Gets the promised type of a promise .