Fix #442: (es3, es5, es6+) Show compiler errors for conflicting properties.

This commit is contained in:
about-code 2016-11-09 21:08:56 +01:00
parent d9a46e1ae6
commit b623f3771e
4 changed files with 20 additions and 12 deletions

View file

@ -14794,11 +14794,13 @@ namespace ts {
error(memberNameNode, message, memberName, className);
}
else if ((
memberName === "name" ||
memberName === "length" ||
memberName === "caller" ||
memberName === "arguments" ) &&
memberName === "arguments") &&
isMethod === false
) {
error(memberNameNode, message, memberName, className);
error(memberNameNode, message, memberName, className);
}
}
}

View file

@ -1,3 +1,5 @@
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(4,12): error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'.
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(15,12): error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'.
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(26,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'.
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(31,12): error TS2300: Duplicate identifier 'prototype'.
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(31,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'.
@ -5,22 +7,26 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(48,12): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'.
==== tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts (5 errors) ====
==== tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts (7 errors) ====
class StaticName {
static name: number; // ok
static name: number; // error
~~~~
!!! error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'.
name: string; // ok
}
class StaticNameFn {
static name() {} // ok
static name() {} // ok
name() {} // ok
}
class StaticLength {
static length: number; // ok
static length: number; // error
~~~~~~
!!! error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'.
length: string; // ok
}

View file

@ -2,18 +2,18 @@
class StaticName {
static name: number; // ok
static name: number; // error
name: string; // ok
}
class StaticNameFn {
static name() {} // ok
static name() {} // ok
name() {} // ok
}
class StaticLength {
static length: number; // ok
static length: number; // error
length: string; // ok
}

View file

@ -2,18 +2,18 @@
class StaticName {
static name: number; // ok
static name: number; // error
name: string; // ok
}
class StaticNameFn {
static name() {} // ok
static name() {} // ok
name() {} // ok
}
class StaticLength {
static length: number; // ok
static length: number; // error
length: string; // ok
}