Skip to content

Commit

Permalink
test(groq): fixing groq tests
Browse files Browse the repository at this point in the history
  • Loading branch information
saiichihashimoto committed Jul 21, 2023
1 parent 88935c5 commit b6bc41b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
25 changes: 18 additions & 7 deletions packages/groq/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ describe("groq", () => {
const UNIQUE_VALUE: unique symbol = Symbol("");

expectType<
ExecuteQuery<"@", Scope<any, typeof UNIQUE_VALUE, any>>
ExecuteQuery<"@", Scope<never, typeof UNIQUE_VALUE, never>>
>().toStrictEqual<typeof UNIQUE_VALUE>();
});

it("key", () => {
const UNIQUE_VALUE: unique symbol = Symbol("");

expectType<
ExecuteQuery<"key", Scope<any, { key: typeof UNIQUE_VALUE }, any>>
ExecuteQuery<"key", Scope<never, { key: typeof UNIQUE_VALUE }, never>>
>().toStrictEqual<typeof UNIQUE_VALUE>();
});

Expand All @@ -95,7 +95,10 @@ describe("groq", () => {
const UNIQUE_VALUE: unique symbol = Symbol("");

expectType<
ExecuteQuery<"^", Scope<any, any, Scope<any, typeof UNIQUE_VALUE, any>>>
ExecuteQuery<
"^",
Scope<never, never, Scope<never, typeof UNIQUE_VALUE, never>>
>
>().toStrictEqual<typeof UNIQUE_VALUE>();
});

Expand All @@ -105,7 +108,11 @@ describe("groq", () => {
expectType<
ExecuteQuery<
"^.^",
Scope<any, any, Scope<any, any, Scope<any, typeof UNIQUE_VALUE, any>>>
Scope<
never,
never,
Scope<never, never, Scope<never, typeof UNIQUE_VALUE, never>>
>
>
>().toStrictEqual<typeof UNIQUE_VALUE>();
});
Expand All @@ -117,9 +124,13 @@ describe("groq", () => {
ExecuteQuery<
"^.^.^",
Scope<
any,
any,
Scope<any, any, Scope<any, any, Scope<any, typeof UNIQUE_VALUE, any>>>
never,
never,
Scope<
never,
never,
Scope<never, never, Scope<never, typeof UNIQUE_VALUE, never>>
>
>
>
>().toStrictEqual<typeof UNIQUE_VALUE>();
Expand Down
8 changes: 6 additions & 2 deletions packages/groq/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,12 @@ type Parent<
? Value
: never
: TExpression extends `^.${infer TParents}`
? TScope extends Scope<any, any, infer TParent>
? Parent<TParents, NonNullable<TParent>>
? TScope extends Scope<
any,
any,
infer TParentScope extends Scope<any, any, any>
>
? Parent<TParents, TParentScope>
: never
: never;

Expand Down

0 comments on commit b6bc41b

Please sign in to comment.