Merge pull request #1132 from Microsoft/elidedImport

Fix the incorrect eliding of import declaration
This commit is contained in:
Sheetal Nandi
2014-11-12 10:19:18 -08:00
5 changed files with 73 additions and 1 deletions

View File

@@ -4474,7 +4474,7 @@ module ts {
if (symbol.flags & SymbolFlags.Import) {
// Mark the import as referenced so that we emit it in the final .js file.
// exception: identifiers that appear in type queries, const enums, modules that contain only const enums
getSymbolLinks(symbol).referenced = !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveImport(symbol));
getSymbolLinks(symbol).referenced = getSymbolLinks(symbol).referenced || (!isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveImport(symbol)));
}
checkCollisionWithCapturedSuperVariable(node, node);

View File

@@ -50,6 +50,7 @@ var VisualizationModel = (function (_super) {
})(Backbone.Model);
exports.VisualizationModel = VisualizationModel;
//// [aliasUsageInIndexerOfClass_main.js]
var moduleA = require("aliasUsageInIndexerOfClass_moduleA");
var N = (function () {
function N() {
this.x = moduleA;

View File

@@ -0,0 +1,27 @@
//// [tests/cases/compiler/elidingImportNames.ts] ////
//// [elidingImportNames_test.ts]
import a = require('elidingImportNames_main'); // alias used in typeof
var b = a;
var x: typeof a;
import a2 = require('elidingImportNames_main1'); // alias not used in typeof
var b2 = a2;
//// [elidingImportNames_main.ts]
export var main = 10;
//// [elidingImportNames_main1.ts]
export var main = 10;
//// [elidingImportNames_main.js]
exports.main = 10;
//// [elidingImportNames_main1.js]
exports.main = 10;
//// [elidingImportNames_test.js]
var a = require('elidingImportNames_main'); // alias used in typeof
var b = a;
var x;
var a2 = require('elidingImportNames_main1'); // alias not used in typeof
var b2 = a2;

View File

@@ -0,0 +1,29 @@
=== tests/cases/compiler/elidingImportNames_test.ts ===
import a = require('elidingImportNames_main'); // alias used in typeof
>a : typeof a
var b = a;
>b : typeof a
>a : typeof a
var x: typeof a;
>x : typeof a
>a : typeof a
import a2 = require('elidingImportNames_main1'); // alias not used in typeof
>a2 : typeof a2
var b2 = a2;
>b2 : typeof a2
>a2 : typeof a2
=== tests/cases/compiler/elidingImportNames_main.ts ===
export var main = 10;
>main : number
=== tests/cases/compiler/elidingImportNames_main1.ts ===
export var main = 10;
>main : number

View File

@@ -0,0 +1,15 @@
// @module: commonjs
// @Filename: elidingImportNames_test.ts
import a = require('elidingImportNames_main'); // alias used in typeof
var b = a;
var x: typeof a;
import a2 = require('elidingImportNames_main1'); // alias not used in typeof
var b2 = a2;
// @Filename: elidingImportNames_main.ts
export var main = 10;
// @Filename: elidingImportNames_main1.ts
export var main = 10;