demo/typescript.js
function getJsxElementInstanceType(node) {
            // There is no such thing as an instance type for a non-class element. This
            // line shouldn't be hit.
            ts.Debug.assert(!!(getNodeLinks(node).jsxFlags & 4 /* ClassElement */), "Should not call getJsxElementInstanceType on non-class Element");
            var classSymbol = getJsxElementTagSymbol(node);
            if (classSymbol === unknownSymbol) {
                // Couldn't find the class instance type. Error has already been issued
                return anyType;
            }
            var valueType = getTypeOfSymbol(classSymbol);
            if (isTypeAny(valueType)) {
                // Short-circuit if the class tag is using an element type 'any'
                return anyType;
            }
            // Resolve the signatures, preferring constructors
            var signatures = getSignaturesOfType(valueType, 1 /* Construct */);
            if (signatures.length === 0) {
                // No construct signatures, try call signatures
                signatures = getSignaturesOfType(valueType, 0 /* Call */);
                if (signatures.length === 0) {
                    // We found no signatures at all, which is an error
                    error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName));
                    return unknownType;
                }
            }
            var returnType = getUnionType(signatures.map(getReturnTypeOfSignature));
            // Issue an error if this return type isn't assignable to JSX.ElementClass
            var elemClassType = getJsxGlobalElementClassType();
            if (elemClassType) {
                checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements);
            }
            return returnType;
        }
function getJsxElementInstanceType(node) {
            // There is no such thing as an instance type for a non-class element. This
            // line shouldn't be hit.
            ts.Debug.assert(!!(getNodeLinks(node).jsxFlags & 4 /* ClassElement */), "Should not call getJsxElementInstanceType on non-class Element");
            var classSymbol = getJsxElementTagSymbol(node);
            if (classSymbol === unknownSymbol) {
                // Couldn't find the class instance type. Error has already been issued
                return anyType;
            }
            var valueType = getTypeOfSymbol(classSymbol);
            if (isTypeAny(valueType)) {
                // Short-circuit if the class tag is using an element type 'any'
                return anyType;
            }
            // Resolve the signatures, preferring constructors
            var signatures = getSignaturesOfType(valueType, 1 /* Construct */);
            if (signatures.length === 0) {
                // No construct signatures, try call signatures
                signatures = getSignaturesOfType(valueType, 0 /* Call */);
                if (signatures.length === 0) {
                    // We found no signatures at all, which is an error
                    error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName));
                    return unknownType;
                }
            }
            var returnType = getUnionType(signatures.map(getReturnTypeOfSignature));
            // Issue an error if this return type isn't assignable to JSX.ElementClass
            var elemClassType = getJsxGlobalElementClassType();
            if (elemClassType) {
                checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements);
            }
            return returnType;
        }
function getJsxElementInstanceType ( node ) { // There is no such thing as an instance type for a non-class element. This // line shouldn't be hit. ts . Debug . assert ( ! ! ( getNodeLinks ( node ) . jsxFlags & 4 /* ClassElement */ ) , "Should not call getJsxElementInstanceType on non-class Element" ) ; var classSymbol = getJsxElementTagSymbol ( node ) ; if ( classSymbol === unknownSymbol ) { // Couldn't find the class instance type. Error has already been issued return anyType ; } var valueType = getTypeOfSymbol ( classSymbol ) ; if ( isTypeAny ( valueType ) ) { // Short-circuit if the class tag is using an element type 'any' return anyType ; } // Resolve the signatures, preferring constructors var signatures = getSignaturesOfType ( valueType , 1 /* Construct */ ) ; if ( signatures . length === 0 ) { // No construct signatures, try call signatures signatures = getSignaturesOfType ( valueType , 0 /* Call */ ) ; if ( signatures . length === 0 ) { // We found no signatures at all, which is an error error ( node . tagName , ts . Diagnostics . JSX_element_type_0_does_not_have_any_construct_or_call_signatures , ts . getTextOfNode ( node . tagName ) ) ; return unknownType ; } } var returnType = getUnionType ( signatures . map ( getReturnTypeOfSignature ) ) ; // Issue an error if this return type isn't assignable to JSX.ElementClass var elemClassType = getJsxGlobalElementClassType ( ) ; if ( elemClassType ) { checkTypeRelatedTo ( returnType , elemClassType , assignableRelation , node , ts . Diagnostics . JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements ) ; } return returnType ; }
Given a JSX element that is a class element, finds the Element Instance Type. If the
element is not a class element, or the class element type cannot be determined, returns 'undefined'.
For example, in the element <MyClass>, the element instance type is `MyClass` (not `typeof MyClass`).
Given a JSX element that is a class element finds the Element Instance Type . If the element is not a class element or the class element type cannot be determined returns undefined . For example in the element <MyClass > the element instance type is MyClass ( not typeof MyClass ) .