Disallow refering to static property in computed property name

This commit is contained in:
Yui T
2015-03-12 08:40:09 -07:00
parent 7ee587c43f
commit 56839604da
6 changed files with 87 additions and 0 deletions
@@ -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;
@@ -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]() { }
}