Skip to content

Imports being dropped when referenced in JSX #13676

Description

@ds300

TypeScript Version: 2.2.0-dev.20170125

Code (compiler test case)

//@module: es6
//@moduleResolution: node
//@target: es6
//@noImplicitAny: false
//@allowSyntheticDefaultImports: true
//@allowJs: true
//@jsx: react
//@outDir: "build"

//@filename: react.d.ts
export = React;
export as namespace React;

declare namespace React {

    function createClass(spec: any): ClassicComponentClass;

    interface ClassicComponentClass {
        new (props?: any): ClassicComponentClass;
    }
}

declare global {
    namespace JSX {
        interface ElementAttributesProperty { }
    }
}


//@filename: src/components/TabBar.js
export default React.createClass({
  render() {
    return (
      null
    );
  }
});

//@filename: src/modules/navigation/NavigationView.js
import TabBar from '../../components/TabBar';
import {layout} from '../../utils/theme';
const x = <TabBar height={layout.footerHeight} />;

Expected behavior:

NavigationView.js should look like:

import TabBar from '../../components/TabBar';
import {layout} from '../../utils/theme';
const x = React.createElement(TabBar, { height: layout.footerHeight });

Actual behavior:

The layout import disappears and we are left with:

import TabBar from '../../components/TabBar';
const x = React.createElement(TabBar, { height: layout.footerHeight });

Took me a long time to develop this test case. Not sure if it's totally minimal, but hope it helps :)

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issueHigh Priority

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions