Skip to content

Allow the use of a module JSX namespace #8757

@ceymard

Description

@ceymard

Since JSX is a global namespace, it is not possible to use typings declared in a module for its Element or ElementClass.

When writing a module, it would then be convenient to write something like ;

import {MyEltType, JSX}  from 'my-custom-jsx-lib'

var myelt = <div> ...</div>

and have typescript check Element, ElementClass and so on on its local JSX instance.

Also, when not providing any JSX namespace but having a factory that has a return type, the compiler crashes nastily with a

/usr/lib/node_modules/typescript/lib/tsc.js:33078
                throw e;
                ^

TypeError: Cannot read property 'flags' of undefined
    at isRelatedTo (/usr/lib/node_modules/typescript/lib/tsc.js:16013:32)
    at checkTypeRelatedTo (/usr/lib/node_modules/typescript/lib/tsc.js:15941:26)
    at checkTypeAssignableTo (/usr/lib/node_modules/typescript/lib/tsc.js:15819:20)
    at isTypeAssignableTo (/usr/lib/node_modules/typescript/lib/tsc.js:15813:20)
    at getJsxElementAttributesType (/usr/lib/node_modules/typescript/lib/tsc.js:18463:47)
    at checkJsxOpeningLikeElement (/usr/lib/node_modules/typescript/lib/tsc.js:18564:40)
    at checkJsxSelfClosingElement (/usr/lib/node_modules/typescript/lib/tsc.js:18265:13)
    at checkExpressionWorker (/usr/lib/node_modules/typescript/lib/tsc.js:20439:28)
    at checkExpression (/usr/lib/node_modules/typescript/lib/tsc.js:20349:42)
    at checkExpressionCached (/usr/lib/node_modules/typescript/lib/tsc.js:20310:38)

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions