From 45e8a5b54d0e3fe8deb1f412436a9defad0ff04e Mon Sep 17 00:00:00 2001 From: about-code Date: Mon, 17 Oct 2016 19:22:40 +0200 Subject: [PATCH] Accepting new baseline. Format code to fit linter rules. --- src/compiler/checker.ts | 53 ++++++++++--------- .../propertyNamedPrototype.errors.txt | 4 +- .../staticPropertyNameConflictsEs5.errors.txt | 40 +++++++------- .../staticPropertyNameConflictsEs6.errors.txt | 24 ++++----- .../staticPrototypeProperty.errors.txt | 8 +-- 5 files changed, 66 insertions(+), 63 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2412faed6ad..9e8c92309b0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14554,43 +14554,46 @@ namespace ts { // Static members may conflict with non-configurable non-writable built-in Function.prototype properties // see https://github.com/microsoft/typescript/issues/442. - function checkClassForStaticPropertyNameConflicts(node: ClassLikeDeclaration) { + function checkClassForStaticPropertyNameConflicts(node: ClassLikeDeclaration) { const es5_descriptors: PropertyDescriptorMap = { // see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.3 // see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.5 - "name": {configurable: false, writable: false}, - "length": {configurable: false, writable: false}, - "prototype": {configurable: false, writable: false}, + "name": { configurable: false, writable: false }, + "length": { configurable: false, writable: false }, + "prototype": { configurable: false, writable: false }, // see https://github.com/microsoft/typescript/issues/442 - "caller": {configurable: false, writable: false}, - "arguments": {configurable: false, writable: false} - }; + "caller": { configurable: false, writable: false }, + "arguments": { configurable: false, writable: false } + }; const post_es5_descriptors: PropertyDescriptorMap = { // see http://www.ecma-international.org/ecma-262/6.0/#sec-properties-of-the-function-constructor // see http://www.ecma-international.org/ecma-262/6.0/#sec-function-instances - "name": {configurable: true, writable: false}, - "length": {configurable: true, writable: false}, - "prototype": {configurable: false, writable: false}, - "caller": {configurable: false, writable: false}, - "arguments": {configurable: false, writable: false} + "name": { configurable: true, writable: false }, + "length": { configurable: true, writable: false }, + "prototype": { configurable: false, writable: false }, + "caller": { configurable: false, writable: false }, + "arguments": { configurable: false, writable: false } }; const message = Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1; const className = getSymbolOfNode(node).name; - - for (let member of node.members) { - let isStatic = forEach(member.modifiers, (m:Modifier) => m.kind === SyntaxKind.StaticKeyword); + + for (const member of node.members) { + const isStatic = forEach(member.modifiers, (m: Modifier) => m.kind === SyntaxKind.StaticKeyword); if (isStatic) { - let memberNameNode = member.name; - let memberName = getPropertyNameForPropertyNameNode(memberNameNode); - let descriptor: PropertyDescriptor = null; - if (languageVersion <= ScriptTarget.ES5) { - descriptor = es5_descriptors.hasOwnProperty(memberName) ? es5_descriptors[memberName] : null; - } else if (languageVersion > ScriptTarget.ES5) { - descriptor = post_es5_descriptors.hasOwnProperty(memberName) ? post_es5_descriptors[memberName] : null; - } - if (descriptor && descriptor.configurable === false && descriptor.writable === false) { - error(memberNameNode, message, memberName, className); + const memberNameNode = member.name; + if (memberNameNode) { + const memberName = getPropertyNameForPropertyNameNode(memberNameNode); + let descriptor: PropertyDescriptor = undefined; + if (languageVersion <= ScriptTarget.ES5) { + descriptor = es5_descriptors.hasOwnProperty(memberName) ? es5_descriptors[memberName] : undefined; + } + else if (languageVersion > ScriptTarget.ES5) { + descriptor = post_es5_descriptors.hasOwnProperty(memberName) ? post_es5_descriptors[memberName] : undefined; + } + if (descriptor && descriptor.configurable === false && descriptor.writable === false) { + error(memberNameNode, message, memberName, className); + } } } } diff --git a/tests/baselines/reference/propertyNamedPrototype.errors.txt b/tests/baselines/reference/propertyNamedPrototype.errors.txt index 6ddd8390720..2c0c8f30f76 100644 --- a/tests/baselines/reference/propertyNamedPrototype.errors.txt +++ b/tests/baselines/reference/propertyNamedPrototype.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/classes/propertyMemberDeclarations/propertyNamedPrototype.ts(3,12): error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. +tests/cases/conformance/classes/propertyMemberDeclarations/propertyNamedPrototype.ts(3,12): error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. ==== tests/cases/conformance/classes/propertyMemberDeclarations/propertyNamedPrototype.ts (1 errors) ==== @@ -6,5 +6,5 @@ tests/cases/conformance/classes/propertyMemberDeclarations/propertyNamedPrototyp prototype: number; // ok static prototype: C; // error ~~~~~~~~~ -!!! error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. +!!! error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. } \ No newline at end of file diff --git a/tests/baselines/reference/staticPropertyNameConflictsEs5.errors.txt b/tests/baselines/reference/staticPropertyNameConflictsEs5.errors.txt index 182b1628522..5c3f3b3f7dc 100644 --- a/tests/baselines/reference/staticPropertyNameConflictsEs5.errors.txt +++ b/tests/baselines/reference/staticPropertyNameConflictsEs5.errors.txt @@ -1,14 +1,14 @@ -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(4,12): error TS2692: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(9,12): error TS2692: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(15,12): error TS2692: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(20,12): error TS2692: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(26,12): error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(4,12): error TS2697: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(9,12): error TS2697: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(15,12): error TS2697: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(20,12): error TS2697: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(26,12): error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(31,12): error TS2300: Duplicate identifier 'prototype'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(31,12): error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(37,12): error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(42,12): error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(48,12): error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(53,12): error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(31,12): error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(37,12): error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(42,12): error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(48,12): error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(53,12): error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. ==== tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts (11 errors) ==== @@ -17,14 +17,14 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon class StaticName { static name: number; // error ~~~~ -!!! error TS2692: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. +!!! error TS2697: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'. name: string; // ok } class StaticNameFn { static name() {} // error ~~~~ -!!! error TS2692: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'. +!!! error TS2697: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'. name() {} // ok } @@ -32,14 +32,14 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon class StaticLength { static length: number; // error ~~~~~~ -!!! error TS2692: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. +!!! error TS2697: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'. length: string; // ok } class StaticLengthFn { static length() {} // error ~~~~~~ -!!! error TS2692: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'. +!!! error TS2697: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'. length() {} // ok } @@ -47,7 +47,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon class StaticPrototype { static prototype: number; // error ~~~~~~~~~ -!!! error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. +!!! error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. prototype: string; // ok } @@ -56,7 +56,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon ~~~~~~~~~ !!! error TS2300: Duplicate identifier 'prototype'. ~~~~~~~~~ -!!! error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. +!!! error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. prototype() {} // ok } @@ -64,14 +64,14 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon class StaticCaller { static caller: number; // error ~~~~~~ -!!! error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. +!!! error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. caller: string; // ok } class StaticCallerFn { static caller() {} // error ~~~~~~ -!!! error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. +!!! error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. caller() {} // ok } @@ -79,14 +79,14 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon class StaticArguments { static arguments: number; // error ~~~~~~~~~ -!!! error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. +!!! error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. arguments: string; // ok } class StaticArgumentsFn { static arguments() {} // error ~~~~~~~~~ -!!! error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. +!!! error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. arguments() {} // ok } \ No newline at end of file diff --git a/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt b/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt index b76b7e02b76..0c65494c7bc 100644 --- a/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt +++ b/tests/baselines/reference/staticPropertyNameConflictsEs6.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(26,12): error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(26,12): error TS2697: 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 TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(37,12): error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(42,12): error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(48,12): error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. -tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(53,12): error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(31,12): error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(37,12): error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(42,12): error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(48,12): error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. +tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts(53,12): error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. ==== tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs6.ts (7 errors) ==== @@ -35,7 +35,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon class StaticPrototype { static prototype: number; // error ~~~~~~~~~ -!!! error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. +!!! error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'. prototype: string; // ok } @@ -44,7 +44,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon ~~~~~~~~~ !!! error TS2300: Duplicate identifier 'prototype'. ~~~~~~~~~ -!!! error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. +!!! error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'. prototype() {} // ok } @@ -52,14 +52,14 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon class StaticCaller { static caller: number; // // error ~~~~~~ -!!! error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. +!!! error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'. caller: string; // ok } class StaticCallerFn { static caller() {} // // error ~~~~~~ -!!! error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. +!!! error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'. caller() {} // ok } @@ -67,14 +67,14 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon class StaticArguments { static arguments: number; // // error ~~~~~~~~~ -!!! error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. +!!! error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'. arguments: string; // ok } class StaticArgumentsFn { static arguments() {} // // error ~~~~~~~~~ -!!! error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. +!!! error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'. arguments() {} // ok } \ No newline at end of file diff --git a/tests/baselines/reference/staticPrototypeProperty.errors.txt b/tests/baselines/reference/staticPrototypeProperty.errors.txt index b2f36a40bed..44b6980cb91 100644 --- a/tests/baselines/reference/staticPrototypeProperty.errors.txt +++ b/tests/baselines/reference/staticPrototypeProperty.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/staticPrototypeProperty.ts(2,11): error TS2300: Duplicate identifier 'prototype'. -tests/cases/compiler/staticPrototypeProperty.ts(2,11): error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. -tests/cases/compiler/staticPrototypeProperty.ts(6,11): error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C2'. +tests/cases/compiler/staticPrototypeProperty.ts(2,11): error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. +tests/cases/compiler/staticPrototypeProperty.ts(6,11): error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C2'. ==== tests/cases/compiler/staticPrototypeProperty.ts (3 errors) ==== @@ -9,11 +9,11 @@ tests/cases/compiler/staticPrototypeProperty.ts(6,11): error TS2692: Static prop ~~~~~~~~~ !!! error TS2300: Duplicate identifier 'prototype'. ~~~~~~~~~ -!!! error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. +!!! error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'. } class C2 { static prototype; ~~~~~~~~~ -!!! error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C2'. +!!! error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C2'. } \ No newline at end of file