Test:use type param constraints for computed prop types

This commit is contained in:
Nathan Shively-Sanders
2017-07-25 09:39:54 -07:00
parent 43981eaa48
commit 1fb6d349f1
8 changed files with 90 additions and 8 deletions

View File

@@ -0,0 +1,15 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames51_ES5.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames51_ES5.ts (1 errors) ====
function f<T, K extends keyof T>() {
var t: T;
var k: K;
var v = {
[t]: 0,
~~~
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
[k]: 1
};
}

View File

@@ -0,0 +1,21 @@
//// [computedPropertyNames51_ES5.ts]
function f<T, K extends keyof T>() {
var t: T;
var k: K;
var v = {
[t]: 0,
[k]: 1
};
}
//// [computedPropertyNames51_ES5.js]
function f() {
var t;
var k;
var v = (_a = {},
_a[t] = 0,
_a[k] = 1,
_a);
var _a;
}

View File

@@ -0,0 +1,15 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames51_ES6.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames51_ES6.ts (1 errors) ====
function f<T, K extends keyof T>() {
var t: T;
var k: K;
var v = {
[t]: 0,
~~~
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
[k]: 1
};
}

View File

@@ -0,0 +1,20 @@
//// [computedPropertyNames51_ES6.ts]
function f<T, K extends keyof T>() {
var t: T;
var k: K;
var v = {
[t]: 0,
[k]: 1
};
}
//// [computedPropertyNames51_ES6.js]
function f() {
var t;
var k;
var v = {
[t]: 0,
[k]: 1
};
}

View File

@@ -1,8 +1,7 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames8_ES5.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames8_ES5.ts(6,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames8_ES5.ts (2 errors) ====
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames8_ES5.ts (1 errors) ====
function f<T, U extends string>() {
var t: T;
var u: U;
@@ -11,7 +10,5 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames8_ES5.ts(6,9
~~~
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
[u]: 1
~~~
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
};
}

View File

@@ -1,8 +1,7 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames8_ES6.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames8_ES6.ts(6,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames8_ES6.ts (2 errors) ====
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames8_ES6.ts (1 errors) ====
function f<T, U extends string>() {
var t: T;
var u: U;
@@ -11,7 +10,5 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames8_ES6.ts(6,9
~~~
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
[u]: 1
~~~
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
};
}

View File

@@ -0,0 +1,8 @@
function f<T, K extends keyof T>() {
var t: T;
var k: K;
var v = {
[t]: 0,
[k]: 1
};
}

View File

@@ -0,0 +1,9 @@
// @target: es6
function f<T, K extends keyof T>() {
var t: T;
var k: K;
var v = {
[t]: 0,
[k]: 1
};
}