mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-11 02:15:10 -05:00
Allow to define valid static fields with names conflicting with builtin properties (#54198)
This commit is contained in:
committed by
GitHub
parent
0d262616f3
commit
1561701b9f
@@ -1,56 +1,58 @@
|
||||
// @target: es5
|
||||
// @useDefineForClassFields: true,false
|
||||
|
||||
// name
|
||||
class StaticName {
|
||||
static name: number; // error
|
||||
static name: number; // error without useDefineForClassFields
|
||||
name: string; // ok
|
||||
}
|
||||
|
||||
class StaticNameFn {
|
||||
static name() {} // error
|
||||
static name() {} // error without useDefineForClassFields
|
||||
name() {} // ok
|
||||
}
|
||||
|
||||
// length
|
||||
class StaticLength {
|
||||
static length: number; // error
|
||||
static length: number; // error without useDefineForClassFields
|
||||
length: string; // ok
|
||||
}
|
||||
|
||||
class StaticLengthFn {
|
||||
static length() {} // error
|
||||
static length() {} // error without useDefineForClassFields
|
||||
length() {} // ok
|
||||
}
|
||||
|
||||
// prototype
|
||||
class StaticPrototype {
|
||||
static prototype: number; // error
|
||||
static prototype: number; // always an error
|
||||
prototype: string; // ok
|
||||
}
|
||||
|
||||
class StaticPrototypeFn {
|
||||
static prototype() {} // error
|
||||
static prototype() {} // always an error
|
||||
prototype() {} // ok
|
||||
}
|
||||
|
||||
// caller
|
||||
class StaticCaller {
|
||||
static caller: number; // error
|
||||
static caller: number; // error without useDefineForClassFields
|
||||
caller: string; // ok
|
||||
}
|
||||
|
||||
class StaticCallerFn {
|
||||
static caller() {} // error
|
||||
static caller() {} // error without useDefineForClassFields
|
||||
caller() {} // ok
|
||||
}
|
||||
|
||||
// arguments
|
||||
class StaticArguments {
|
||||
static arguments: number; // error
|
||||
static arguments: number; // error without useDefineForClassFields
|
||||
arguments: string; // ok
|
||||
}
|
||||
|
||||
class StaticArgumentsFn {
|
||||
static arguments() {} // error
|
||||
static arguments() {} // error without useDefineForClassFields
|
||||
arguments() {} // ok
|
||||
}
|
||||
|
||||
@@ -60,56 +62,56 @@ class StaticArgumentsFn {
|
||||
|
||||
// name
|
||||
var StaticName_Anonymous = class {
|
||||
static name: number; // error
|
||||
static name: number; // error without useDefineForClassFields
|
||||
name: string; // ok
|
||||
}
|
||||
|
||||
var StaticNameFn_Anonymous = class {
|
||||
static name() {} // error
|
||||
static name() {} // error without useDefineForClassFields
|
||||
name() {} // ok
|
||||
}
|
||||
|
||||
// length
|
||||
var StaticLength_Anonymous = class {
|
||||
static length: number; // error
|
||||
static length: number; // error without useDefineForClassFields
|
||||
length: string; // ok
|
||||
}
|
||||
|
||||
var StaticLengthFn_Anonymous = class {
|
||||
static length() {} // error
|
||||
static length() {} // error without useDefineForClassFields
|
||||
length() {} // ok
|
||||
}
|
||||
|
||||
// prototype
|
||||
var StaticPrototype_Anonymous = class {
|
||||
static prototype: number; // error
|
||||
static prototype: number; // always an error
|
||||
prototype: string; // ok
|
||||
}
|
||||
|
||||
var StaticPrototypeFn_Anonymous = class {
|
||||
static prototype() {} // error
|
||||
static prototype() {} // always an error
|
||||
prototype() {} // ok
|
||||
}
|
||||
|
||||
// caller
|
||||
var StaticCaller_Anonymous = class {
|
||||
static caller: number; // error
|
||||
static caller: number; // error without useDefineForClassFields
|
||||
caller: string; // ok
|
||||
}
|
||||
|
||||
var StaticCallerFn_Anonymous = class {
|
||||
static caller() {} // error
|
||||
static caller() {} // error without useDefineForClassFields
|
||||
caller() {} // ok
|
||||
}
|
||||
|
||||
// arguments
|
||||
var StaticArguments_Anonymous = class {
|
||||
static arguments: number; // error
|
||||
static arguments: number; // error without useDefineForClassFields
|
||||
arguments: string; // ok
|
||||
}
|
||||
|
||||
var StaticArgumentsFn_Anonymous = class {
|
||||
static arguments() {} // error
|
||||
static arguments() {} // error without useDefineForClassFields
|
||||
arguments() {} // ok
|
||||
}
|
||||
|
||||
@@ -119,14 +121,14 @@ var StaticArgumentsFn_Anonymous = class {
|
||||
// name
|
||||
module TestOnDefaultExportedClass_1 {
|
||||
class StaticName {
|
||||
static name: number; // error
|
||||
static name: number; // error without useDefineForClassFields
|
||||
name: string; // ok
|
||||
}
|
||||
}
|
||||
|
||||
module TestOnDefaultExportedClass_2 {
|
||||
class StaticNameFn {
|
||||
static name() {} // error
|
||||
static name() {} // error without useDefineForClassFields
|
||||
name() {} // ok
|
||||
}
|
||||
}
|
||||
@@ -134,29 +136,29 @@ module TestOnDefaultExportedClass_2 {
|
||||
// length
|
||||
module TestOnDefaultExportedClass_3 {
|
||||
export default class StaticLength {
|
||||
static length: number; // error
|
||||
static length: number; // error without useDefineForClassFields
|
||||
length: string; // ok
|
||||
}
|
||||
}
|
||||
|
||||
module TestOnDefaultExportedClass_4 {
|
||||
export default class StaticLengthFn {
|
||||
static length() {} // error
|
||||
static length() {} // error without useDefineForClassFields
|
||||
length() {} // ok
|
||||
}
|
||||
}
|
||||
|
||||
// prototype
|
||||
module TestOnDefaultExportedClass_5 {
|
||||
module TestOnDefaultExportedClass_5 {
|
||||
export default class StaticPrototype {
|
||||
static prototype: number; // error
|
||||
static prototype: number; // always an error
|
||||
prototype: string; // ok
|
||||
}
|
||||
}
|
||||
|
||||
module TestOnDefaultExportedClass_6 {
|
||||
export default class StaticPrototypeFn {
|
||||
static prototype() {} // error
|
||||
static prototype() {} // always an error
|
||||
prototype() {} // ok
|
||||
}
|
||||
}
|
||||
@@ -164,14 +166,14 @@ module TestOnDefaultExportedClass_6 {
|
||||
// caller
|
||||
module TestOnDefaultExportedClass_7 {
|
||||
export default class StaticCaller {
|
||||
static caller: number; // error
|
||||
static caller: number; // error without useDefineForClassFields
|
||||
caller: string; // ok
|
||||
}
|
||||
}
|
||||
|
||||
module TestOnDefaultExportedClass_8 {
|
||||
export default class StaticCallerFn {
|
||||
static caller() {} // error
|
||||
static caller() {} // error without useDefineForClassFields
|
||||
caller() {} // ok
|
||||
}
|
||||
}
|
||||
@@ -179,14 +181,14 @@ module TestOnDefaultExportedClass_8 {
|
||||
// arguments
|
||||
module TestOnDefaultExportedClass_9 {
|
||||
export default class StaticArguments {
|
||||
static arguments: number; // error
|
||||
static arguments: number; // error without useDefineForClassFields
|
||||
arguments: string; // ok
|
||||
}
|
||||
}
|
||||
|
||||
module TestOnDefaultExportedClass_10 {
|
||||
export default class StaticArgumentsFn {
|
||||
static arguments() {} // error
|
||||
static arguments() {} // error without useDefineForClassFields
|
||||
arguments() {} // ok
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user