mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-07-02 14:48:32 -05:00
Merge pull request #1132 from Microsoft/elidedImport
Fix the incorrect eliding of import declaration
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
27
tests/baselines/reference/elidingImportNames.js
Normal file
27
tests/baselines/reference/elidingImportNames.js
Normal 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;
|
||||
29
tests/baselines/reference/elidingImportNames.types
Normal file
29
tests/baselines/reference/elidingImportNames.types
Normal 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
|
||||
|
||||
15
tests/cases/compiler/elidingImportNames.ts
Normal file
15
tests/cases/compiler/elidingImportNames.ts
Normal 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;
|
||||
Reference in New Issue
Block a user