mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 11:54:44 -06:00
exported name should be defined on the source file level
This commit is contained in:
parent
90b81858af
commit
a31c8d5861
@ -2651,7 +2651,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
return false;
|
||||
}
|
||||
|
||||
return !exportEquals && exportSpecifiers && (<Identifier>node).text in exportSpecifiers;
|
||||
if (exportEquals || !exportSpecifiers || !((<Identifier>node).text in exportSpecifiers)) {
|
||||
return false;
|
||||
}
|
||||
// check that referenced declaration is declared on source file level
|
||||
const declaration = resolver.getReferencedValueDeclaration(<Identifier>node);
|
||||
return declaration && getEnclosingBlockScopeContainer(declaration).kind === SyntaxKind.SourceFile;
|
||||
}
|
||||
|
||||
function emitPrefixUnaryExpression(node: PrefixUnaryExpression) {
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
//// [localNameThatMatchExportedNameViaExportDeclaration.ts]
|
||||
|
||||
export { my }
|
||||
|
||||
var my: any;
|
||||
|
||||
my += my;
|
||||
|
||||
function doSome1(my: any) {
|
||||
my = +my;
|
||||
return my;
|
||||
}
|
||||
|
||||
function doSome2() {
|
||||
const internal = (my: any) => {
|
||||
my = +my;
|
||||
return my;
|
||||
};
|
||||
return internal("1");
|
||||
}
|
||||
|
||||
|
||||
//// [localNameThatMatchExportedNameViaExportDeclaration.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
var my;
|
||||
exports.my = my;
|
||||
exports.my = my += my;
|
||||
function doSome1(my) {
|
||||
my = +my;
|
||||
return my;
|
||||
}
|
||||
function doSome2() {
|
||||
var internal = function (my) {
|
||||
my = +my;
|
||||
return my;
|
||||
};
|
||||
return internal("1");
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,43 @@
|
||||
=== tests/cases/compiler/localNameThatMatchExportedNameViaExportDeclaration.ts ===
|
||||
|
||||
export { my }
|
||||
>my : Symbol(my, Decl(localNameThatMatchExportedNameViaExportDeclaration.ts, 1, 8))
|
||||
|
||||
var my: any;
|
||||
>my : Symbol(my, Decl(localNameThatMatchExportedNameViaExportDeclaration.ts, 3, 3))
|
||||
|
||||
my += my;
|
||||
>my : Symbol(my, Decl(localNameThatMatchExportedNameViaExportDeclaration.ts, 3, 3))
|
||||
>my : Symbol(my, Decl(localNameThatMatchExportedNameViaExportDeclaration.ts, 3, 3))
|
||||
|
||||
function doSome1(my: any) {
|
||||
>doSome1 : Symbol(doSome1, Decl(localNameThatMatchExportedNameViaExportDeclaration.ts, 5, 9))
|
||||
>my : Symbol(my, Decl(localNameThatMatchExportedNameViaExportDeclaration.ts, 7, 17))
|
||||
|
||||
my = +my;
|
||||
>my : Symbol(my, Decl(localNameThatMatchExportedNameViaExportDeclaration.ts, 7, 17))
|
||||
>my : Symbol(my, Decl(localNameThatMatchExportedNameViaExportDeclaration.ts, 7, 17))
|
||||
|
||||
return my;
|
||||
>my : Symbol(my, Decl(localNameThatMatchExportedNameViaExportDeclaration.ts, 7, 17))
|
||||
}
|
||||
|
||||
function doSome2() {
|
||||
>doSome2 : Symbol(doSome2, Decl(localNameThatMatchExportedNameViaExportDeclaration.ts, 10, 1))
|
||||
|
||||
const internal = (my: any) => {
|
||||
>internal : Symbol(internal, Decl(localNameThatMatchExportedNameViaExportDeclaration.ts, 13, 9))
|
||||
>my : Symbol(my, Decl(localNameThatMatchExportedNameViaExportDeclaration.ts, 13, 22))
|
||||
|
||||
my = +my;
|
||||
>my : Symbol(my, Decl(localNameThatMatchExportedNameViaExportDeclaration.ts, 13, 22))
|
||||
>my : Symbol(my, Decl(localNameThatMatchExportedNameViaExportDeclaration.ts, 13, 22))
|
||||
|
||||
return my;
|
||||
>my : Symbol(my, Decl(localNameThatMatchExportedNameViaExportDeclaration.ts, 13, 22))
|
||||
|
||||
};
|
||||
return internal("1");
|
||||
>internal : Symbol(internal, Decl(localNameThatMatchExportedNameViaExportDeclaration.ts, 13, 9))
|
||||
}
|
||||
|
||||
@ -0,0 +1,51 @@
|
||||
=== tests/cases/compiler/localNameThatMatchExportedNameViaExportDeclaration.ts ===
|
||||
|
||||
export { my }
|
||||
>my : any
|
||||
|
||||
var my: any;
|
||||
>my : any
|
||||
|
||||
my += my;
|
||||
>my += my : any
|
||||
>my : any
|
||||
>my : any
|
||||
|
||||
function doSome1(my: any) {
|
||||
>doSome1 : (my: any) => any
|
||||
>my : any
|
||||
|
||||
my = +my;
|
||||
>my = +my : number
|
||||
>my : any
|
||||
>+my : number
|
||||
>my : any
|
||||
|
||||
return my;
|
||||
>my : any
|
||||
}
|
||||
|
||||
function doSome2() {
|
||||
>doSome2 : () => any
|
||||
|
||||
const internal = (my: any) => {
|
||||
>internal : (my: any) => any
|
||||
>(my: any) => { my = +my; return my; } : (my: any) => any
|
||||
>my : any
|
||||
|
||||
my = +my;
|
||||
>my = +my : number
|
||||
>my : any
|
||||
>+my : number
|
||||
>my : any
|
||||
|
||||
return my;
|
||||
>my : any
|
||||
|
||||
};
|
||||
return internal("1");
|
||||
>internal("1") : any
|
||||
>internal : (my: any) => any
|
||||
>"1" : string
|
||||
}
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
// @module: amd
|
||||
|
||||
export { my }
|
||||
|
||||
var my: any;
|
||||
|
||||
my += my;
|
||||
|
||||
function doSome1(my: any) {
|
||||
my = +my;
|
||||
return my;
|
||||
}
|
||||
|
||||
function doSome2() {
|
||||
const internal = (my: any) => {
|
||||
my = +my;
|
||||
return my;
|
||||
};
|
||||
return internal("1");
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user