Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions tests/baselines/reference/aliasUsageInIndexerOfClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
27 changes: 27 additions & 0 deletions tests/baselines/reference/elidingImportNames.js
Original file line number Diff line number Diff line change
@@ -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 changes: 29 additions & 0 deletions tests/baselines/reference/elidingImportNames.types
Original file line number Diff line number Diff line change
@@ -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 changes: 15 additions & 0 deletions tests/cases/compiler/elidingImportNames.ts
Original file line number Diff line number Diff line change
@@ -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;