Reduce test case + update baselines

This commit is contained in:
Nathan Shively-Sanders 2021-10-21 11:10:04 -07:00
parent 16db880e02
commit ea7d4c62c9
25 changed files with 39 additions and 114 deletions

View file

@ -60,6 +60,6 @@ var v = {
[`hello ${a} bye`]() { } [`hello ${a} bye`]() { }
>[`hello ${a} bye`] : () => void >[`hello ${a} bye`] : () => void
>`hello ${a} bye` : string >`hello ${a} bye` : `hello ${any} bye`
>a : any >a : any
} }

View file

@ -60,6 +60,6 @@ var v = {
[`hello ${a} bye`]() { } [`hello ${a} bye`]() { }
>[`hello ${a} bye`] : () => void >[`hello ${a} bye`] : () => void
>`hello ${a} bye` : string >`hello ${a} bye` : `hello ${any} bye`
>a : any >a : any
} }

View file

@ -70,7 +70,7 @@ var v = {
get [`hello ${a} bye`]() { return 0; } get [`hello ${a} bye`]() { return 0; }
>[`hello ${a} bye`] : number >[`hello ${a} bye`] : number
>`hello ${a} bye` : string >`hello ${a} bye` : `hello ${any} bye`
>a : any >a : any
>0 : 0 >0 : 0
} }

View file

@ -70,7 +70,7 @@ var v = {
get [`hello ${a} bye`]() { return 0; } get [`hello ${a} bye`]() { return 0; }
>[`hello ${a} bye`] : number >[`hello ${a} bye`] : number
>`hello ${a} bye` : string >`hello ${a} bye` : `hello ${any} bye`
>a : any >a : any
>0 : 0 >0 : 0
} }

View file

@ -63,7 +63,7 @@ class C {
static [`hello ${a} bye`] = 0 static [`hello ${a} bye`] = 0
>[`hello ${a} bye`] : number >[`hello ${a} bye`] : number
>`hello ${a} bye` : string >`hello ${a} bye` : `hello ${any} bye`
>a : any >a : any
>0 : 0 >0 : 0
} }

View file

@ -63,7 +63,7 @@ class C {
static [`hello ${a} bye`] = 0 static [`hello ${a} bye`] = 0
>[`hello ${a} bye`] : number >[`hello ${a} bye`] : number
>`hello ${a} bye` : string >`hello ${a} bye` : `hello ${any} bye`
>a : any >a : any
>0 : 0 >0 : 0
} }

View file

@ -59,6 +59,6 @@ class C {
static [`hello ${a} bye`]() { } static [`hello ${a} bye`]() { }
>[`hello ${a} bye`] : () => void >[`hello ${a} bye`] : () => void
>`hello ${a} bye` : string >`hello ${a} bye` : `hello ${any} bye`
>a : any >a : any
} }

View file

@ -59,6 +59,6 @@ class C {
static [`hello ${a} bye`]() { } static [`hello ${a} bye`]() { }
>[`hello ${a} bye`] : () => void >[`hello ${a} bye`] : () => void
>`hello ${a} bye` : string >`hello ${a} bye` : `hello ${any} bye`
>a : any >a : any
} }

View file

@ -15,7 +15,7 @@ class C {
[[]]() { } [[]]() { }
>[[]] : () => void >[[]] : () => void
>[] : undefined[] >[] : readonly []
static [{}]() { } static [{}]() { }
>[{}] : () => void >[{}] : () => void

View file

@ -15,7 +15,7 @@ class C {
[[]]() { } [[]]() { }
>[[]] : () => void >[[]] : () => void
>[] : undefined[] >[] : readonly []
static [{}]() { } static [{}]() { }
>[{}] : () => void >[{}] : () => void

View file

@ -69,7 +69,7 @@ class C {
get [`hello ${a} bye`]() { return 0; } get [`hello ${a} bye`]() { return 0; }
>[`hello ${a} bye`] : number >[`hello ${a} bye`] : number
>`hello ${a} bye` : string >`hello ${a} bye` : `hello ${any} bye`
>a : any >a : any
>0 : 0 >0 : 0
} }

View file

@ -69,7 +69,7 @@ class C {
get [`hello ${a} bye`]() { return 0; } get [`hello ${a} bye`]() { return 0; }
>[`hello ${a} bye`] : number >[`hello ${a} bye`] : number
>`hello ${a} bye` : string >`hello ${a} bye` : `hello ${any} bye`
>a : any >a : any
>0 : 0 >0 : 0
} }

View file

@ -17,7 +17,7 @@ class C {
get [[]]() { return 0; } get [[]]() { return 0; }
>[[]] : number >[[]] : number
>[] : undefined[] >[] : readonly []
>0 : 0 >0 : 0
set [{}](v) { } set [{}](v) { }

View file

@ -17,7 +17,7 @@ class C {
get [[]]() { return 0; } get [[]]() { return 0; }
>[[]] : number >[[]] : number
>[] : undefined[] >[] : readonly []
>0 : 0 >0 : 0
set [{}](v) { } set [{}](v) { }

View file

@ -22,7 +22,7 @@ class C {
set [[0, 1]](v) { } set [[0, 1]](v) { }
>[[0, 1]] : any >[[0, 1]] : any
>[0, 1] : number[] >[0, 1] : readonly [0, 1]
>0 : 0 >0 : 0
>1 : 1 >1 : 1
>v : any >v : any

View file

@ -22,7 +22,7 @@ class C {
set [[0, 1]](v) { } set [[0, 1]](v) { }
>[[0, 1]] : any >[[0, 1]] : any
>[0, 1] : number[] >[0, 1] : readonly [0, 1]
>0 : 0 >0 : 0
>1 : 1 >1 : 1
>v : any >v : any

View file

@ -70,7 +70,7 @@ var v = {
[`hello ${a} bye`]: 0 [`hello ${a} bye`]: 0
>[`hello ${a} bye`] : number >[`hello ${a} bye`] : number
>`hello ${a} bye` : string >`hello ${a} bye` : `hello ${any} bye`
>a : any >a : any
>0 : 0 >0 : 0
} }

View file

@ -70,7 +70,7 @@ var v = {
[`hello ${a} bye`]: 0 [`hello ${a} bye`]: 0
>[`hello ${a} bye`] : number >[`hello ${a} bye`] : number
>`hello ${a} bye` : string >`hello ${a} bye` : `hello ${any} bye`
>a : any >a : any
>0 : 0 >0 : 0
} }

View file

@ -18,7 +18,7 @@ var v = {
[[]]: 0, [[]]: 0,
>[[]] : number >[[]] : number
>[] : undefined[] >[] : readonly []
>0 : 0 >0 : 0
[{}]: 0, [{}]: 0,

View file

@ -18,7 +18,7 @@ var v = {
[[]]: 0, [[]]: 0,
>[[]] : number >[[]] : number
>[] : undefined[] >[] : readonly []
>0 : 0 >0 : 0
[{}]: 0, [{}]: 0,

View file

@ -1,26 +1,13 @@
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; }'. 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; }'.
Object literal may only specify known properties, and 'b' does not exist in type '{ a: any; }'.
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; }'.
Object literal may only specify known properties, and 'b' does not exist in type '{ a: any; }'. Object literal may only specify known properties, and 'b' does not exist in type '{ a: any; }'.
==== tests/cases/conformance/expressions/literals/constContextTemplateLiteral.ts (2 errors) ==== ==== tests/cases/conformance/expressions/literals/constContextTemplateLiteral.ts (1 errors) ====
interface Person { type Person = { id: number }
id: number; const persons: Record<string, { a: any }> = {
name: string;
}
declare function key(): `person-${number}`
/* This only happens if index type is a template literal type */
const persons: Record<`person-${Person["id"]}`, { a: any }> = {
[`person-${1}`]: { b: "something" }, // ok, error [`person-${1}`]: { b: "something" }, // ok, error
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
!!! error TS2418: Type of computed property's value is '{ b: string; }', which is not assignable to type '{ a: any; }'. !!! error TS2418: Type of computed property's value is '{ b: string; }', which is not assignable to type '{ a: any; }'.
!!! error TS2418: Object literal may only specify known properties, and 'b' does not exist in type '{ a: any; }'. !!! error TS2418: Object literal may only specify known properties, and 'b' does not exist in type '{ a: any; }'.
[`person-${1}` as const]: { b: "something" }, // ok, error
~~~~~~~~~~~~~~
!!! error TS2418: Type of computed property's value is '{ b: string; }', which is not assignable to type '{ a: any; }'.
!!! error TS2418: Object literal may only specify known properties, and 'b' does not exist in type '{ a: any; }'.
[key()]: { b: "something" }, // still no error, it's not a literal
} }

View file

@ -1,23 +1,12 @@
//// [constContextTemplateLiteral.ts] //// [constContextTemplateLiteral.ts]
interface Person { type Person = { id: number }
id: number; const persons: Record<string, { a: any }> = {
name: string;
}
declare function key(): `person-${number}`
/* This only happens if index type is a template literal type */
const persons: Record<`person-${Person["id"]}`, { a: any }> = {
[`person-${1}`]: { b: "something" }, // ok, error [`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
} }
//// [constContextTemplateLiteral.js] //// [constContextTemplateLiteral.js]
var _a; var _a;
/* This only happens if index type is a template literal type */
var persons = (_a = {}, var persons = (_a = {},
_a["person-".concat(1)] = { b: "something" }, _a["person-".concat(1)] = { b: "something" },
_a["person-".concat(1)] = { b: "something" },
_a[key()] = { b: "something" },
_a); _a);

View file

@ -1,36 +1,15 @@
=== tests/cases/conformance/expressions/literals/constContextTemplateLiteral.ts === === tests/cases/conformance/expressions/literals/constContextTemplateLiteral.ts ===
interface Person { type Person = { id: number }
>Person : Symbol(Person, Decl(constContextTemplateLiteral.ts, 0, 0)) >Person : Symbol(Person, Decl(constContextTemplateLiteral.ts, 0, 0))
>id : Symbol(id, Decl(constContextTemplateLiteral.ts, 0, 15))
id: number; const persons: Record<string, { a: any }> = {
>id : Symbol(Person.id, Decl(constContextTemplateLiteral.ts, 0, 18)) >persons : Symbol(persons, Decl(constContextTemplateLiteral.ts, 1, 5))
name: string;
>name : Symbol(Person.name, Decl(constContextTemplateLiteral.ts, 1, 15))
}
declare function key(): `person-${number}`
>key : Symbol(key, Decl(constContextTemplateLiteral.ts, 3, 1))
/* This only happens if index type is a template literal type */
const persons: Record<`person-${Person["id"]}`, { a: any }> = {
>persons : Symbol(persons, Decl(constContextTemplateLiteral.ts, 7, 5))
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) >Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
>Person : Symbol(Person, Decl(constContextTemplateLiteral.ts, 0, 0)) >a : Symbol(a, Decl(constContextTemplateLiteral.ts, 1, 31))
>a : Symbol(a, Decl(constContextTemplateLiteral.ts, 7, 49))
[`person-${1}`]: { b: "something" }, // ok, error [`person-${1}`]: { b: "something" }, // ok, error
>[`person-${1}`] : Symbol([`person-${1}`], Decl(constContextTemplateLiteral.ts, 7, 63)) >[`person-${1}`] : Symbol([`person-${1}`], Decl(constContextTemplateLiteral.ts, 1, 45))
>b : Symbol(b, Decl(constContextTemplateLiteral.ts, 8, 22)) >b : Symbol(b, Decl(constContextTemplateLiteral.ts, 2, 22))
[`person-${1}` as const]: { b: "something" }, // ok, error
>[`person-${1}` as const] : Symbol([`person-${1}` as const], Decl(constContextTemplateLiteral.ts, 8, 40))
>const : Symbol(const)
>b : Symbol(b, Decl(constContextTemplateLiteral.ts, 9, 31))
[key()]: { b: "something" }, // still no error, it's not a literal
>[key()] : Symbol([key()], Decl(constContextTemplateLiteral.ts, 9, 49))
>key : Symbol(key, Decl(constContextTemplateLiteral.ts, 3, 1))
>b : Symbol(b, Decl(constContextTemplateLiteral.ts, 10, 14))
} }

View file

@ -1,20 +1,12 @@
=== tests/cases/conformance/expressions/literals/constContextTemplateLiteral.ts === === tests/cases/conformance/expressions/literals/constContextTemplateLiteral.ts ===
interface Person { type Person = { id: number }
id: number; >Person : Person
>id : number >id : number
name: string; const persons: Record<string, { a: any }> = {
>name : string >persons : Record<string, { a: any; }>
}
declare function key(): `person-${number}`
>key : () => `person-${number}`
/* This only happens if index type is a template literal type */
const persons: Record<`person-${Person["id"]}`, { a: any }> = {
>persons : Record<`person-${number}`, { a: any; }>
>a : any >a : any
>{ [`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; }; } >{ [`person-${1}`]: { b: "something" }, // ok, error} : { "person-1": { b: string; }; }
[`person-${1}`]: { b: "something" }, // ok, error [`person-${1}`]: { b: "something" }, // ok, error
>[`person-${1}`] : { b: string; } >[`person-${1}`] : { b: string; }
@ -22,23 +14,6 @@ const persons: Record<`person-${Person["id"]}`, { a: any }> = {
>1 : 1 >1 : 1
>{ b: "something" } : { b: string; } >{ b: "something" } : { b: string; }
>b : string >b : string
>"something" : "something"
[`person-${1}` as const]: { b: "something" }, // ok, error
>[`person-${1}` as const] : { b: string; }
>`person-${1}` as const : "person-1"
>`person-${1}` : "person-1"
>1 : 1
>{ b: "something" } : { b: string; }
>b : string
>"something" : "something"
[key()]: { b: "something" }, // still no error, it's not a literal
>[key()] : { b: string; }
>key() : `person-${number}`
>key : () => `person-${number}`
>{ b: "something" } : { b: string; }
>b : string
>"something" : "something" >"something" : "something"
} }

View file

@ -1,9 +1,4 @@
type Person = { id: number } type Person = { id: number }
const persons: Record<string, { a: any }> = {
declare function key(): `person-${number}`
/* This only happens if index type is a template literal type */
const persons: Record<`person-${Person["id"]}`, { a: any }> = {
[`person-${1}`]: { b: "something" }, // ok, error [`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
} }