Skip to content

Commit 803c861

Browse files
committed
chore: stricter helper types
1 parent e961e94 commit 803c861

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/select-query-parser/result.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export type ProcessEmbeddedResource<
198198
Schema extends GenericSchema,
199199
Relationships extends GenericRelationship[],
200200
Field extends Ast.FieldNode,
201-
CurrentTableOrView extends keyof TablesAndViews<Schema>
201+
CurrentTableOrView extends keyof TablesAndViews<Schema> & string
202202
> = ResolveRelationship<Schema, Relationships, Field, CurrentTableOrView> extends infer Resolved
203203
? Resolved extends {
204204
referencedTable: Pick<GenericTable, 'Row' | 'Relationships'>

src/select-query-parser/utils.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import {
1212

1313
export type SelectQueryError<Message extends string> = { error: true } & Message
1414

15-
type AsString<T> = T extends string ? T : ''
16-
1715
type RequireHintingSelectQueryError<
1816
DistantName extends string,
1917
RelationName extends string
@@ -207,7 +205,7 @@ export type ResolveRelationship<
207205
Schema extends GenericSchema,
208206
Relationships extends GenericRelationship[],
209207
Field extends Ast.FieldNode,
210-
CurrentTableOrView extends keyof TablesAndViews<Schema>
208+
CurrentTableOrView extends keyof TablesAndViews<Schema> & string
211209
> = ResolveReverseRelationship<
212210
Schema,
213211
Relationships,
@@ -387,7 +385,7 @@ type FilterRelationships<R, TName, From> = R extends readonly (infer Rel)[]
387385
type ResolveForwardRelationship<
388386
Schema extends GenericSchema,
389387
Field extends Ast.FieldNode,
390-
CurrentTableOrView extends keyof TablesAndViews<Schema>
388+
CurrentTableOrView extends keyof TablesAndViews<Schema> & string
391389
> = FindFieldMatchingRelationships<
392390
Schema,
393391
TablesAndViews<Schema>[Field['name']]['Relationships'],
@@ -432,7 +430,7 @@ type ResolveForwardRelationship<
432430
from: CurrentTableOrView
433431
type: 'found-by-join-table'
434432
}
435-
: SelectQueryError<`could not find the relation between ${AsString<CurrentTableOrView>} and ${Field['name']}`>
433+
: SelectQueryError<`could not find the relation between ${CurrentTableOrView} and ${Field['name']}`>
436434

437435
/**
438436
* Given a CurrentTableOrView, finds all join tables to this relation.
@@ -454,7 +452,7 @@ type ResolveForwardRelationship<
454452
*/
455453
export type FindJoinTableRelationship<
456454
Schema extends GenericSchema,
457-
CurrentTableOrView extends keyof TablesAndViews<Schema>,
455+
CurrentTableOrView extends keyof TablesAndViews<Schema> & string,
458456
FieldName extends string
459457
> = {
460458
[TableName in keyof TablesAndViews<Schema>]: TablesAndViews<Schema>[TableName]['Relationships'] extends readonly (infer Rel)[]

0 commit comments

Comments
 (0)