File tree Expand file tree Collapse file tree 4 files changed +52
-3
lines changed Expand file tree Collapse file tree 4 files changed +52
-3
lines changed Original file line number Diff line number Diff line change @@ -15063,10 +15063,16 @@ namespace ts {
15063
15063
const symbol = getSymbolOfNode(node);
15064
15064
const target = resolveAlias(symbol);
15065
15065
if (target !== unknownSymbol) {
15066
+ // For external modules symbol represent local symbol for an alias.
15067
+ // This local symbol will merge any other local declarations (excluding other aliases)
15068
+ // and symbol.flags will contains combined representation for all merged declaration.
15069
+ // Based on symbol.flags we can compute a set of excluded meanings (meaning that resolved alias should not have,
15070
+ // otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export*
15071
+ // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names).
15066
15072
const excludedMeanings =
15067
- (symbol.flags & SymbolFlags.Value ? SymbolFlags.Value : 0) |
15068
- (symbol.flags & SymbolFlags.Type ? SymbolFlags.Type : 0) |
15069
- (symbol.flags & SymbolFlags.Namespace ? SymbolFlags.Namespace : 0);
15073
+ (symbol.flags & ( SymbolFlags.Value | SymbolFlags.ExportValue) ? SymbolFlags.Value : 0) |
15074
+ (symbol.flags & ( SymbolFlags.Type | SymbolFlags.ExportType) ? SymbolFlags.Type : 0) |
15075
+ (symbol.flags & ( SymbolFlags.Namespace | SymbolFlags.ExportNamespace) ? SymbolFlags.Namespace : 0);
15070
15076
if (target.flags & excludedMeanings) {
15071
15077
const message = node.kind === SyntaxKind.ExportSpecifier ?
15072
15078
Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 :
Original file line number Diff line number Diff line change
1
+ tests/cases/compiler/f2.ts(1,9): error TS2440: Import declaration conflicts with local declaration of 'f'
2
+
3
+
4
+ ==== tests/cases/compiler/f1.ts (0 errors) ====
5
+ export function f() {
6
+ }
7
+
8
+ ==== tests/cases/compiler/f2.ts (1 errors) ====
9
+ import {f} from './f1';
10
+ ~
11
+ !!! error TS2440: Import declaration conflicts with local declaration of 'f'
12
+ export function f() {
13
+ }
Original file line number Diff line number Diff line change
1
+ //// [tests/cases/compiler/functionAndImportNameConflict.ts] ////
2
+
3
+ //// [f1.ts]
4
+ export function f ( ) {
5
+ }
6
+
7
+ //// [f2.ts]
8
+ import { f } from './f1' ;
9
+ export function f ( ) {
10
+ }
11
+
12
+ //// [f1.js]
13
+ "use strict" ;
14
+ function f ( ) {
15
+ }
16
+ exports . f = f ;
17
+ //// [f2.js]
18
+ "use strict" ;
19
+ function f ( ) {
20
+ }
21
+ exports . f = f ;
Original file line number Diff line number Diff line change
1
+ // @module : commonjs
2
+ // @filename : f1.ts
3
+ export function f ( ) {
4
+ }
5
+
6
+ // @filename : f2.ts
7
+ import { f } from './f1' ;
8
+ export function f ( ) {
9
+ }
You can’t perform that action at this time.
0 commit comments