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

Commit cffc62a

Browse filesBrowse files
committed
Report duplicate identifier errors on all locations for merged declarations to align with local declarations
1 parent 318575c commit cffc62a
Copy full SHA for cffc62a

21 files changed

+161-129Lines changed: 161 additions & 129 deletions
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/compiler/checker.ts‎

Copy file name to clipboardExpand all lines: src/compiler/checker.ts
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ module ts {
226226
forEach(source.declarations, node => {
227227
error(node.name ? node.name : node, Diagnostics.Duplicate_identifier_0, symbolToString(source));
228228
});
229+
forEach(target.declarations, node => {
230+
error(node.name ? node.name : node, Diagnostics.Duplicate_identifier_0, symbolToString(source));
231+
});
229232
}
230233
}
231234

Collapse file

‎tests/baselines/reference/functionTypeArgumentArrayAssignment.errors.txt‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/functionTypeArgumentArrayAssignment.errors.txt
-15Lines changed: 0 additions & 15 deletions
This file was deleted.
Collapse file
+14-9Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
//// [functionTypeArgumentArrayAssignment.ts]
2-
interface Array<T> {
3-
foo: T;
4-
length: number;
5-
}
2+
module test {
3+
interface Array<T> {
4+
foo: T;
5+
length: number;
6+
}
67

7-
function map<U>() {
8-
var ys: U[] = [];
8+
function map<U>() {
9+
var ys: U[] = [];
10+
}
911
}
1012

1113

1214
//// [functionTypeArgumentArrayAssignment.js]
13-
function map() {
14-
var ys = [];
15-
}
15+
var test;
16+
(function (test) {
17+
function map() {
18+
var ys = [];
19+
}
20+
})(test || (test = {}));
Collapse file
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
=== tests/cases/compiler/functionTypeArgumentArrayAssignment.ts ===
2+
module test {
3+
>test : typeof test
4+
5+
interface Array<T> {
6+
>Array : Array<T>
7+
>T : T
8+
9+
foo: T;
10+
>foo : T
11+
>T : T
12+
13+
length: number;
14+
>length : number
15+
}
16+
17+
function map<U>() {
18+
>map : <U>() => void
19+
>U : U
20+
21+
var ys: U[] = [];
22+
>ys : U[]
23+
>U : U
24+
>[] : U[]
25+
}
26+
}
27+
Collapse file
+23-24Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
1-
tests/cases/compiler/instanceofOperator.ts(6,7): error TS2300: Duplicate identifier 'Object'.
2-
tests/cases/compiler/instanceofOperator.ts(11,1): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
3-
tests/cases/compiler/instanceofOperator.ts(14,16): error TS2359: The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
4-
tests/cases/compiler/instanceofOperator.ts(15,19): error TS2359: The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
5-
tests/cases/compiler/instanceofOperator.ts(18,1): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
6-
tests/cases/compiler/instanceofOperator.ts(20,1): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
1+
tests/cases/compiler/instanceofOperator.ts(12,5): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
2+
tests/cases/compiler/instanceofOperator.ts(15,20): error TS2359: The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
3+
tests/cases/compiler/instanceofOperator.ts(16,23): error TS2359: The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
4+
tests/cases/compiler/instanceofOperator.ts(19,5): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
5+
tests/cases/compiler/instanceofOperator.ts(21,5): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
76

87

9-
==== tests/cases/compiler/instanceofOperator.ts (6 errors) ====
8+
==== tests/cases/compiler/instanceofOperator.ts (5 errors) ====
109
// Spec:
1110
// The instanceof operator requires the left operand to be of type Any or an object type, and the right
1211
// operand to be of type Any or a subtype of the ‘Function’ interface type. The result is always of the
1312
// Boolean primitive type.
1413

15-
class Object { }
16-
~~~~~~
17-
!!! error TS2300: Duplicate identifier 'Object'.
18-
var obj: Object;
14+
module test {
15+
class Object { }
16+
var obj: Object;
1917

2018

2119

22-
4 instanceof null;
23-
~
20+
4 instanceof null;
21+
~
2422
!!! error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
2523

26-
// Error and should be error
27-
obj instanceof 4;
28-
~
24+
// Error and should be error
25+
obj instanceof 4;
26+
~
2927
!!! error TS2359: The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
30-
Object instanceof obj;
31-
~~~
28+
Object instanceof obj;
29+
~~~
3230
!!! error TS2359: The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
3331

34-
// Error on left hand side
35-
null instanceof null;
36-
~~~~
32+
// Error on left hand side
33+
null instanceof null;
34+
~~~~
3735
!!! error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
38-
obj instanceof Object;
39-
undefined instanceof undefined;
40-
~~~~~~~~~
36+
obj instanceof Object;
37+
undefined instanceof undefined;
38+
~~~~~~~~~
4139
!!! error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
40+
}
4241

4342

Collapse file

‎tests/baselines/reference/instanceofOperator.js‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/instanceofOperator.js
+29-24Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,23 @@
44
// operand to be of type Any or a subtype of the ‘Function’ interface type. The result is always of the
55
// Boolean primitive type.
66

7-
class Object { }
8-
var obj: Object;
7+
module test {
8+
class Object { }
9+
var obj: Object;
910

1011

1112

12-
4 instanceof null;
13+
4 instanceof null;
1314

14-
// Error and should be error
15-
obj instanceof 4;
16-
Object instanceof obj;
15+
// Error and should be error
16+
obj instanceof 4;
17+
Object instanceof obj;
1718

18-
// Error on left hand side
19-
null instanceof null;
20-
obj instanceof Object;
21-
undefined instanceof undefined;
19+
// Error on left hand side
20+
null instanceof null;
21+
obj instanceof Object;
22+
undefined instanceof undefined;
23+
}
2224

2325

2426

@@ -27,17 +29,20 @@ undefined instanceof undefined;
2729
// The instanceof operator requires the left operand to be of type Any or an object type, and the right
2830
// operand to be of type Any or a subtype of the ‘Function’ interface type. The result is always of the
2931
// Boolean primitive type.
30-
var Object = (function () {
31-
function Object() {
32-
}
33-
return Object;
34-
})();
35-
var obj;
36-
4 instanceof null;
37-
// Error and should be error
38-
obj instanceof 4;
39-
Object instanceof obj;
40-
// Error on left hand side
41-
null instanceof null;
42-
obj instanceof Object;
43-
undefined instanceof undefined;
32+
var test;
33+
(function (test) {
34+
var Object = (function () {
35+
function Object() {
36+
}
37+
return Object;
38+
})();
39+
var obj;
40+
4 instanceof null;
41+
// Error and should be error
42+
obj instanceof 4;
43+
Object instanceof obj;
44+
// Error on left hand side
45+
null instanceof null;
46+
obj instanceof Object;
47+
undefined instanceof undefined;
48+
})(test || (test = {}));
Collapse file

‎tests/baselines/reference/letDeclarations-scopes-duplicates2.errors.txt‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/letDeclarations-scopes-duplicates2.errors.txt
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
tests/cases/compiler/file1.ts(2,5): error TS2300: Duplicate identifier 'var1'.
12
tests/cases/compiler/file2.ts(1,5): error TS2300: Duplicate identifier 'var1'.
23

34

4-
==== tests/cases/compiler/file1.ts (0 errors) ====
5+
==== tests/cases/compiler/file1.ts (1 errors) ====
56

67
let var1 = 0;
8+
~~~~
9+
!!! error TS2300: Duplicate identifier 'var1'.
710

811
==== tests/cases/compiler/file2.ts (1 errors) ====
912
let var1 = 0;
Collapse file

‎tests/baselines/reference/letDeclarations-scopes-duplicates3.errors.txt‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/letDeclarations-scopes-duplicates3.errors.txt
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
tests/cases/compiler/file1.ts(2,5): error TS2300: Duplicate identifier 'var1'.
12
tests/cases/compiler/file2.ts(1,7): error TS2300: Duplicate identifier 'var1'.
23

34

4-
==== tests/cases/compiler/file1.ts (0 errors) ====
5+
==== tests/cases/compiler/file1.ts (1 errors) ====
56

67
let var1 = 0;
8+
~~~~
9+
!!! error TS2300: Duplicate identifier 'var1'.
710

811
==== tests/cases/compiler/file2.ts (1 errors) ====
912
const var1 = 0;
Collapse file

‎tests/baselines/reference/letDeclarations-scopes-duplicates4.errors.txt‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/letDeclarations-scopes-duplicates4.errors.txt
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
tests/cases/compiler/file1.ts(2,7): error TS2300: Duplicate identifier 'var1'.
12
tests/cases/compiler/file2.ts(1,5): error TS2300: Duplicate identifier 'var1'.
23

34

4-
==== tests/cases/compiler/file1.ts (0 errors) ====
5+
==== tests/cases/compiler/file1.ts (1 errors) ====
56

67
const var1 = 0;
8+
~~~~
9+
!!! error TS2300: Duplicate identifier 'var1'.
710

811
==== tests/cases/compiler/file2.ts (1 errors) ====
912
let var1 = 0;
Collapse file

‎tests/baselines/reference/letDeclarations-scopes-duplicates5.errors.txt‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/letDeclarations-scopes-duplicates5.errors.txt
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
tests/cases/compiler/file1.ts(2,7): error TS2300: Duplicate identifier 'var1'.
12
tests/cases/compiler/file2.ts(1,7): error TS2300: Duplicate identifier 'var1'.
23

34

4-
==== tests/cases/compiler/file1.ts (0 errors) ====
5+
==== tests/cases/compiler/file1.ts (1 errors) ====
56

67
const var1 = 0;
8+
~~~~
9+
!!! error TS2300: Duplicate identifier 'var1'.
710

811
==== tests/cases/compiler/file2.ts (1 errors) ====
912
const var1 = 0;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.