Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 Jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ function runConsoleTests(defaultReporter, runInParallel) {
}
}

var testTimeout = 20000;
var testTimeout = 22000;
desc("Runs all the tests in parallel using the built run.js file. Optional arguments are: t[ests]=category1|category2|... d[ebug]=true.");
task("runtests-parallel", ["build-rules", "tests", builtLocalDirectory], function () {
runConsoleTests('min', /*runInParallel*/ true);
Expand Down
17 changes: 14 additions & 3 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1473,8 +1473,15 @@ namespace ts {
}
}

/**
* Indicates that a symbol is an alias that does not merge with a local declaration.
*/
function isNonLocalAlias(symbol: Symbol, excludes = SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace) {
return symbol && (symbol.flags & (SymbolFlags.Alias | excludes)) === SymbolFlags.Alias;
}

function resolveSymbol(symbol: Symbol, dontResolveAlias?: boolean): Symbol {
const shouldResolve = !dontResolveAlias && symbol && symbol.flags & SymbolFlags.Alias && !(symbol.flags & (SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace));
const shouldResolve = !dontResolveAlias && isNonLocalAlias(symbol);
return shouldResolve ? resolveAlias(symbol) : symbol;
}

Expand Down Expand Up @@ -12015,7 +12022,9 @@ namespace ts {
return getTypeOfSymbol(symbol);
}

if (symbol.flags & SymbolFlags.Alias && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) {
// We should only mark aliases as referenced if there isn't a local value declaration
// for the symbol.
if (isNonLocalAlias(symbol, /*excludes*/ SymbolFlags.Value) && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) {
markAliasSymbolAsReferenced(symbol);
}

Expand Down Expand Up @@ -22864,7 +22873,9 @@ namespace ts {
node = getParseTreeNode(node, isIdentifier);
if (node) {
const symbol = getReferencedValueSymbol(node);
if (symbol && symbol.flags & SymbolFlags.Alias) {
// We should only get the declaration of an alias if there isn't a local value
// declaration for the symbol
if (isNonLocalAlias(symbol, /*excludes*/ SymbolFlags.Value)) {
return getDeclarationOfAliasSymbol(symbol);
}
}
Expand Down
17 changes: 17 additions & 0 deletions tests/baselines/reference/symbolMergeValueAndImportedType.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//// [tests/cases/compiler/symbolMergeValueAndImportedType.ts] ////

//// [main.ts]
import { X } from "./other";
const X = 42;
console.log('X is ' + X);
//// [other.ts]
export type X = {};

//// [other.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//// [main.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const X = 42;
console.log('X is ' + X);
17 changes: 17 additions & 0 deletions tests/baselines/reference/symbolMergeValueAndImportedType.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
=== tests/cases/compiler/main.ts ===
import { X } from "./other";
>X : Symbol(X, Decl(main.ts, 0, 8), Decl(main.ts, 1, 5))

const X = 42;
>X : Symbol(X, Decl(main.ts, 0, 8), Decl(main.ts, 1, 5))

console.log('X is ' + X);
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>X : Symbol(X, Decl(main.ts, 0, 8), Decl(main.ts, 1, 5))

=== tests/cases/compiler/other.ts ===
export type X = {};
>X : Symbol(X, Decl(other.ts, 0, 0))

21 changes: 21 additions & 0 deletions tests/baselines/reference/symbolMergeValueAndImportedType.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
=== tests/cases/compiler/main.ts ===
import { X } from "./other";
>X : 42

const X = 42;
>X : 42
>42 : 42

console.log('X is ' + X);
>console.log('X is ' + X) : void
>console.log : (message?: any, ...optionalParams: any[]) => void
>console : Console
>log : (message?: any, ...optionalParams: any[]) => void
>'X is ' + X : string
>'X is ' : "X is "
>X : 42

=== tests/cases/compiler/other.ts ===
export type X = {};
>X : X

9 changes: 9 additions & 0 deletions tests/cases/compiler/symbolMergeValueAndImportedType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// @target: es2015
// @module: commonjs
// @lib: es2015,dom
// @filename: main.ts
import { X } from "./other";
const X = 42;
console.log('X is ' + X);
// @filename: other.ts
export type X = {};