docs/libs/typescript.js
function getContextualSignature(node) {
            ts.Debug.assert(node.kind !== 147 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node));
            var type = getContextualTypeForFunctionLikeDeclaration(node);
            if (!type) {
                return undefined;
            }
            if (!(type.flags & 524288 /* Union */)) {
                return getNonGenericSignature(type);
            }
            var signatureList;
            var types = type.types;
            for (var _i = 0, types_12 = types; _i < types_12.length; _i++) {
                var current = types_12[_i];
                var signature = getNonGenericSignature(current);
                if (signature) {
                    if (!signatureList) {
                        // This signature will contribute to contextual union signature
                        signatureList = [signature];
                    }
                    else if (!compareSignaturesIdentical(signatureList[0], signature, /*partialMatch*/ false, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true, compareTypesIdentical)) {
                        // Signatures aren't identical, do not use
                        return undefined;
                    }
                    else {
                        // Use this signature for contextual union signature
                        signatureList.push(signature);
                    }
                }
            }
            // Result is union of signatures collected (return type is union of return types of this signature set)
            var result;
            if (signatureList) {
                result = cloneSignature(signatureList[0]);
                // Clear resolved return type we possibly got from cloneSignature
                result.resolvedReturnType = undefined;
                result.unionSignatures = signatureList;
            }
            return result;
        }
function getContextualSignature(node) {
            ts.Debug.assert(node.kind !== 147 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node));
            var type = getContextualTypeForFunctionLikeDeclaration(node);
            if (!type) {
                return undefined;
            }
            if (!(type.flags & 524288 /* Union */)) {
                return getNonGenericSignature(type);
            }
            var signatureList;
            var types = type.types;
            for (var _i = 0, types_12 = types; _i < types_12.length; _i++) {
                var current = types_12[_i];
                var signature = getNonGenericSignature(current);
                if (signature) {
                    if (!signatureList) {
                        // This signature will contribute to contextual union signature
                        signatureList = [signature];
                    }
                    else if (!compareSignaturesIdentical(signatureList[0], signature, /*partialMatch*/ false, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true, compareTypesIdentical)) {
                        // Signatures aren't identical, do not use
                        return undefined;
                    }
                    else {
                        // Use this signature for contextual union signature
                        signatureList.push(signature);
                    }
                }
            }
            // Result is union of signatures collected (return type is union of return types of this signature set)
            var result;
            if (signatureList) {
                result = cloneSignature(signatureList[0]);
                // Clear resolved return type we possibly got from cloneSignature
                result.resolvedReturnType = undefined;
                result.unionSignatures = signatureList;
            }
            return result;
        }
function getContextualSignature ( node ) { ts . Debug . assert ( node . kind !== 147 /* MethodDeclaration */ || ts . isObjectLiteralMethod ( node ) ) ; var type = getContextualTypeForFunctionLikeDeclaration ( node ) ; if ( ! type ) { return undefined ; } if ( ! ( type . flags & 524288 /* Union */ ) ) { return getNonGenericSignature ( type ) ; } var signatureList ; var types = type . types ; for ( var _i = 0 , types_12 = types ; _i < types_12 . length ; _i ++ ) { var current = types_12 [ _i ] ; var signature = getNonGenericSignature ( current ) ; if ( signature ) { if ( ! signatureList ) { // This signature will contribute to contextual union signature signatureList = [ signature ] ; } else if ( ! compareSignaturesIdentical ( signatureList [ 0 ] , signature , /*partialMatch*/ false , /*ignoreThisTypes*/ true , /*ignoreReturnTypes*/ true , compareTypesIdentical ) ) { // Signatures aren't identical, do not use return undefined ; } else { // Use this signature for contextual union signature signatureList . push ( signature ) ; } } } // Result is union of signatures collected (return type is union of return types of this signature set) var result ; if ( signatureList ) { result = cloneSignature ( signatureList [ 0 ] ) ; // Clear resolved return type we possibly got from cloneSignature result . resolvedReturnType = undefined ; result . unionSignatures = signatureList ; } return result ; }
Return the contextual signature for a given expression node. A contextual type provides a contextual signature if it has a single call signature and if that call signature is non-generic. If the contextual type is a union type, get the signature from each type possible and if they are all identical ignoring their return type, the result is same signature but with return type as union type of return types from these signatures
Return the contextual signature for a given expression node . A contextual type provides a contextual signature if it has a single call signature and if that call signature is non - generic . If the contextual type is a union type get the signature from each type possible and if they are all identical ignoring their return type the result is same signature but with return type as union type of return types from these signatures