From d1f59c99a455e831e1659682df96547cb1ea102a Mon Sep 17 00:00:00 2001 From: Ben Merckx Date: Tue, 12 Nov 2024 11:07:30 +0530 Subject: [PATCH] Add entry fields to inferred types --- src/core/Graph.ts | 4 +--- src/core/Infer.ts | 11 +++-------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/core/Graph.ts b/src/core/Graph.ts index db2d5316..c50877bf 100644 --- a/src/core/Graph.ts +++ b/src/core/Graph.ts @@ -77,9 +77,7 @@ type InferResult = Selection extends Expr< : Selection extends undefined ? Types extends undefined ? EntryFields & (Include extends undefined ? {} : InferSelection) - : Infer & - EntryFields & - (Include extends undefined ? {} : InferSelection) + : Infer & (Include extends undefined ? {} : InferSelection) : InferSelection type QueryResult = Expand< diff --git a/src/core/Infer.ts b/src/core/Infer.ts index 9f218ad0..07b8325f 100644 --- a/src/core/Infer.ts +++ b/src/core/Infer.ts @@ -1,24 +1,19 @@ import {Expand, UnionOfValues} from 'alinea/core/util/Types' +import {EntryFields} from './EntryFields.js' import {Expr} from './Expr.js' import {Field} from './Field.js' import {Type} from './Type.js' type QueryList = Expand< UnionOfValues<{ - [K in keyof T]: {_type: K} & QueryRow + [K in keyof T]: {_type: K} & Type.Infer }> > -export type QueryRow = { - [K in keyof Definition as Definition[K] extends Expr - ? K - : never]: Definition[K] extends Expr ? T : never -} - export type InferQueryValue = T extends Array> ? InferQueryValue : T extends Type - ? QueryRow + ? Type.Infer & EntryFields : T extends Expr ? QueryValue : T extends Record