Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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 2 Jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ function runConsoleTests(defaultReporter, runInParallel) {
}
}

var defaultTestTimeout = 20000;
var defaultTestTimeout = 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 17 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 @@ -12020,7 +12027,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 @@ -22926,7 +22935,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 17 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 17 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 21 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 9 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 = {};
Morty Proxy This is a proxified and sanitized view of the page, visit original site.