Fix #4274: When collecting linked aliases use SymbolFlags.Alias to capture local aliases as well
This commit is contained in:
parent
f92aa8681a
commit
fafd497124
11 changed files with 204 additions and 3 deletions
|
@ -2175,10 +2175,13 @@ namespace ts {
|
||||||
function collectLinkedAliases(node: Identifier): Node[] {
|
function collectLinkedAliases(node: Identifier): Node[] {
|
||||||
let exportSymbol: Symbol;
|
let exportSymbol: Symbol;
|
||||||
if (node.parent && node.parent.kind === SyntaxKind.ExportAssignment) {
|
if (node.parent && node.parent.kind === SyntaxKind.ExportAssignment) {
|
||||||
exportSymbol = resolveName(node.parent, node.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, Diagnostics.Cannot_find_name_0, node);
|
exportSymbol = resolveName(node.parent, node.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, Diagnostics.Cannot_find_name_0, node);
|
||||||
}
|
}
|
||||||
else if (node.parent.kind === SyntaxKind.ExportSpecifier) {
|
else if (node.parent.kind === SyntaxKind.ExportSpecifier) {
|
||||||
exportSymbol = getTargetOfExportSpecifier(<ExportSpecifier>node.parent);
|
let exportSpecifier = <ExportSpecifier>node.parent;
|
||||||
|
exportSymbol = (<ExportDeclaration>exportSpecifier.parent.parent).moduleSpecifier ?
|
||||||
|
getExternalModuleMember(<ExportDeclaration>exportSpecifier.parent.parent, exportSpecifier) :
|
||||||
|
resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias);
|
||||||
}
|
}
|
||||||
let result: Node[] = [];
|
let result: Node[] = [];
|
||||||
if (exportSymbol) {
|
if (exportSymbol) {
|
||||||
|
|
|
@ -715,6 +715,7 @@ namespace ts.formatting {
|
||||||
case SyntaxKind.TypeReference:
|
case SyntaxKind.TypeReference:
|
||||||
case SyntaxKind.TypeAssertionExpression:
|
case SyntaxKind.TypeAssertionExpression:
|
||||||
case SyntaxKind.ClassDeclaration:
|
case SyntaxKind.ClassDeclaration:
|
||||||
|
case SyntaxKind.ClassExpression:
|
||||||
case SyntaxKind.InterfaceDeclaration:
|
case SyntaxKind.InterfaceDeclaration:
|
||||||
case SyntaxKind.FunctionDeclaration:
|
case SyntaxKind.FunctionDeclaration:
|
||||||
case SyntaxKind.FunctionExpression:
|
case SyntaxKind.FunctionExpression:
|
||||||
|
@ -725,6 +726,7 @@ namespace ts.formatting {
|
||||||
case SyntaxKind.ConstructSignature:
|
case SyntaxKind.ConstructSignature:
|
||||||
case SyntaxKind.CallExpression:
|
case SyntaxKind.CallExpression:
|
||||||
case SyntaxKind.NewExpression:
|
case SyntaxKind.NewExpression:
|
||||||
|
case SyntaxKind.ExpressionWithTypeArguments:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
//// [tests/cases/compiler/declarationEmit_exportAssignment.ts] ////
|
||||||
|
|
||||||
|
//// [utils.ts]
|
||||||
|
|
||||||
|
export function foo() { }
|
||||||
|
export function bar() { }
|
||||||
|
export interface Buzz { }
|
||||||
|
|
||||||
|
//// [index.ts]
|
||||||
|
import {foo} from "utils";
|
||||||
|
export = foo;
|
||||||
|
|
||||||
|
//// [utils.js]
|
||||||
|
function foo() { }
|
||||||
|
exports.foo = foo;
|
||||||
|
function bar() { }
|
||||||
|
exports.bar = bar;
|
||||||
|
//// [index.js]
|
||||||
|
var utils_1 = require("utils");
|
||||||
|
module.exports = utils_1.foo;
|
||||||
|
|
||||||
|
|
||||||
|
//// [utils.d.ts]
|
||||||
|
export declare function foo(): void;
|
||||||
|
export declare function bar(): void;
|
||||||
|
export interface Buzz {
|
||||||
|
}
|
||||||
|
//// [index.d.ts]
|
||||||
|
import { foo } from "utils";
|
||||||
|
export = foo;
|
|
@ -0,0 +1,18 @@
|
||||||
|
=== tests/cases/compiler/utils.ts ===
|
||||||
|
|
||||||
|
export function foo() { }
|
||||||
|
>foo : Symbol(foo, Decl(utils.ts, 0, 0))
|
||||||
|
|
||||||
|
export function bar() { }
|
||||||
|
>bar : Symbol(bar, Decl(utils.ts, 1, 25))
|
||||||
|
|
||||||
|
export interface Buzz { }
|
||||||
|
>Buzz : Symbol(Buzz, Decl(utils.ts, 2, 25))
|
||||||
|
|
||||||
|
=== tests/cases/compiler/index.ts ===
|
||||||
|
import {foo} from "utils";
|
||||||
|
>foo : Symbol(foo, Decl(index.ts, 0, 8))
|
||||||
|
|
||||||
|
export = foo;
|
||||||
|
>foo : Symbol(foo, Decl(index.ts, 0, 8))
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
=== tests/cases/compiler/utils.ts ===
|
||||||
|
|
||||||
|
export function foo() { }
|
||||||
|
>foo : () => void
|
||||||
|
|
||||||
|
export function bar() { }
|
||||||
|
>bar : () => void
|
||||||
|
|
||||||
|
export interface Buzz { }
|
||||||
|
>Buzz : Buzz
|
||||||
|
|
||||||
|
=== tests/cases/compiler/index.ts ===
|
||||||
|
import {foo} from "utils";
|
||||||
|
>foo : () => void
|
||||||
|
|
||||||
|
export = foo;
|
||||||
|
>foo : () => void
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
//// [tests/cases/compiler/declarationEmit_exportDeclaration.ts] ////
|
||||||
|
|
||||||
|
//// [utils.ts]
|
||||||
|
|
||||||
|
export function foo() { }
|
||||||
|
export function bar() { }
|
||||||
|
export interface Buzz { }
|
||||||
|
|
||||||
|
//// [index.ts]
|
||||||
|
import {foo, bar, Buzz} from "utils";
|
||||||
|
|
||||||
|
foo();
|
||||||
|
let obj: Buzz;
|
||||||
|
export {bar};
|
||||||
|
|
||||||
|
//// [utils.js]
|
||||||
|
function foo() { }
|
||||||
|
exports.foo = foo;
|
||||||
|
function bar() { }
|
||||||
|
exports.bar = bar;
|
||||||
|
//// [index.js]
|
||||||
|
var utils_1 = require("utils");
|
||||||
|
exports.bar = utils_1.bar;
|
||||||
|
utils_1.foo();
|
||||||
|
var obj;
|
||||||
|
|
||||||
|
|
||||||
|
//// [utils.d.ts]
|
||||||
|
export declare function foo(): void;
|
||||||
|
export declare function bar(): void;
|
||||||
|
export interface Buzz {
|
||||||
|
}
|
||||||
|
//// [index.d.ts]
|
||||||
|
import { bar } from "utils";
|
||||||
|
export { bar };
|
|
@ -0,0 +1,27 @@
|
||||||
|
=== tests/cases/compiler/utils.ts ===
|
||||||
|
|
||||||
|
export function foo() { }
|
||||||
|
>foo : Symbol(foo, Decl(utils.ts, 0, 0))
|
||||||
|
|
||||||
|
export function bar() { }
|
||||||
|
>bar : Symbol(bar, Decl(utils.ts, 1, 25))
|
||||||
|
|
||||||
|
export interface Buzz { }
|
||||||
|
>Buzz : Symbol(Buzz, Decl(utils.ts, 2, 25))
|
||||||
|
|
||||||
|
=== tests/cases/compiler/index.ts ===
|
||||||
|
import {foo, bar, Buzz} from "utils";
|
||||||
|
>foo : Symbol(foo, Decl(index.ts, 0, 8))
|
||||||
|
>bar : Symbol(bar, Decl(index.ts, 0, 12))
|
||||||
|
>Buzz : Symbol(Buzz, Decl(index.ts, 0, 17))
|
||||||
|
|
||||||
|
foo();
|
||||||
|
>foo : Symbol(foo, Decl(index.ts, 0, 8))
|
||||||
|
|
||||||
|
let obj: Buzz;
|
||||||
|
>obj : Symbol(obj, Decl(index.ts, 3, 3))
|
||||||
|
>Buzz : Symbol(Buzz, Decl(index.ts, 0, 17))
|
||||||
|
|
||||||
|
export {bar};
|
||||||
|
>bar : Symbol(bar, Decl(index.ts, 4, 8))
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
=== tests/cases/compiler/utils.ts ===
|
||||||
|
|
||||||
|
export function foo() { }
|
||||||
|
>foo : () => void
|
||||||
|
|
||||||
|
export function bar() { }
|
||||||
|
>bar : () => void
|
||||||
|
|
||||||
|
export interface Buzz { }
|
||||||
|
>Buzz : Buzz
|
||||||
|
|
||||||
|
=== tests/cases/compiler/index.ts ===
|
||||||
|
import {foo, bar, Buzz} from "utils";
|
||||||
|
>foo : () => void
|
||||||
|
>bar : () => void
|
||||||
|
>Buzz : any
|
||||||
|
|
||||||
|
foo();
|
||||||
|
>foo() : void
|
||||||
|
>foo : () => void
|
||||||
|
|
||||||
|
let obj: Buzz;
|
||||||
|
>obj : Buzz
|
||||||
|
>Buzz : Buzz
|
||||||
|
|
||||||
|
export {bar};
|
||||||
|
>bar : () => void
|
||||||
|
|
12
tests/cases/compiler/declarationEmit_exportAssignment.ts
Normal file
12
tests/cases/compiler/declarationEmit_exportAssignment.ts
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// @target: es5
|
||||||
|
// @module: commonjs
|
||||||
|
// @declaration: true
|
||||||
|
|
||||||
|
// @filename: utils.ts
|
||||||
|
export function foo() { }
|
||||||
|
export function bar() { }
|
||||||
|
export interface Buzz { }
|
||||||
|
|
||||||
|
// @filename: index.ts
|
||||||
|
import {foo} from "utils";
|
||||||
|
export = foo;
|
15
tests/cases/compiler/declarationEmit_exportDeclaration.ts
Normal file
15
tests/cases/compiler/declarationEmit_exportDeclaration.ts
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
// @target: es5
|
||||||
|
// @module: commonjs
|
||||||
|
// @declaration: true
|
||||||
|
|
||||||
|
// @filename: utils.ts
|
||||||
|
export function foo() { }
|
||||||
|
export function bar() { }
|
||||||
|
export interface Buzz { }
|
||||||
|
|
||||||
|
// @filename: index.ts
|
||||||
|
import {foo, bar, Buzz} from "utils";
|
||||||
|
|
||||||
|
foo();
|
||||||
|
let obj: Buzz;
|
||||||
|
export {bar};
|
|
@ -14,6 +14,13 @@
|
||||||
////
|
////
|
||||||
////foo()<number, string, T >();
|
////foo()<number, string, T >();
|
||||||
////(a + b)<number, string, T >();
|
////(a + b)<number, string, T >();
|
||||||
|
////
|
||||||
|
////function bar<T>() {
|
||||||
|
/////*inClassExpression*/ return class < T2 > {
|
||||||
|
//// }
|
||||||
|
////}
|
||||||
|
/////*expressionWithTypeArguments*/class A < T > extends bar < T >( ) < T > {
|
||||||
|
////}
|
||||||
|
|
||||||
|
|
||||||
format.document();
|
format.document();
|
||||||
|
@ -34,3 +41,9 @@ verify.currentLineContentIs(" new <T>(a: T);");
|
||||||
|
|
||||||
goTo.marker("inOptionalMethodSignature");
|
goTo.marker("inOptionalMethodSignature");
|
||||||
verify.currentLineContentIs(" op?<T, M>(a: T, b: M);");
|
verify.currentLineContentIs(" op?<T, M>(a: T, b: M);");
|
||||||
|
|
||||||
|
goTo.marker("inClassExpression");
|
||||||
|
verify.currentLineContentIs(" return class <T2> {");
|
||||||
|
|
||||||
|
goTo.marker("expressionWithTypeArguments");
|
||||||
|
verify.currentLineContentIs("class A<T> extends bar<T>()<T> {");
|
Loading…
Reference in a new issue