mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Disallow refering to static property in computed property name
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNamesWithStaticProperty.ts(3,9): error TS1200: A computed property name cannot reference a static property
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNamesWithStaticProperty.ts(6,9): error TS1200: A computed property name cannot reference a static property
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNamesWithStaticProperty.ts(9,5): error TS1200: A computed property name cannot reference a static property
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesWithStaticProperty.ts (3 errors) ====
|
||||
class C {
|
||||
static staticProp = 10;
|
||||
get [C.staticProp]() {
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS1200: A computed property name cannot reference a static property
|
||||
return "hello";
|
||||
}
|
||||
set [C.staticProp](x: string) {
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS1200: A computed property name cannot reference a static property
|
||||
var y = x;
|
||||
}
|
||||
[C.staticProp]() { }
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS1200: A computed property name cannot reference a static property
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
//// [computedPropertyNamesWithStaticProperty.ts]
|
||||
class C {
|
||||
static staticProp = 10;
|
||||
get [C.staticProp]() {
|
||||
return "hello";
|
||||
}
|
||||
set [C.staticProp](x: string) {
|
||||
var y = x;
|
||||
}
|
||||
[C.staticProp]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNamesWithStaticProperty.js]
|
||||
class C {
|
||||
constructor() {
|
||||
}
|
||||
get [C.staticProp]() {
|
||||
return "hello";
|
||||
}
|
||||
set [C.staticProp](x) {
|
||||
var y = x;
|
||||
}
|
||||
[C.staticProp]() {
|
||||
}
|
||||
}
|
||||
C.staticProp = 10;
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// @target: es6
|
||||
class C {
|
||||
static staticProp = 10;
|
||||
get [C.staticProp]() {
|
||||
return "hello";
|
||||
}
|
||||
set [C.staticProp](x: string) {
|
||||
var y = x;
|
||||
}
|
||||
[C.staticProp]() { }
|
||||
}
|
||||
Reference in New Issue
Block a user