Tag the 'react' import as used even under --jsx preserve

Fixes #5865
This commit is contained in:
Ryan Cavanaugh 2015-12-29 14:43:57 -08:00
parent 72bb1d3dec
commit 80a16de570
2 changed files with 7 additions and 9 deletions

View file

@ -8363,14 +8363,12 @@ namespace ts {
checkGrammarJsxElement(node); checkGrammarJsxElement(node);
checkJsxPreconditions(node); checkJsxPreconditions(node);
// If we're compiling under --jsx react, the symbol 'React' should // The symbol 'React' should be marked as 'used' so we don't incorrectly elide its import. And if there
// be marked as 'used' so we don't incorrectly elide its import. And if there // is no 'React' symbol in scope when targeting React emit, we should issue an error.
// is no 'React' symbol in scope, we should issue an error. const reactRefErr = compilerOptions.jsx === JsxEmit.React ? Diagnostics.Cannot_find_name_0 : undefined;
if (compilerOptions.jsx === JsxEmit.React) { const reactSym = resolveName(node.tagName, "React", SymbolFlags.Value, reactRefErr, "React");
const reactSym = resolveName(node.tagName, "React", SymbolFlags.Value, Diagnostics.Cannot_find_name_0, "React"); if (reactSym) {
if (reactSym) { getSymbolLinks(reactSym).referenced = true;
getSymbolLinks(reactSym).referenced = true;
}
} }
const targetAttributesType = getJsxElementAttributesType(node); const targetAttributesType = getJsxElementAttributesType(node);

View file

@ -34,7 +34,7 @@ module M {
//// [test.jsx] //// [test.jsx]
define(["require", "exports", 'react-router'], function (require, exports, ReactRouter) { define(["require", "exports", 'react', 'react-router'], function (require, exports, React, ReactRouter) {
"use strict"; "use strict";
var Route = ReactRouter.Route; var Route = ReactRouter.Route;
var routes1 = <Route />; var routes1 = <Route />;