You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I expected TypeScript to be able to properly infer value type using this K type.
testForT1 and TestForGeneric should works fine.
Actual behavior:
I can't get V into the proper type using the K I got. testForT1 function worked, but testForGeneric function occured that error.
Type 'T[{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]]' is not assignable to type 'Function'.
Type 'T[T[keyof T] extends Function ? keyof T : never]' is not assignable to type 'Function'.
Type 'T[keyof T]' is not assignable to type 'Function'.
Type 'T[string] | T[number] | T[symbol]' is not assignable to type 'Function'.
Type 'T[string]' is not assignable to type 'Function'.(2322)
TypeScript Version: 3.9.2
Search Terms:
ts type inference by value type
,ts get property name from value type
Expected behavior:
this is an example code of typescriptlang.org : Distributive conditional types
I got
K
type thatT[K]
isFunction
. (following code:)I expected TypeScript to be able to properly infer value type using this
K
type.testForT1 and TestForGeneric should works fine.
Actual behavior:
I can't get V into the proper type using the K I got.
testForT1
function worked, buttestForGeneric
function occured that error.Related Issues:
Code
Output
Compiler Options
Playground Link: Provided
The text was updated successfully, but these errors were encountered: