docs/libs/typescript.js
function getContextuallyTypedParameterType(parameter) {
            var func = parameter.parent;
            if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
                var iife = ts.getImmediatelyInvokedFunctionExpression(func);
                if (iife) {
                    var indexOfParameter = ts.indexOf(func.parameters, parameter);
                    if (iife.arguments && indexOfParameter < iife.arguments.length) {
                        if (parameter.dotDotDotToken) {
                            var restTypes = [];
                            for (var i = indexOfParameter; i < iife.arguments.length; i++) {
                                restTypes.push(getTypeOfExpression(iife.arguments[i]));
                            }
                            return createArrayType(getUnionType(restTypes));
                        }
                        var links = getNodeLinks(iife);
                        var cached = links.resolvedSignature;
                        links.resolvedSignature = anySignature;
                        var type = checkExpression(iife.arguments[indexOfParameter]);
                        links.resolvedSignature = cached;
                        return type;
                    }
                }
                var contextualSignature = getContextualSignature(func);
                if (contextualSignature) {
                    var funcHasRestParameters = ts.hasRestParameter(func);
                    var len = func.parameters.length - (funcHasRestParameters ? 1 : 0);
                    var indexOfParameter = ts.indexOf(func.parameters, parameter);
                    if (indexOfParameter < len) {
                        return getTypeAtPosition(contextualSignature, indexOfParameter);
                    }
                    // If last parameter is contextually rest parameter get its type
                    if (funcHasRestParameters &&
                        indexOfParameter === (func.parameters.length - 1) &&
                        isRestParameterIndex(contextualSignature, func.parameters.length - 1)) {
                        return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters));
                    }
                }
            }
            return undefined;
        }
function getContextuallyTypedParameterType(parameter) {
            var func = parameter.parent;
            if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
                var iife = ts.getImmediatelyInvokedFunctionExpression(func);
                if (iife) {
                    var indexOfParameter = ts.indexOf(func.parameters, parameter);
                    if (iife.arguments && indexOfParameter < iife.arguments.length) {
                        if (parameter.dotDotDotToken) {
                            var restTypes = [];
                            for (var i = indexOfParameter; i < iife.arguments.length; i++) {
                                restTypes.push(getTypeOfExpression(iife.arguments[i]));
                            }
                            return createArrayType(getUnionType(restTypes));
                        }
                        var links = getNodeLinks(iife);
                        var cached = links.resolvedSignature;
                        links.resolvedSignature = anySignature;
                        var type = checkExpression(iife.arguments[indexOfParameter]);
                        links.resolvedSignature = cached;
                        return type;
                    }
                }
                var contextualSignature = getContextualSignature(func);
                if (contextualSignature) {
                    var funcHasRestParameters = ts.hasRestParameter(func);
                    var len = func.parameters.length - (funcHasRestParameters ? 1 : 0);
                    var indexOfParameter = ts.indexOf(func.parameters, parameter);
                    if (indexOfParameter < len) {
                        return getTypeAtPosition(contextualSignature, indexOfParameter);
                    }
                    // If last parameter is contextually rest parameter get its type
                    if (funcHasRestParameters &&
                        indexOfParameter === (func.parameters.length - 1) &&
                        isRestParameterIndex(contextualSignature, func.parameters.length - 1)) {
                        return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters));
                    }
                }
            }
            return undefined;
        }
function getContextuallyTypedParameterType ( parameter ) { var func = parameter . parent ; if ( isContextSensitiveFunctionOrObjectLiteralMethod ( func ) ) { var iife = ts . getImmediatelyInvokedFunctionExpression ( func ) ; if ( iife ) { var indexOfParameter = ts . indexOf ( func . parameters , parameter ) ; if ( iife . arguments && indexOfParameter < iife . arguments . length ) { if ( parameter . dotDotDotToken ) { var restTypes = [ ] ; for ( var i = indexOfParameter ; i < iife . arguments . length ; i ++ ) { restTypes . push ( getTypeOfExpression ( iife . arguments [ i ] ) ) ; } return createArrayType ( getUnionType ( restTypes ) ) ; } var links = getNodeLinks ( iife ) ; var cached = links . resolvedSignature ; links . resolvedSignature = anySignature ; var type = checkExpression ( iife . arguments [ indexOfParameter ] ) ; links . resolvedSignature = cached ; return type ; } } var contextualSignature = getContextualSignature ( func ) ; if ( contextualSignature ) { var funcHasRestParameters = ts . hasRestParameter ( func ) ; var len = func . parameters . length - ( funcHasRestParameters ? 1 : 0 ) ; var indexOfParameter = ts . indexOf ( func . parameters , parameter ) ; if ( indexOfParameter < len ) { return getTypeAtPosition ( contextualSignature , indexOfParameter ) ; } // If last parameter is contextually rest parameter get its type if ( funcHasRestParameters && indexOfParameter === ( func . parameters . length - 1 ) && isRestParameterIndex ( contextualSignature , func . parameters . length - 1 ) ) { return getTypeOfSymbol ( ts . lastOrUndefined ( contextualSignature . parameters ) ) ; } } } return undefined ; }
Return contextual type of parameter or undefined if no contextual type is available
Return contextual type of parameter or undefined if no contextual type is available