Skip to content

Commit

Permalink
Removing es6 method/property distinction.
Browse files Browse the repository at this point in the history
Adding tests with default export and anonymous class expressions.
  • Loading branch information
about-code committed Jan 14, 2017
1 parent 4718efd commit 9b217e3
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 416 deletions.
40 changes: 12 additions & 28 deletions src/compiler/checker.ts
Expand Up @@ -15694,8 +15694,8 @@ namespace ts {
}

/**
* Static members being set on a constructor function may conflict with built-in Function
* object properties. Esp. in ECMAScript 5 there are non-configurable and non-writable
* Static members being set on a constructor function may conflict with built-in properties
* of Function. Esp. in ECMAScript 5 there are non-configurable and non-writable
* built-in properties. This check issues a transpile error when a class has a static
* member with the same name as a non-writable built-in property.
*
Expand All @@ -15705,37 +15705,21 @@ namespace ts {
* @see http://www.ecma-international.org/ecma-262/6.0/#sec-function-instances
*/
function checkClassForStaticPropertyNameConflicts(node: ClassLikeDeclaration) {
const message = Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1;
const className = getNameOfSymbol(getSymbolOfNode(node));
for (const member of node.members) {
const isStatic = getModifierFlags(member) & ModifierFlags.Static;
const isMethod = member.kind === SyntaxKind.MethodDeclaration;
const memberNameNode = member.name;
const isStatic = getModifierFlags(member) & ModifierFlags.Static;
if (isStatic && memberNameNode) {
const memberName = getPropertyNameForPropertyNameNode(memberNameNode);
if (languageVersion <= ScriptTarget.ES5) { // ES3, ES5
if (memberName === "prototype" ||
memberName === "name" ||
memberName === "length" ||
memberName === "caller" ||
memberName === "arguments"
) {
error(memberNameNode, message, memberName, className);
}
}
else { // ES6+
if (memberName === "prototype") {
switch (memberName) {
case "name":
case "length":
case "caller":
case "arguments":
case "prototype":
const message = Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1;
const className = getNameOfSymbol(getSymbolOfNode(node));
error(memberNameNode, message, memberName, className);
}
else if ((
memberName === "name" ||
memberName === "length" ||
memberName === "caller" ||
memberName === "arguments") &&
isMethod === false
) {
error(memberNameNode, message, memberName, className);
}
break;
}
}
}
Expand Down

This file was deleted.

120 changes: 0 additions & 120 deletions tests/baselines/reference/staticPropertyNameConflictsEs5.js

This file was deleted.

This file was deleted.

0 comments on commit 9b217e3

Please sign in to comment.