Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mrichards42
Copy link
Contributor

πŸ‘‹ Hi folks, thanks for a great library! I came across what looks like a typing bug to me:


The first overload of TypePreservingAggregation (taking columnName and options) used Readonly<TKey> for the columnName type. In this context, TKey is supposed to be a single column name, but Readonly<TKey> maps over the full constraint of keyof ResolveTableType<TRecord>.

This results in TKey being a union of all keys in the table, rather than a single key. Because of this, the result type ends up being a union of all values in the table.

The fix is to remove the Readonly type, which is fine since TKey is a string and not an object like in the other overloads.

The first overload of TypePreservingAggregation (taking columnName and
options) used `Readonly<TKey>` for the columnName type. In this context,
`TKey` is supposed to be a single column name, but `Readonly<TKey>` maps
over the full constraint of `ResolveTableType<TRecord>`.

This results in `TKey` being a union of all keys in the table, rather
than a single key. Because of this, the result type ends up being a
union of all values in the table.

The fix is to remove the `Readonly` type, which is fine since `TKey` is
a string and not an object like in the other overloads.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 92.27% when pulling c748f39 on mrichards42:fix-aggregation-type into 2dadde4 on knex:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants