Skip to content

Re-exporting JSX namespace causes Typescript to crash #30153

@just-boris

Description

@just-boris

Search Terms:

  • Cannot read property 'get' of undefined
  • getJsxLibraryManagedAttributes
  • getJsxManagedAttributesFromLocatedAttributes

Code

index.tsx

import * as MyLib from "./library";

const content = <my-element/>;

library.ts

function createElement(element: string, props: any, ...children: any[]): any {}

namespace JSX {
  export interface IntrinsicElements {
    [key: string]: Record<string, any>;
  }
}

export { createElement, JSX };

Expected behavior:

The following code should compile

Actual behavior:

Compilation fails with the following error in the console:

$ ./node_modules/.bin/tsc -p tsconfig.json
/Users/serdiuk/coding/test/node_modules/typescript/lib/tsc.js:71803
                throw e;
                ^

TypeError: Cannot read property 'get' of undefined
    at getSymbol (/Users/serdiuk/coding/test/node_modules/typescript/lib/tsc.js:26100:38)
    at getJsxLibraryManagedAttributes (/Users/serdiuk/coding/test/node_modules/typescript/lib/tsc.js:40495:36)
    at getJsxManagedAttributesFromLocatedAttributes (/Users/serdiuk/coding/test/node_modules/typescript/lib/tsc.js:39854:30)
    at getJsxPropsTypeFromCallSignature (/Users/serdiuk/coding/test/node_modules/typescript/lib/tsc.js:39809:25)
    at getEffectiveFirstArgumentForJsxSignature (/Users/serdiuk/coding/test/node_modules/typescript/lib/tsc.js:39805:54)
    at resolveJsxOpeningLikeElement (/Users/serdiuk/coding/test/node_modules/typescript/lib/tsc.js:42133:112)
    at resolveSignature (/Users/serdiuk/coding/test/node_modules/typescript/lib/tsc.js:42170:28)
    at getResolvedSignature (/Users/serdiuk/coding/test/node_modules/typescript/lib/tsc.js:42182:26)
    at checkJsxOpeningLikeElementOrOpeningFragment (/Users/serdiuk/coding/test/node_modules/typescript/lib/tsc.js:40630:27)
    at checkJsxSelfClosingElementDeferred (/Users/serdiuk/coding/test/node_modules/typescript/lib/tsc.js:40274:13)

Tested on both v3.3.3333 and 3.4.0-dev

Playground Link:

Not possible to reproduce in playground, since it requires multiple files interaction.
However, I have a simple reproduction here: https://github.com/just-boris/typescript-30153

Related Issues:

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad output

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions