mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Report duplicate identifier errors on all locations for merged declarations to align with local declarations
This commit is contained in:
parent
318575ce75
commit
cffc62aa1b
@ -226,6 +226,9 @@ module ts {
|
||||
forEach(source.declarations, node => {
|
||||
error(node.name ? node.name : node, Diagnostics.Duplicate_identifier_0, symbolToString(source));
|
||||
});
|
||||
forEach(target.declarations, node => {
|
||||
error(node.name ? node.name : node, Diagnostics.Duplicate_identifier_0, symbolToString(source));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
tests/cases/compiler/functionTypeArgumentArrayAssignment.ts(3,2): error TS2300: Duplicate identifier 'length'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/functionTypeArgumentArrayAssignment.ts (1 errors) ====
|
||||
interface Array<T> {
|
||||
foo: T;
|
||||
length: number;
|
||||
~~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'length'.
|
||||
}
|
||||
|
||||
function map<U>() {
|
||||
var ys: U[] = [];
|
||||
}
|
||||
|
||||
@ -1,15 +1,20 @@
|
||||
//// [functionTypeArgumentArrayAssignment.ts]
|
||||
interface Array<T> {
|
||||
foo: T;
|
||||
length: number;
|
||||
}
|
||||
module test {
|
||||
interface Array<T> {
|
||||
foo: T;
|
||||
length: number;
|
||||
}
|
||||
|
||||
function map<U>() {
|
||||
var ys: U[] = [];
|
||||
function map<U>() {
|
||||
var ys: U[] = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [functionTypeArgumentArrayAssignment.js]
|
||||
function map() {
|
||||
var ys = [];
|
||||
}
|
||||
var test;
|
||||
(function (test) {
|
||||
function map() {
|
||||
var ys = [];
|
||||
}
|
||||
})(test || (test = {}));
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
=== tests/cases/compiler/functionTypeArgumentArrayAssignment.ts ===
|
||||
module test {
|
||||
>test : typeof test
|
||||
|
||||
interface Array<T> {
|
||||
>Array : Array<T>
|
||||
>T : T
|
||||
|
||||
foo: T;
|
||||
>foo : T
|
||||
>T : T
|
||||
|
||||
length: number;
|
||||
>length : number
|
||||
}
|
||||
|
||||
function map<U>() {
|
||||
>map : <U>() => void
|
||||
>U : U
|
||||
|
||||
var ys: U[] = [];
|
||||
>ys : U[]
|
||||
>U : U
|
||||
>[] : U[]
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,43 +1,42 @@
|
||||
tests/cases/compiler/instanceofOperator.ts(6,7): error TS2300: Duplicate identifier 'Object'.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
|
||||
|
||||
==== tests/cases/compiler/instanceofOperator.ts (6 errors) ====
|
||||
==== tests/cases/compiler/instanceofOperator.ts (5 errors) ====
|
||||
// Spec:
|
||||
// The instanceof operator requires the left operand to be of type Any or an object type, and the right
|
||||
// operand to be of type Any or a subtype of the ‘Function’ interface type. The result is always of the
|
||||
// Boolean primitive type.
|
||||
|
||||
class Object { }
|
||||
~~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'Object'.
|
||||
var obj: Object;
|
||||
module test {
|
||||
class Object { }
|
||||
var obj: Object;
|
||||
|
||||
|
||||
|
||||
4 instanceof null;
|
||||
~
|
||||
4 instanceof null;
|
||||
~
|
||||
!!! error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
|
||||
|
||||
// Error and should be error
|
||||
obj instanceof 4;
|
||||
~
|
||||
// Error and should be error
|
||||
obj instanceof 4;
|
||||
~
|
||||
!!! 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.
|
||||
Object instanceof obj;
|
||||
~~~
|
||||
Object instanceof obj;
|
||||
~~~
|
||||
!!! 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.
|
||||
|
||||
// Error on left hand side
|
||||
null instanceof null;
|
||||
~~~~
|
||||
// Error on left hand side
|
||||
null instanceof null;
|
||||
~~~~
|
||||
!!! error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
|
||||
obj instanceof Object;
|
||||
undefined instanceof undefined;
|
||||
~~~~~~~~~
|
||||
obj instanceof Object;
|
||||
undefined instanceof undefined;
|
||||
~~~~~~~~~
|
||||
!!! error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
|
||||
}
|
||||
|
||||
|
||||
@ -4,21 +4,23 @@
|
||||
// operand to be of type Any or a subtype of the ‘Function’ interface type. The result is always of the
|
||||
// Boolean primitive type.
|
||||
|
||||
class Object { }
|
||||
var obj: Object;
|
||||
module test {
|
||||
class Object { }
|
||||
var obj: Object;
|
||||
|
||||
|
||||
|
||||
4 instanceof null;
|
||||
4 instanceof null;
|
||||
|
||||
// Error and should be error
|
||||
obj instanceof 4;
|
||||
Object instanceof obj;
|
||||
// Error and should be error
|
||||
obj instanceof 4;
|
||||
Object instanceof obj;
|
||||
|
||||
// Error on left hand side
|
||||
null instanceof null;
|
||||
obj instanceof Object;
|
||||
undefined instanceof undefined;
|
||||
// Error on left hand side
|
||||
null instanceof null;
|
||||
obj instanceof Object;
|
||||
undefined instanceof undefined;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -27,17 +29,20 @@ undefined instanceof undefined;
|
||||
// The instanceof operator requires the left operand to be of type Any or an object type, and the right
|
||||
// operand to be of type Any or a subtype of the ‘Function’ interface type. The result is always of the
|
||||
// Boolean primitive type.
|
||||
var Object = (function () {
|
||||
function Object() {
|
||||
}
|
||||
return Object;
|
||||
})();
|
||||
var obj;
|
||||
4 instanceof null;
|
||||
// Error and should be error
|
||||
obj instanceof 4;
|
||||
Object instanceof obj;
|
||||
// Error on left hand side
|
||||
null instanceof null;
|
||||
obj instanceof Object;
|
||||
undefined instanceof undefined;
|
||||
var test;
|
||||
(function (test) {
|
||||
var Object = (function () {
|
||||
function Object() {
|
||||
}
|
||||
return Object;
|
||||
})();
|
||||
var obj;
|
||||
4 instanceof null;
|
||||
// Error and should be error
|
||||
obj instanceof 4;
|
||||
Object instanceof obj;
|
||||
// Error on left hand side
|
||||
null instanceof null;
|
||||
obj instanceof Object;
|
||||
undefined instanceof undefined;
|
||||
})(test || (test = {}));
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
tests/cases/compiler/file1.ts(2,5): error TS2300: Duplicate identifier 'var1'.
|
||||
tests/cases/compiler/file2.ts(1,5): error TS2300: Duplicate identifier 'var1'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.ts (0 errors) ====
|
||||
==== tests/cases/compiler/file1.ts (1 errors) ====
|
||||
|
||||
let var1 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var1'.
|
||||
|
||||
==== tests/cases/compiler/file2.ts (1 errors) ====
|
||||
let var1 = 0;
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
tests/cases/compiler/file1.ts(2,5): error TS2300: Duplicate identifier 'var1'.
|
||||
tests/cases/compiler/file2.ts(1,7): error TS2300: Duplicate identifier 'var1'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.ts (0 errors) ====
|
||||
==== tests/cases/compiler/file1.ts (1 errors) ====
|
||||
|
||||
let var1 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var1'.
|
||||
|
||||
==== tests/cases/compiler/file2.ts (1 errors) ====
|
||||
const var1 = 0;
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
tests/cases/compiler/file1.ts(2,7): error TS2300: Duplicate identifier 'var1'.
|
||||
tests/cases/compiler/file2.ts(1,5): error TS2300: Duplicate identifier 'var1'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.ts (0 errors) ====
|
||||
==== tests/cases/compiler/file1.ts (1 errors) ====
|
||||
|
||||
const var1 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var1'.
|
||||
|
||||
==== tests/cases/compiler/file2.ts (1 errors) ====
|
||||
let var1 = 0;
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
tests/cases/compiler/file1.ts(2,7): error TS2300: Duplicate identifier 'var1'.
|
||||
tests/cases/compiler/file2.ts(1,7): error TS2300: Duplicate identifier 'var1'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.ts (0 errors) ====
|
||||
==== tests/cases/compiler/file1.ts (1 errors) ====
|
||||
|
||||
const var1 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var1'.
|
||||
|
||||
==== tests/cases/compiler/file2.ts (1 errors) ====
|
||||
const var1 = 0;
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
tests/cases/compiler/file1.ts(2,5): error TS2300: Duplicate identifier 'var1'.
|
||||
tests/cases/compiler/file2.ts(1,5): error TS2300: Duplicate identifier 'var1'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.ts (0 errors) ====
|
||||
==== tests/cases/compiler/file1.ts (1 errors) ====
|
||||
|
||||
var var1 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var1'.
|
||||
|
||||
==== tests/cases/compiler/file2.ts (1 errors) ====
|
||||
let var1 = 0;
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
tests/cases/compiler/file1.ts(2,5): error TS2300: Duplicate identifier 'var1'.
|
||||
tests/cases/compiler/file2.ts(1,5): error TS2300: Duplicate identifier 'var1'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.ts (0 errors) ====
|
||||
==== tests/cases/compiler/file1.ts (1 errors) ====
|
||||
|
||||
let var1 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var1'.
|
||||
|
||||
==== tests/cases/compiler/file2.ts (1 errors) ====
|
||||
var var1 = 0;
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
tests/cases/compiler/letDeclarations3.ts(3,5): error TS2300: Duplicate identifier 'l1'.
|
||||
tests/cases/compiler/letDeclarations3.ts(3,9): error TS2300: Duplicate identifier 'l1'.
|
||||
tests/cases/compiler/letDeclarations3.ts(3,13): error TS2300: Duplicate identifier 'l1'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/letDeclarations3.ts (3 errors) ====
|
||||
|
||||
// Duplicate variables
|
||||
let l1, l1, l1;
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'l1'.
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'l1'.
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'l1'.
|
||||
|
||||
// unexpected 'let'
|
||||
let l2, let, l3;
|
||||
@ -1,23 +0,0 @@
|
||||
tests/cases/conformance/parser/ecmascript5/parserOptionalTypeMembers1.ts(2,5): error TS2300: Duplicate identifier 'configurable'.
|
||||
tests/cases/conformance/parser/ecmascript5/parserOptionalTypeMembers1.ts(3,5): error TS2300: Duplicate identifier 'enumerable'.
|
||||
tests/cases/conformance/parser/ecmascript5/parserOptionalTypeMembers1.ts(4,5): error TS2300: Duplicate identifier 'value'.
|
||||
tests/cases/conformance/parser/ecmascript5/parserOptionalTypeMembers1.ts(5,5): error TS2300: Duplicate identifier 'writable'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/parserOptionalTypeMembers1.ts (4 errors) ====
|
||||
interface PropertyDescriptor {
|
||||
configurable?: boolean;
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'configurable'.
|
||||
enumerable?: boolean;
|
||||
~~~~~~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'enumerable'.
|
||||
value?: any;
|
||||
~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'value'.
|
||||
writable?: boolean;
|
||||
~~~~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'writable'.
|
||||
get?(): any;
|
||||
set?(v: any): void;
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
//// [parserOptionalTypeMembers1.ts]
|
||||
interface PropertyDescriptor {
|
||||
interface PropertyDescriptor2 {
|
||||
configurable?: boolean;
|
||||
enumerable?: boolean;
|
||||
value?: any;
|
||||
|
||||
23
tests/baselines/reference/parserOptionalTypeMembers1.types
Normal file
23
tests/baselines/reference/parserOptionalTypeMembers1.types
Normal file
@ -0,0 +1,23 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/parserOptionalTypeMembers1.ts ===
|
||||
interface PropertyDescriptor2 {
|
||||
>PropertyDescriptor2 : PropertyDescriptor2
|
||||
|
||||
configurable?: boolean;
|
||||
>configurable : boolean
|
||||
|
||||
enumerable?: boolean;
|
||||
>enumerable : boolean
|
||||
|
||||
value?: any;
|
||||
>value : any
|
||||
|
||||
writable?: boolean;
|
||||
>writable : boolean
|
||||
|
||||
get?(): any;
|
||||
>get : () => any
|
||||
|
||||
set?(v: any): void;
|
||||
>set : (v: any) => void
|
||||
>v : any
|
||||
}
|
||||
@ -1,3 +1,4 @@
|
||||
in1.d.ts(1,8): error TS2300: Duplicate identifier 'a'.
|
||||
in2.d.ts(1,8): error TS2300: Duplicate identifier 'a'.
|
||||
|
||||
|
||||
@ -14,8 +15,10 @@ in2.d.ts(1,8): error TS2300: Duplicate identifier 'a'.
|
||||
class MyClass{ }
|
||||
}
|
||||
}
|
||||
==== in1.d.ts (0 errors) ====
|
||||
==== in1.d.ts (1 errors) ====
|
||||
import a = A;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'a'.
|
||||
==== in2.d.ts (1 errors) ====
|
||||
import a = A;
|
||||
~
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
in1.d.ts(1,8): error TS2300: Duplicate identifier 'a'.
|
||||
in2.d.ts(1,8): error TS2300: Duplicate identifier 'a'.
|
||||
|
||||
|
||||
@ -14,8 +15,10 @@ in2.d.ts(1,8): error TS2300: Duplicate identifier 'a'.
|
||||
class MyClass{ }
|
||||
}
|
||||
}
|
||||
==== in1.d.ts (0 errors) ====
|
||||
==== in1.d.ts (1 errors) ====
|
||||
import a = A;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'a'.
|
||||
==== in2.d.ts (1 errors) ====
|
||||
import a = A;
|
||||
~
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
interface Array<T> {
|
||||
foo: T;
|
||||
length: number;
|
||||
}
|
||||
module test {
|
||||
interface Array<T> {
|
||||
foo: T;
|
||||
length: number;
|
||||
}
|
||||
|
||||
function map<U>() {
|
||||
var ys: U[] = [];
|
||||
function map<U>() {
|
||||
var ys: U[] = [];
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@ -1,4 +1,4 @@
|
||||
interface PropertyDescriptor {
|
||||
interface PropertyDescriptor2 {
|
||||
configurable?: boolean;
|
||||
enumerable?: boolean;
|
||||
value?: any;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user