mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-04-17 01:49:41 -05:00
Test:use type param constraints for computed prop types
This commit is contained in:
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
21
tests/baselines/reference/computedPropertyNames51_ES5.js
Normal file
21
tests/baselines/reference/computedPropertyNames51_ES5.js
Normal 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;
|
||||
}
|
||||
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
20
tests/baselines/reference/computedPropertyNames51_ES6.js
Normal file
20
tests/baselines/reference/computedPropertyNames51_ES6.js
Normal 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
|
||||
};
|
||||
}
|
||||
@@ -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'.
|
||||
};
|
||||
}
|
||||
@@ -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'.
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
function f<T, K extends keyof T>() {
|
||||
var t: T;
|
||||
var k: K;
|
||||
var v = {
|
||||
[t]: 0,
|
||||
[k]: 1
|
||||
};
|
||||
}
|
||||
@@ -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
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user