[BUG] overmind-graphql type is broken
SergeiKalachev opened this issue · 1 comments
@christianalfoni Hello!
I discovered a bug in overmind-graphql
package. I upgraded all packages to the latest versions:
"overmind": "28.0.1",
"overmind-graphql": "8.0.1",
"overmind-react": "29.0.1",
After the upgrade I see TS error in my gql files where gql
function from overmind-graphql
is used:
Argument of type 'TemplateStringsArray' is not assignable to parameter of type 'Literals'.
Type 'TemplateStringsArray' is missing the following properties from type 'string[]': pop, push, reverse, shift, and 6 more.ts(2345)
I took a look at the commits were made in overmind-graphql
and I see the following change: 576c7de#diff-b00535046c2f50ff11c353cc982bfda7a948198ee6e371dfa81a951ead3876ebL127
You extracted the type
type Literals = string | string[]
from the function
export const gql = (literals: string | readonly string[], ...placeholders: any[]): Query<any, any> => gqlTag(literals, ...placeholders) as any
But you removed readonly
keyword (probably because an old version of prettier complains) and it causes the error.
The fix would be to make the type be:
type Literals = string | ReadonlyArray<string>
Then it corresponds to the type from gqlTag, fixes TS error and satisfies eslint/prettier.
Would you mind merging the PR that fixes the issue #527?
#527 is already merged and fixes this issue.