function checkVariableLikeDeclaration(node) {
            checkDecorators(node);
            checkSourceElement(node.type);
            // For a computed property, just check the initializer and exit
            // Do not use hasDynamicName here, because that returns false for well known symbols.
            // We want to perform checkComputedPropertyName for all computed properties, including
            // well known symbols.
            if (node.name.kind === 136 /* ComputedPropertyName */) {
                checkComputedPropertyName(node.name);
                if (node.initializer) {
                    checkExpressionCached(node.initializer);
                }
            }
            // For a binding pattern, check contained binding elements
            if (ts.isBindingPattern(node.name)) {
                ts.forEach(node.name.elements, checkSourceElement);
            }
            // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body
            if (node.initializer && ts.getRootDeclaration(node).kind === 138 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) {
                error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation);
                return;
            }
            // For a binding pattern, validate the initializer and exit
            if (ts.isBindingPattern(node.name)) {
                if (node.initializer) {
                    checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined);
                    checkParameterInitializer(node);
                }
                return;
            }
            var symbol = getSymbolOfNode(node);
            var type = getTypeOfVariableOrParameterOrProperty(symbol);
            if (node === symbol.valueDeclaration) {
                // Node is the primary declaration of the symbol, just validate the initializer
                if (node.initializer) {
                    checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined);
                    checkParameterInitializer(node);
                }
            }
            else {
                // Node is a secondary declaration, check that type is identical to primary declaration and check that
                // initializer is consistent with type associated with the node
                var declarationType = getWidenedTypeForVariableLikeDeclaration(node);
                if (type !== unknownType && declarationType !== unknownType && !isTypeIdenticalTo(type, declarationType)) {
                    error(node.name, ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, ts.declarationNameToString(node.name), typeToString(type), typeToString(declarationType));
                }
                if (node.initializer) {
                    checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined);
                }
            }
            if (node.kind !== 141 /* PropertyDeclaration */ && node.kind !== 140 /* PropertySignature */) {
                // We know we don't have a binding pattern or computed name here
                checkExportsOnMergedDeclarations(node);
                if (node.kind === 211 /* VariableDeclaration */ || node.kind === 163 /* BindingElement */) {
                    checkVarDeclaredNamesNotShadowed(node);
                }
                checkCollisionWithCapturedSuperVariable(node, node.name);
                checkCollisionWithCapturedThisVariable(node, node.name);
                checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
            }
        }
function checkVariableLikeDeclaration(node) {
            checkDecorators(node);
            checkSourceElement(node.type);
            // For a computed property, just check the initializer and exit
            // Do not use hasDynamicName here, because that returns false for well known symbols.
            // We want to perform checkComputedPropertyName for all computed properties, including
            // well known symbols.
            if (node.name.kind === 136 /* ComputedPropertyName */) {
                checkComputedPropertyName(node.name);
                if (node.initializer) {
                    checkExpressionCached(node.initializer);
                }
            }
            // For a binding pattern, check contained binding elements
            if (ts.isBindingPattern(node.name)) {
                ts.forEach(node.name.elements, checkSourceElement);
            }
            // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body
            if (node.initializer && ts.getRootDeclaration(node).kind === 138 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) {
                error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation);
                return;
            }
            // For a binding pattern, validate the initializer and exit
            if (ts.isBindingPattern(node.name)) {
                if (node.initializer) {
                    checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined);
                    checkParameterInitializer(node);
                }
                return;
            }
            var symbol = getSymbolOfNode(node);
            var type = getTypeOfVariableOrParameterOrProperty(symbol);
            if (node === symbol.valueDeclaration) {
                // Node is the primary declaration of the symbol, just validate the initializer
                if (node.initializer) {
                    checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined);
                    checkParameterInitializer(node);
                }
            }
            else {
                // Node is a secondary declaration, check that type is identical to primary declaration and check that
                // initializer is consistent with type associated with the node
                var declarationType = getWidenedTypeForVariableLikeDeclaration(node);
                if (type !== unknownType && declarationType !== unknownType && !isTypeIdenticalTo(type, declarationType)) {
                    error(node.name, ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, ts.declarationNameToString(node.name), typeToString(type), typeToString(declarationType));
                }
                if (node.initializer) {
                    checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined);
                }
            }
            if (node.kind !== 141 /* PropertyDeclaration */ && node.kind !== 140 /* PropertySignature */) {
                // We know we don't have a binding pattern or computed name here
                checkExportsOnMergedDeclarations(node);
                if (node.kind === 211 /* VariableDeclaration */ || node.kind === 163 /* BindingElement */) {
                    checkVarDeclaredNamesNotShadowed(node);
                }
                checkCollisionWithCapturedSuperVariable(node, node.name);
                checkCollisionWithCapturedThisVariable(node, node.name);
                checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
            }
        }
function checkVariableLikeDeclaration ( node ) { checkDecorators ( node ) ; checkSourceElement ( node . type ) ; // For a computed property, just check the initializer and exit // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. if ( node . name . kind === 136 /* ComputedPropertyName */ ) { checkComputedPropertyName ( node . name ) ; if ( node . initializer ) { checkExpressionCached ( node . initializer ) ; } } // For a binding pattern, check contained binding elements if ( ts . isBindingPattern ( node . name ) ) { ts . forEach ( node . name . elements , checkSourceElement ) ; } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body if ( node . initializer && ts . getRootDeclaration ( node ) . kind === 138 /* Parameter */ && ts . nodeIsMissing ( ts . getContainingFunction ( node ) . body ) ) { error ( node , ts . Diagnostics . A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation ) ; return ; } // For a binding pattern, validate the initializer and exit if ( ts . isBindingPattern ( node . name ) ) { if ( node . initializer ) { checkTypeAssignableTo ( checkExpressionCached ( node . initializer ) , getWidenedTypeForVariableLikeDeclaration ( node ) , node , /*headMessage*/ undefined ) ; checkParameterInitializer ( node ) ; } return ; } var symbol = getSymbolOfNode ( node ) ; var type = getTypeOfVariableOrParameterOrProperty ( symbol ) ; if ( node === symbol . valueDeclaration ) { // Node is the primary declaration of the symbol, just validate the initializer if ( node . initializer ) { checkTypeAssignableTo ( checkExpressionCached ( node . initializer ) , type , node , /*headMessage*/ undefined ) ; checkParameterInitializer ( node ) ; } } else { // Node is a secondary declaration, check that type is identical to primary declaration and check that // initializer is consistent with type associated with the node var declarationType = getWidenedTypeForVariableLikeDeclaration ( node ) ; if ( type !== unknownType && declarationType !== unknownType && ! isTypeIdenticalTo ( type , declarationType ) ) { error ( node . name , ts . Diagnostics . Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2 , ts . declarationNameToString ( node . name ) , typeToString ( type ) , typeToString ( declarationType ) ) ; } if ( node . initializer ) { checkTypeAssignableTo ( checkExpressionCached ( node . initializer ) , declarationType , node , /*headMessage*/ undefined ) ; } } if ( node . kind !== 141 /* PropertyDeclaration */ && node . kind !== 140 /* PropertySignature */ ) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations ( node ) ; if ( node . kind === 211 /* VariableDeclaration */ || node . kind === 163 /* BindingElement */ ) { checkVarDeclaredNamesNotShadowed ( node ) ; } checkCollisionWithCapturedSuperVariable ( node , node . name ) ; checkCollisionWithCapturedThisVariable ( node , node . name ) ; checkCollisionWithRequireExportsInGeneratedCode ( node , node . name ) ; } }
Check variable, parameter, or property declaration
Check variable parameter or property declaration