Skip to content

Commit ea7d4c6

Browse files
committed
Reduce test case + update baselines
1 parent 16db880 commit ea7d4c6

25 files changed

+39
-114
lines changed

tests/baselines/reference/computedPropertyNames10_ES5.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ var v = {
6060

6161
[`hello ${a} bye`]() { }
6262
>[`hello ${a} bye`] : () => void
63-
>`hello ${a} bye` : string
63+
>`hello ${a} bye` : `hello ${any} bye`
6464
>a : any
6565
}

tests/baselines/reference/computedPropertyNames10_ES6.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ var v = {
6060

6161
[`hello ${a} bye`]() { }
6262
>[`hello ${a} bye`] : () => void
63-
>`hello ${a} bye` : string
63+
>`hello ${a} bye` : `hello ${any} bye`
6464
>a : any
6565
}

tests/baselines/reference/computedPropertyNames11_ES5.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ var v = {
7070

7171
get [`hello ${a} bye`]() { return 0; }
7272
>[`hello ${a} bye`] : number
73-
>`hello ${a} bye` : string
73+
>`hello ${a} bye` : `hello ${any} bye`
7474
>a : any
7575
>0 : 0
7676
}

tests/baselines/reference/computedPropertyNames11_ES6.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ var v = {
7070

7171
get [`hello ${a} bye`]() { return 0; }
7272
>[`hello ${a} bye`] : number
73-
>`hello ${a} bye` : string
73+
>`hello ${a} bye` : `hello ${any} bye`
7474
>a : any
7575
>0 : 0
7676
}

tests/baselines/reference/computedPropertyNames12_ES5.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class C {
6363

6464
static [`hello ${a} bye`] = 0
6565
>[`hello ${a} bye`] : number
66-
>`hello ${a} bye` : string
66+
>`hello ${a} bye` : `hello ${any} bye`
6767
>a : any
6868
>0 : 0
6969
}

tests/baselines/reference/computedPropertyNames12_ES6.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class C {
6363

6464
static [`hello ${a} bye`] = 0
6565
>[`hello ${a} bye`] : number
66-
>`hello ${a} bye` : string
66+
>`hello ${a} bye` : `hello ${any} bye`
6767
>a : any
6868
>0 : 0
6969
}

tests/baselines/reference/computedPropertyNames13_ES5.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ class C {
5959

6060
static [`hello ${a} bye`]() { }
6161
>[`hello ${a} bye`] : () => void
62-
>`hello ${a} bye` : string
62+
>`hello ${a} bye` : `hello ${any} bye`
6363
>a : any
6464
}

tests/baselines/reference/computedPropertyNames13_ES6.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ class C {
5959

6060
static [`hello ${a} bye`]() { }
6161
>[`hello ${a} bye`] : () => void
62-
>`hello ${a} bye` : string
62+
>`hello ${a} bye` : `hello ${any} bye`
6363
>a : any
6464
}

tests/baselines/reference/computedPropertyNames14_ES5.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class C {
1515

1616
[[]]() { }
1717
>[[]] : () => void
18-
>[] : undefined[]
18+
>[] : readonly []
1919

2020
static [{}]() { }
2121
>[{}] : () => void

tests/baselines/reference/computedPropertyNames14_ES6.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class C {
1515

1616
[[]]() { }
1717
>[[]] : () => void
18-
>[] : undefined[]
18+
>[] : readonly []
1919

2020
static [{}]() { }
2121
>[{}] : () => void

tests/baselines/reference/computedPropertyNames16_ES5.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class C {
6969

7070
get [`hello ${a} bye`]() { return 0; }
7171
>[`hello ${a} bye`] : number
72-
>`hello ${a} bye` : string
72+
>`hello ${a} bye` : `hello ${any} bye`
7373
>a : any
7474
>0 : 0
7575
}

tests/baselines/reference/computedPropertyNames16_ES6.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class C {
6969

7070
get [`hello ${a} bye`]() { return 0; }
7171
>[`hello ${a} bye`] : number
72-
>`hello ${a} bye` : string
72+
>`hello ${a} bye` : `hello ${any} bye`
7373
>a : any
7474
>0 : 0
7575
}

tests/baselines/reference/computedPropertyNames17_ES5.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class C {
1717

1818
get [[]]() { return 0; }
1919
>[[]] : number
20-
>[] : undefined[]
20+
>[] : readonly []
2121
>0 : 0
2222

2323
set [{}](v) { }

tests/baselines/reference/computedPropertyNames17_ES6.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class C {
1717

1818
get [[]]() { return 0; }
1919
>[[]] : number
20-
>[] : undefined[]
20+
>[] : readonly []
2121
>0 : 0
2222

2323
set [{}](v) { }

tests/baselines/reference/computedPropertyNames3_ES5.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class C {
2222

2323
set [[0, 1]](v) { }
2424
>[[0, 1]] : any
25-
>[0, 1] : number[]
25+
>[0, 1] : readonly [0, 1]
2626
>0 : 0
2727
>1 : 1
2828
>v : any

tests/baselines/reference/computedPropertyNames3_ES6.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class C {
2222

2323
set [[0, 1]](v) { }
2424
>[[0, 1]] : any
25-
>[0, 1] : number[]
25+
>[0, 1] : readonly [0, 1]
2626
>0 : 0
2727
>1 : 1
2828
>v : any

tests/baselines/reference/computedPropertyNames4_ES5.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ var v = {
7070

7171
[`hello ${a} bye`]: 0
7272
>[`hello ${a} bye`] : number
73-
>`hello ${a} bye` : string
73+
>`hello ${a} bye` : `hello ${any} bye`
7474
>a : any
7575
>0 : 0
7676
}

tests/baselines/reference/computedPropertyNames4_ES6.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ var v = {
7070

7171
[`hello ${a} bye`]: 0
7272
>[`hello ${a} bye`] : number
73-
>`hello ${a} bye` : string
73+
>`hello ${a} bye` : `hello ${any} bye`
7474
>a : any
7575
>0 : 0
7676
}

tests/baselines/reference/computedPropertyNames5_ES5.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var v = {
1818

1919
[[]]: 0,
2020
>[[]] : number
21-
>[] : undefined[]
21+
>[] : readonly []
2222
>0 : 0
2323

2424
[{}]: 0,

tests/baselines/reference/computedPropertyNames5_ES6.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var v = {
1818

1919
[[]]: 0,
2020
>[[]] : number
21-
>[] : undefined[]
21+
>[] : readonly []
2222
>0 : 0
2323

2424
[{}]: 0,
Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,13 @@
1-
tests/cases/conformance/expressions/literals/constContextTemplateLiteral.ts(9,24): error TS2418: Type of computed property's value is '{ b: string; }', which is not assignable to type '{ a: any; }'.
2-
Object literal may only specify known properties, and 'b' does not exist in type '{ a: any; }'.
3-
tests/cases/conformance/expressions/literals/constContextTemplateLiteral.ts(10,33): error TS2418: Type of computed property's value is '{ b: string; }', which is not assignable to type '{ a: any; }'.
1+
tests/cases/conformance/expressions/literals/constContextTemplateLiteral.ts(3,24): error TS2418: Type of computed property's value is '{ b: string; }', which is not assignable to type '{ a: any; }'.
42
Object literal may only specify known properties, and 'b' does not exist in type '{ a: any; }'.
53

64

7-
==== tests/cases/conformance/expressions/literals/constContextTemplateLiteral.ts (2 errors) ====
8-
interface Person {
9-
id: number;
10-
name: string;
11-
}
12-
13-
declare function key(): `person-${number}`
14-
/* This only happens if index type is a template literal type */
15-
const persons: Record<`person-${Person["id"]}`, { a: any }> = {
5+
==== tests/cases/conformance/expressions/literals/constContextTemplateLiteral.ts (1 errors) ====
6+
type Person = { id: number }
7+
const persons: Record<string, { a: any }> = {
168
[`person-${1}`]: { b: "something" }, // ok, error
179
~~~~~~~~~~~~~~
1810
!!! error TS2418: Type of computed property's value is '{ b: string; }', which is not assignable to type '{ a: any; }'.
1911
!!! error TS2418: Object literal may only specify known properties, and 'b' does not exist in type '{ a: any; }'.
20-
[`person-${1}` as const]: { b: "something" }, // ok, error
21-
~~~~~~~~~~~~~~
22-
!!! error TS2418: Type of computed property's value is '{ b: string; }', which is not assignable to type '{ a: any; }'.
23-
!!! error TS2418: Object literal may only specify known properties, and 'b' does not exist in type '{ a: any; }'.
24-
[key()]: { b: "something" }, // still no error, it's not a literal
2512
}
2613

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
//// [constContextTemplateLiteral.ts]
2-
interface Person {
3-
id: number;
4-
name: string;
5-
}
6-
7-
declare function key(): `person-${number}`
8-
/* This only happens if index type is a template literal type */
9-
const persons: Record<`person-${Person["id"]}`, { a: any }> = {
2+
type Person = { id: number }
3+
const persons: Record<string, { a: any }> = {
104
[`person-${1}`]: { b: "something" }, // ok, error
11-
[`person-${1}` as const]: { b: "something" }, // ok, error
12-
[key()]: { b: "something" }, // still no error, it's not a literal
135
}
146

157

168
//// [constContextTemplateLiteral.js]
179
var _a;
18-
/* This only happens if index type is a template literal type */
1910
var persons = (_a = {},
2011
_a["person-".concat(1)] = { b: "something" },
21-
_a["person-".concat(1)] = { b: "something" },
22-
_a[key()] = { b: "something" },
2312
_a);
Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,15 @@
11
=== tests/cases/conformance/expressions/literals/constContextTemplateLiteral.ts ===
2-
interface Person {
2+
type Person = { id: number }
33
>Person : Symbol(Person, Decl(constContextTemplateLiteral.ts, 0, 0))
4+
>id : Symbol(id, Decl(constContextTemplateLiteral.ts, 0, 15))
45

5-
id: number;
6-
>id : Symbol(Person.id, Decl(constContextTemplateLiteral.ts, 0, 18))
7-
8-
name: string;
9-
>name : Symbol(Person.name, Decl(constContextTemplateLiteral.ts, 1, 15))
10-
}
11-
12-
declare function key(): `person-${number}`
13-
>key : Symbol(key, Decl(constContextTemplateLiteral.ts, 3, 1))
14-
15-
/* This only happens if index type is a template literal type */
16-
const persons: Record<`person-${Person["id"]}`, { a: any }> = {
17-
>persons : Symbol(persons, Decl(constContextTemplateLiteral.ts, 7, 5))
6+
const persons: Record<string, { a: any }> = {
7+
>persons : Symbol(persons, Decl(constContextTemplateLiteral.ts, 1, 5))
188
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
19-
>Person : Symbol(Person, Decl(constContextTemplateLiteral.ts, 0, 0))
20-
>a : Symbol(a, Decl(constContextTemplateLiteral.ts, 7, 49))
9+
>a : Symbol(a, Decl(constContextTemplateLiteral.ts, 1, 31))
2110

2211
[`person-${1}`]: { b: "something" }, // ok, error
23-
>[`person-${1}`] : Symbol([`person-${1}`], Decl(constContextTemplateLiteral.ts, 7, 63))
24-
>b : Symbol(b, Decl(constContextTemplateLiteral.ts, 8, 22))
25-
26-
[`person-${1}` as const]: { b: "something" }, // ok, error
27-
>[`person-${1}` as const] : Symbol([`person-${1}` as const], Decl(constContextTemplateLiteral.ts, 8, 40))
28-
>const : Symbol(const)
29-
>b : Symbol(b, Decl(constContextTemplateLiteral.ts, 9, 31))
30-
31-
[key()]: { b: "something" }, // still no error, it's not a literal
32-
>[key()] : Symbol([key()], Decl(constContextTemplateLiteral.ts, 9, 49))
33-
>key : Symbol(key, Decl(constContextTemplateLiteral.ts, 3, 1))
34-
>b : Symbol(b, Decl(constContextTemplateLiteral.ts, 10, 14))
12+
>[`person-${1}`] : Symbol([`person-${1}`], Decl(constContextTemplateLiteral.ts, 1, 45))
13+
>b : Symbol(b, Decl(constContextTemplateLiteral.ts, 2, 22))
3514
}
3615

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,19 @@
11
=== tests/cases/conformance/expressions/literals/constContextTemplateLiteral.ts ===
2-
interface Person {
3-
id: number;
2+
type Person = { id: number }
3+
>Person : Person
44
>id : number
55

6-
name: string;
7-
>name : string
8-
}
9-
10-
declare function key(): `person-${number}`
11-
>key : () => `person-${number}`
12-
13-
/* This only happens if index type is a template literal type */
14-
const persons: Record<`person-${Person["id"]}`, { a: any }> = {
15-
>persons : Record<`person-${number}`, { a: any; }>
6+
const persons: Record<string, { a: any }> = {
7+
>persons : Record<string, { a: any; }>
168
>a : any
17-
>{ [`person-${1}`]: { b: "something" }, // ok, error [`person-${1}` as const]: { b: "something" }, // ok, error [key()]: { b: "something" }, // still no error, it's not a literal} : { [x: string]: { b: string; }; "person-1": { b: string; }; }
9+
>{ [`person-${1}`]: { b: "something" }, // ok, error} : { "person-1": { b: string; }; }
1810

1911
[`person-${1}`]: { b: "something" }, // ok, error
2012
>[`person-${1}`] : { b: string; }
2113
>`person-${1}` : "person-1"
2214
>1 : 1
2315
>{ b: "something" } : { b: string; }
2416
>b : string
25-
>"something" : "something"
26-
27-
[`person-${1}` as const]: { b: "something" }, // ok, error
28-
>[`person-${1}` as const] : { b: string; }
29-
>`person-${1}` as const : "person-1"
30-
>`person-${1}` : "person-1"
31-
>1 : 1
32-
>{ b: "something" } : { b: string; }
33-
>b : string
34-
>"something" : "something"
35-
36-
[key()]: { b: "something" }, // still no error, it's not a literal
37-
>[key()] : { b: string; }
38-
>key() : `person-${number}`
39-
>key : () => `person-${number}`
40-
>{ b: "something" } : { b: string; }
41-
>b : string
4217
>"something" : "something"
4318
}
4419

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
type Person = { id: number }
2-
3-
declare function key(): `person-${number}`
4-
/* This only happens if index type is a template literal type */
5-
const persons: Record<`person-${Person["id"]}`, { a: any }> = {
2+
const persons: Record<string, { a: any }> = {
63
[`person-${1}`]: { b: "something" }, // ok, error
7-
// [`person-${1}` as const]: { b: "something" }, // ok, error
8-
// [key()]: { b: "something" }, // still no error, it's not a literal
94
}

0 commit comments

Comments
 (0)