Skip to content

Commit 45e8a5b

Browse files
committed
Accepting new baseline. Format code to fit linter rules.
1 parent 9122f62 commit 45e8a5b

File tree

5 files changed

+66
-63
lines changed

5 files changed

+66
-63
lines changed

src/compiler/checker.ts

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14554,43 +14554,46 @@ namespace ts {
1455414554

1455514555
// Static members may conflict with non-configurable non-writable built-in Function.prototype properties
1455614556
// see https://github.com/microsoft/typescript/issues/442.
14557-
function checkClassForStaticPropertyNameConflicts(node: ClassLikeDeclaration) {
14557+
function checkClassForStaticPropertyNameConflicts(node: ClassLikeDeclaration) {
1455814558
const es5_descriptors: PropertyDescriptorMap = {
1455914559
// see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.3
1456014560
// see http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.5
14561-
"name": {configurable: false, writable: false},
14562-
"length": {configurable: false, writable: false},
14563-
"prototype": {configurable: false, writable: false},
14561+
"name": { configurable: false, writable: false },
14562+
"length": { configurable: false, writable: false },
14563+
"prototype": { configurable: false, writable: false },
1456414564

1456514565
// see https://github.com/microsoft/typescript/issues/442
14566-
"caller": {configurable: false, writable: false},
14567-
"arguments": {configurable: false, writable: false}
14568-
};
14566+
"caller": { configurable: false, writable: false },
14567+
"arguments": { configurable: false, writable: false }
14568+
};
1456914569
const post_es5_descriptors: PropertyDescriptorMap = {
1457014570
// see http://www.ecma-international.org/ecma-262/6.0/#sec-properties-of-the-function-constructor
1457114571
// see http://www.ecma-international.org/ecma-262/6.0/#sec-function-instances
14572-
"name": {configurable: true, writable: false},
14573-
"length": {configurable: true, writable: false},
14574-
"prototype": {configurable: false, writable: false},
14575-
"caller": {configurable: false, writable: false},
14576-
"arguments": {configurable: false, writable: false}
14572+
"name": { configurable: true, writable: false },
14573+
"length": { configurable: true, writable: false },
14574+
"prototype": { configurable: false, writable: false },
14575+
"caller": { configurable: false, writable: false },
14576+
"arguments": { configurable: false, writable: false }
1457714577
};
1457814578
const message = Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1;
1457914579
const className = getSymbolOfNode(node).name;
14580-
14581-
for (let member of node.members) {
14582-
let isStatic = forEach(member.modifiers, (m:Modifier) => m.kind === SyntaxKind.StaticKeyword);
14580+
14581+
for (const member of node.members) {
14582+
const isStatic = forEach(member.modifiers, (m: Modifier) => m.kind === SyntaxKind.StaticKeyword);
1458314583
if (isStatic) {
14584-
let memberNameNode = member.name;
14585-
let memberName = getPropertyNameForPropertyNameNode(memberNameNode);
14586-
let descriptor: PropertyDescriptor = null;
14587-
if (languageVersion <= ScriptTarget.ES5) {
14588-
descriptor = es5_descriptors.hasOwnProperty(memberName) ? es5_descriptors[memberName] : null;
14589-
} else if (languageVersion > ScriptTarget.ES5) {
14590-
descriptor = post_es5_descriptors.hasOwnProperty(memberName) ? post_es5_descriptors[memberName] : null;
14591-
}
14592-
if (descriptor && descriptor.configurable === false && descriptor.writable === false) {
14593-
error(memberNameNode, message, memberName, className);
14584+
const memberNameNode = member.name;
14585+
if (memberNameNode) {
14586+
const memberName = getPropertyNameForPropertyNameNode(memberNameNode);
14587+
let descriptor: PropertyDescriptor = undefined;
14588+
if (languageVersion <= ScriptTarget.ES5) {
14589+
descriptor = es5_descriptors.hasOwnProperty(memberName) ? es5_descriptors[memberName] : undefined;
14590+
}
14591+
else if (languageVersion > ScriptTarget.ES5) {
14592+
descriptor = post_es5_descriptors.hasOwnProperty(memberName) ? post_es5_descriptors[memberName] : undefined;
14593+
}
14594+
if (descriptor && descriptor.configurable === false && descriptor.writable === false) {
14595+
error(memberNameNode, message, memberName, className);
14596+
}
1459414597
}
1459514598
}
1459614599
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
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'.
1+
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'.
22

33

44
==== tests/cases/conformance/classes/propertyMemberDeclarations/propertyNamedPrototype.ts (1 errors) ====
55
class C {
66
prototype: number; // ok
77
static prototype: C; // error
88
~~~~~~~~~
9-
!!! error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'.
9+
!!! error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'C'.
1010
}
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
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'.
2-
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'.
3-
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'.
4-
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'.
5-
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'.
1+
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'.
2+
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'.
3+
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'.
4+
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'.
5+
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'.
66
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts(31,12): error TS2300: Duplicate identifier 'prototype'.
7-
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'.
8-
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'.
9-
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'.
10-
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'.
11-
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'.
7+
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'.
8+
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'.
9+
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'.
10+
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'.
11+
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'.
1212

1313

1414
==== tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflictsEs5.ts (11 errors) ====
@@ -17,37 +17,37 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon
1717
class StaticName {
1818
static name: number; // error
1919
~~~~
20-
!!! error TS2692: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'.
20+
!!! error TS2697: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'.
2121
name: string; // ok
2222
}
2323

2424
class StaticNameFn {
2525
static name() {} // error
2626
~~~~
27-
!!! error TS2692: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'.
27+
!!! error TS2697: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'.
2828
name() {} // ok
2929
}
3030

3131

3232
class StaticLength {
3333
static length: number; // error
3434
~~~~~~
35-
!!! error TS2692: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'.
35+
!!! error TS2697: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'.
3636
length: string; // ok
3737
}
3838

3939
class StaticLengthFn {
4040
static length() {} // error
4141
~~~~~~
42-
!!! error TS2692: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'.
42+
!!! error TS2697: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn'.
4343
length() {} // ok
4444
}
4545

4646

4747
class StaticPrototype {
4848
static prototype: number; // error
4949
~~~~~~~~~
50-
!!! error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'.
50+
!!! error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype'.
5151
prototype: string; // ok
5252
}
5353

@@ -56,37 +56,37 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon
5656
~~~~~~~~~
5757
!!! error TS2300: Duplicate identifier 'prototype'.
5858
~~~~~~~~~
59-
!!! error TS2692: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'.
59+
!!! error TS2697: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn'.
6060
prototype() {} // ok
6161
}
6262

6363

6464
class StaticCaller {
6565
static caller: number; // error
6666
~~~~~~
67-
!!! error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'.
67+
!!! error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller'.
6868
caller: string; // ok
6969
}
7070

7171
class StaticCallerFn {
7272
static caller() {} // error
7373
~~~~~~
74-
!!! error TS2692: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'.
74+
!!! error TS2697: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'.
7575
caller() {} // ok
7676
}
7777

7878

7979
class StaticArguments {
8080
static arguments: number; // error
8181
~~~~~~~~~
82-
!!! error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'.
82+
!!! error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'.
8383
arguments: string; // ok
8484
}
8585

8686
class StaticArgumentsFn {
8787
static arguments() {} // error
8888
~~~~~~~~~
89-
!!! error TS2692: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'.
89+
!!! error TS2697: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'.
9090
arguments() {} // ok
9191
}
9292

0 commit comments

Comments
 (0)