VSCode updated and now ships with 5.7.2 by default. I've noticed this is breaking typing with $ that was previously working. Interestingly, $$ still works fine.
/*
Breaks with:
Error: Type instantiation is excessively deep and possibly infinite.ts(2589)
*/
const breaks = defineQuery('Demo', query => [
query.users({ filter: $('test') }, user => [user.id]),
])
/*
Using $$ works
*/
const works = defineQuery('Demo', query => [
query.users({ filter: $$('test') }, user => [user.id]),
])
/*
Breaks with:
Types of property 'id' are incompatible.
Type '{ equal_to: Variable<unknown, "test">; }' is not assignable to type 'VariableWithoutScalars<null | undefined, any> | IntFilter | (IntFilter & { distinct_from?: undefined; equal_to?: undefined; ... 8 more ...; not_in?: undefined; }) | ... 365 more ... | undefined'.
Types of property 'equal_to' are incompatible.
Type 'Variable<unknown, "test">' is not assignable to type 'number | Variable<number | null | undefined, any> | (number & Variable<number | null | undefined, any>) | (Variable<number | null | undefined, any> & number) | null | undefined'.
Type 'Variable<unknown, "test">' is not assignable to type 'Variable<number | null | undefined, any>'.
Type 'unknown' is not assignable to type 'number | null | undefined'.ts(2322)
graphql.ts(246189, 1): The call would have succeeded against this implementation, but implementation signatures of overloads are not externally visible.
*/
const breaksWithoutTypeCast = defineQuery('Demo', query => [
query.users(
{
filter: {
id: { equal_to: $('test') },
},
},
user => [user.id],
),
])
// This works
const needToTypeCast = defineQuery('Demo', query => [
query.users(
{
filter: {
id: { equal_to: $<number, 'test'>('test') },
},
},
user => [user.id],
),
])
I've tested on TypeScript 5.6 and 5.5 and this issue is not present.
VSCode updated and now ships with 5.7.2 by default. I've noticed this is breaking typing with
$that was previously working. Interestingly,$$still works fine.I've tested on TypeScript 5.6 and 5.5 and this issue is not present.