function checkClassPropertyAccess(node, left, type, prop) {
            var flags = getDeclarationFlagsFromSymbol(prop);
            var declaringClass = getDeclaredTypeOfSymbol(prop.parent);
            if (left.kind === 95 /* SuperKeyword */) {
                var errorNode = node.kind === 166 /* PropertyAccessExpression */ ?
                    node.name :
                    node.right;
                // TS 1.0 spec (April 2014): 4.8.2
                // - In a constructor, instance member function, instance member accessor, or
                //   instance member variable initializer where this references a derived class instance,
                //   a super property access is permitted and must specify a public instance member function of the base class.
                // - In a static member function or static member accessor
                //   where this references the constructor function object of a derived class,
                //   a super property access is permitted and must specify a public static member function of the base class.
                if (getDeclarationKindFromSymbol(prop) !== 143 /* MethodDeclaration */) {
                    // `prop` refers to a *property* declared in the super class
                    // rather than a *method*, so it does not satisfy the above criteria.
                    error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword);
                    return false;
                }
                if (flags & 256 /* Abstract */) {
                    // A method cannot be accessed in a super property access if the method is abstract.
                    // This error could mask a private property access error. But, a member
                    // cannot simultaneously be private and abstract, so this will trigger an
                    // additional error elsewhere.
                    error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass));
                    return false;
                }
            }
            // Public properties are otherwise accessible.
            if (!(flags & (32 /* Private */ | 64 /* Protected */))) {
                return true;
            }
            // Property is known to be private or protected at this point
            // Get the declaring and enclosing class instance types
            var enclosingClassDeclaration = ts.getContainingClass(node);
            var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined;
            // Private property is accessible if declaring and enclosing class are the same
            if (flags & 32 /* Private */) {
                if (declaringClass !== enclosingClass) {
                    error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass));
                    return false;
                }
                return true;
            }
            // Property is known to be protected at this point
            // All protected properties of a supertype are accessible in a super access
            if (left.kind === 95 /* SuperKeyword */) {
                return true;
            }
            // A protected property is accessible in the declaring class and classes derived from it
            if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) {
                error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass));
                return false;
            }
            // No further restrictions for static properties
            if (flags & 128 /* Static */) {
                return true;
            }
            // An instance property must be accessed through an instance of the enclosing class
            if (type.flags & 33554432 /* ThisType */) {
                // get the original type -- represented as the type constraint of the 'this' type
                type = getConstraintOfTypeParameter(type);
            }
            // TODO: why is the first part of this check here?
            if (!(getTargetType(type).flags & (1024 /* Class */ | 2048 /* Interface */) && hasBaseType(type, enclosingClass))) {
                error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass));
                return false;
            }
            return true;
        }
function checkClassPropertyAccess(node, left, type, prop) {
            var flags = getDeclarationFlagsFromSymbol(prop);
            var declaringClass = getDeclaredTypeOfSymbol(prop.parent);
            if (left.kind === 95 /* SuperKeyword */) {
                var errorNode = node.kind === 166 /* PropertyAccessExpression */ ?
                    node.name :
                    node.right;
                // TS 1.0 spec (April 2014): 4.8.2
                // - In a constructor, instance member function, instance member accessor, or
                //   instance member variable initializer where this references a derived class instance,
                //   a super property access is permitted and must specify a public instance member function of the base class.
                // - In a static member function or static member accessor
                //   where this references the constructor function object of a derived class,
                //   a super property access is permitted and must specify a public static member function of the base class.
                if (getDeclarationKindFromSymbol(prop) !== 143 /* MethodDeclaration */) {
                    // `prop` refers to a *property* declared in the super class
                    // rather than a *method*, so it does not satisfy the above criteria.
                    error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword);
                    return false;
                }
                if (flags & 256 /* Abstract */) {
                    // A method cannot be accessed in a super property access if the method is abstract.
                    // This error could mask a private property access error. But, a member
                    // cannot simultaneously be private and abstract, so this will trigger an
                    // additional error elsewhere.
                    error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass));
                    return false;
                }
            }
            // Public properties are otherwise accessible.
            if (!(flags & (32 /* Private */ | 64 /* Protected */))) {
                return true;
            }
            // Property is known to be private or protected at this point
            // Get the declaring and enclosing class instance types
            var enclosingClassDeclaration = ts.getContainingClass(node);
            var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined;
            // Private property is accessible if declaring and enclosing class are the same
            if (flags & 32 /* Private */) {
                if (declaringClass !== enclosingClass) {
                    error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass));
                    return false;
                }
                return true;
            }
            // Property is known to be protected at this point
            // All protected properties of a supertype are accessible in a super access
            if (left.kind === 95 /* SuperKeyword */) {
                return true;
            }
            // A protected property is accessible in the declaring class and classes derived from it
            if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) {
                error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass));
                return false;
            }
            // No further restrictions for static properties
            if (flags & 128 /* Static */) {
                return true;
            }
            // An instance property must be accessed through an instance of the enclosing class
            if (type.flags & 33554432 /* ThisType */) {
                // get the original type -- represented as the type constraint of the 'this' type
                type = getConstraintOfTypeParameter(type);
            }
            // TODO: why is the first part of this check here?
            if (!(getTargetType(type).flags & (1024 /* Class */ | 2048 /* Interface */) && hasBaseType(type, enclosingClass))) {
                error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass));
                return false;
            }
            return true;
        }
function checkClassPropertyAccess ( node , left , type , prop ) { var flags = getDeclarationFlagsFromSymbol ( prop ) ; var declaringClass = getDeclaredTypeOfSymbol ( prop . parent ) ; if ( left . kind === 95 /* SuperKeyword */ ) { var errorNode = node . kind === 166 /* PropertyAccessExpression */ ? node . name : node . right ; // TS 1.0 spec (April 2014): 4.8.2 // - In a constructor, instance member function, instance member accessor, or //   instance member variable initializer where this references a derived class instance, //   a super property access is permitted and must specify a public instance member function of the base class. // - In a static member function or static member accessor //   where this references the constructor function object of a derived class, //   a super property access is permitted and must specify a public static member function of the base class. if ( getDeclarationKindFromSymbol ( prop ) !== 143 /* MethodDeclaration */ ) { // `prop` refers to a *property* declared in the super class // rather than a *method*, so it does not satisfy the above criteria. error ( errorNode , ts . Diagnostics . Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword ) ; return false ; } if ( flags & 256 /* Abstract */ ) { // A method cannot be accessed in a super property access if the method is abstract. // This error could mask a private property access error. But, a member // cannot simultaneously be private and abstract, so this will trigger an // additional error elsewhere. error ( errorNode , ts . Diagnostics . Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression , symbolToString ( prop ) , typeToString ( declaringClass ) ) ; return false ; } } // Public properties are otherwise accessible. if ( ! ( flags & ( 32 /* Private */ | 64 /* Protected */ ) ) ) { return true ; } // Property is known to be private or protected at this point // Get the declaring and enclosing class instance types var enclosingClassDeclaration = ts . getContainingClass ( node ) ; var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol ( getSymbolOfNode ( enclosingClassDeclaration ) ) : undefined ; // Private property is accessible if declaring and enclosing class are the same if ( flags & 32 /* Private */ ) { if ( declaringClass !== enclosingClass ) { error ( node , ts . Diagnostics . Property_0_is_private_and_only_accessible_within_class_1 , symbolToString ( prop ) , typeToString ( declaringClass ) ) ; return false ; } return true ; } // Property is known to be protected at this point // All protected properties of a supertype are accessible in a super access if ( left . kind === 95 /* SuperKeyword */ ) { return true ; } // A protected property is accessible in the declaring class and classes derived from it if ( ! enclosingClass || ! hasBaseType ( enclosingClass , declaringClass ) ) { error ( node , ts . Diagnostics . Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses , symbolToString ( prop ) , typeToString ( declaringClass ) ) ; return false ; } // No further restrictions for static properties if ( flags & 128 /* Static */ ) { return true ; } // An instance property must be accessed through an instance of the enclosing class if ( type . flags & 33554432 /* ThisType */ ) { // get the original type -- represented as the type constraint of the 'this' type type = getConstraintOfTypeParameter ( type ) ; } // TODO: why is the first part of this check here? if ( ! ( getTargetType ( type ) . flags & ( 1024 /* Class */ | 2048 /* Interface */ ) && hasBaseType ( type , enclosingClass ) ) ) { error ( node , ts . Diagnostics . Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1 , symbolToString ( prop ) , typeToString ( enclosingClass ) ) ; return false ; } return true ; }
Check whether the requested property access is valid.
Returns true if node is a valid property access, and false otherwise.
@param node The node to be checked.
@param left The left hand side of the property access (e.g.: the super in `super.foo`).
@param type The type of left.
@param prop The symbol for the right hand side of the property access.
Check whether the requested property access is valid . Returns true if node is a valid property access and false otherwise .