diff --git a/tests/baselines/reference/keyofAndIndexedAccess2.errors.txt b/tests/baselines/reference/keyofAndIndexedAccess2.errors.txt index 0dceb11f57f26..f4525727476a8 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess2.errors.txt +++ b/tests/baselines/reference/keyofAndIndexedAccess2.errors.txt @@ -208,6 +208,11 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(108,5): error TS23 // Repro from #31149 function fn3>(param: T, cb: (element: T[number]) => void) { - cb(param[0]); // Argument of type 'string' is not assignable to parameter of type 'T[number]'. + cb(param[0]); + } + + function fn4() { + let x: Array[K] = 'abc'; + let y: ReadonlyArray[K] = 'abc'; } \ No newline at end of file diff --git a/tests/baselines/reference/keyofAndIndexedAccess2.js b/tests/baselines/reference/keyofAndIndexedAccess2.js index 60409d65a38ff..7bf53b9fba491 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess2.js +++ b/tests/baselines/reference/keyofAndIndexedAccess2.js @@ -129,7 +129,12 @@ function fn2>(param: T, cb: (element: T[number]) => void // Repro from #31149 function fn3>(param: T, cb: (element: T[number]) => void) { - cb(param[0]); // Argument of type 'string' is not assignable to parameter of type 'T[number]'. + cb(param[0]); +} + +function fn4() { + let x: Array[K] = 'abc'; + let y: ReadonlyArray[K] = 'abc'; } @@ -215,5 +220,9 @@ function fn2(param, cb) { } // Repro from #31149 function fn3(param, cb) { - cb(param[0]); // Argument of type 'string' is not assignable to parameter of type 'T[number]'. + cb(param[0]); +} +function fn4() { + let x = 'abc'; + let y = 'abc'; } diff --git a/tests/baselines/reference/keyofAndIndexedAccess2.symbols b/tests/baselines/reference/keyofAndIndexedAccess2.symbols index c82129c4da128..2155451ef7497 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess2.symbols +++ b/tests/baselines/reference/keyofAndIndexedAccess2.symbols @@ -483,8 +483,23 @@ function fn3>(param: T, cb: (element: T[number]) >element : Symbol(element, Decl(keyofAndIndexedAccess2.ts, 129, 61)) >T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 129, 13)) - cb(param[0]); // Argument of type 'string' is not assignable to parameter of type 'T[number]'. + cb(param[0]); >cb : Symbol(cb, Decl(keyofAndIndexedAccess2.ts, 129, 55)) >param : Symbol(param, Decl(keyofAndIndexedAccess2.ts, 129, 46)) } +function fn4() { +>fn4 : Symbol(fn4, Decl(keyofAndIndexedAccess2.ts, 131, 1)) +>K : Symbol(K, Decl(keyofAndIndexedAccess2.ts, 133, 13)) + + let x: Array[K] = 'abc'; +>x : Symbol(x, Decl(keyofAndIndexedAccess2.ts, 134, 7)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more) +>K : Symbol(K, Decl(keyofAndIndexedAccess2.ts, 133, 13)) + + let y: ReadonlyArray[K] = 'abc'; +>y : Symbol(y, Decl(keyofAndIndexedAccess2.ts, 135, 7)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --)) +>K : Symbol(K, Decl(keyofAndIndexedAccess2.ts, 133, 13)) +} + diff --git a/tests/baselines/reference/keyofAndIndexedAccess2.types b/tests/baselines/reference/keyofAndIndexedAccess2.types index 91c6d55a6f531..af43ed0f4eb27 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess2.types +++ b/tests/baselines/reference/keyofAndIndexedAccess2.types @@ -479,7 +479,7 @@ function fn3>(param: T, cb: (element: T[number]) >cb : (element: T[number]) => void >element : T[number] - cb(param[0]); // Argument of type 'string' is not assignable to parameter of type 'T[number]'. + cb(param[0]); >cb(param[0]) : void >cb : (element: T[number]) => void >param[0] : string @@ -487,3 +487,15 @@ function fn3>(param: T, cb: (element: T[number]) >0 : 0 } +function fn4() { +>fn4 : () => void + + let x: Array[K] = 'abc'; +>x : string[][K] +>'abc' : "abc" + + let y: ReadonlyArray[K] = 'abc'; +>y : readonly string[][K] +>'abc' : "abc" +} +