mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Test duplicate identifier reporting in classes
This commit is contained in:
1 parent
78bc368c22
commit
ce629f03a7
3 files changed
+76
No files matched your search
@@ -0,0 +1,31 @@
|
||||
tests/cases/compiler/classWithDuplicateIdentifier.ts(3,5): error TS2300: Duplicate identifier 'a'.
|
||||
tests/cases/compiler/classWithDuplicateIdentifier.ts(6,5): error TS2300: Duplicate identifier 'b'.
|
||||
tests/cases/compiler/classWithDuplicateIdentifier.ts(7,5): error TS2300: Duplicate identifier 'b'.
|
||||
tests/cases/compiler/classWithDuplicateIdentifier.ts(11,5): error TS2300: Duplicate identifier 'c'.
|
||||
tests/cases/compiler/classWithDuplicateIdentifier.ts(11,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'c' must be of type 'number', but here has type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/classWithDuplicateIdentifier.ts (5 errors) ====
|
||||
class C {
|
||||
a(): number { return 0; } // error: duplicate identifier
|
||||
a: number;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'a'.
|
||||
}
|
||||
class K {
|
||||
b: number; // error: duplicate identifier
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'b'.
|
||||
b(): number { return 0; }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'b'.
|
||||
}
|
||||
class D {
|
||||
c: number;
|
||||
c: string;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'c'.
|
||||
~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'c' must be of type 'number', but here has type 'string'.
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
//// [classWithDuplicateIdentifier.ts]
|
||||
class C {
|
||||
a(): number { return 0; } // error: duplicate identifier
|
||||
a: number;
|
||||
}
|
||||
class K {
|
||||
b: number; // error: duplicate identifier
|
||||
b(): number { return 0; }
|
||||
}
|
||||
class D {
|
||||
c: number;
|
||||
c: string;
|
||||
}
|
||||
|
||||
|
||||
//// [classWithDuplicateIdentifier.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.a = function () { return 0; }; // error: duplicate identifier
|
||||
return C;
|
||||
}());
|
||||
var K = (function () {
|
||||
function K() {
|
||||
}
|
||||
K.prototype.b = function () { return 0; };
|
||||
return K;
|
||||
}());
|
||||
var D = (function () {
|
||||
function D() {
|
||||
}
|
||||
return D;
|
||||
}());
|
||||
@@ -0,0 +1,12 @@
|
||||
class C {
|
||||
a(): number { return 0; } // error: duplicate identifier
|
||||
a: number;
|
||||
}
|
||||
class K {
|
||||
b: number; // error: duplicate identifier
|
||||
b(): number { return 0; }
|
||||
}
|
||||
class D {
|
||||
c: number;
|
||||
c: string;
|
||||
}
|
||||
Reference in new issue
Block a user