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
The stringComparer allows us to sort an array, given a string lambda expression. In this case I'm looking to sort my array of books by their title.
However, even though sort is expecting compareFn?: (a: T, b: T) => number and stringComparer delivers on that with (obj1:T, obj2: T) => number there is a problem. The type of x in x => x.title has not flowed though as expected. It is not {title: string}. It's just {}.
I think I've encountered a problem with types flowing down correctly. Take the following code:
The
stringComparer
allows us to sort an array, given a string lambda expression. In this case I'm looking to sort my array of books by their title.However, even though
sort
is expectingcompareFn?: (a: T, b: T) => number
andstringComparer
delivers on that with(obj1:T, obj2: T) => number
there is a problem. The type ofx
inx => x.title
has not flowed though as expected. It is not{title: string}
. It's just{}
.You can see this in the playground here
I'm not certain if this is a but or if I've missed a trick here - I thought I'd best report it just in case.
The text was updated successfully, but these errors were encountered: