ScalablyTyped/Converter

Parser failure in @supabase/postgrest-js

keynmol opened this issue · 1 comments

On Discord @oyvindberg pointed out that even if it worked, it'd be useless because of this beauty

  1. cd $(mktemp -d) && npm install @supabase/postgrest-js typescript
  2. cs launch stc
[error] 2023-03-29T19:03:44.376261Z Phase1ReadTypescript.scala:72 message Couldn't parse: Parse error at 56.174 end of input expected [id => @supabase/postgrest-js, thread => 1, phase => typescript, file => ../dist/module/select-query-parser.d.ts]com.olvind.logging.Logger$LoggedException: Couldn't parse: Parse error at 56.174 end of input expected
        at com.olvind.logging.Logger$LoggingOps$.fatal$extension(Logger.scala:178)
        at org.scalablytyped.converter.internal.importer.Phase1ReadTypescript.$anonfun$apply$4(Phase1ReadTypescript.scala:72)
        at org.scalablytyped.converter.internal.importer.Lazy$$anon$1.get(Lazy.scala:30)
        at org.scalablytyped.converter.internal.importer.Phase1ReadTypescript.$anonfun$apply$22(Phase1ReadTypescript.scala:198)
        at org.scalablytyped.converter.internal.importer.Phase1ReadTypescript.apply(Phase1ReadTypescript.scala:198)
        at org.scalablytyped.converter.internal.importer.Phase1ReadTypescript.apply(Phase1ReadTypescript.scala:19)
        at org.scalablytyped.converter.internal.phases.PhaseRunner$.$anonfun$doNext$4(PhaseRunner.scala:71)
        at org.scalablytyped.converter.internal.phases.PhaseRunner$.$anonfun$doNext$3(PhaseRunner.scala:71)
        at org.scalablytyped.converter.internal.phases.PhaseRes.flatMap(PhaseRes.scala:26)
        at org.scalablytyped.converter.internal.phases.PhaseRes.flatMap$(PhaseRes.scala:24)
        at org.scalablytyped.converter.internal.phases.PhaseRes$Ok.flatMap(PhaseRes.scala:33)
        at org.scalablytyped.converter.internal.phases.PhaseRunner$.$anonfun$doNext$1(PhaseRunner.scala:70)
        at org.scalablytyped.converter.internal.phases.PhaseCache.getOrElse(PhaseCache.scala:26)
        at org.scalablytyped.converter.internal.phases.PhaseRunner$.$anonfun$doNext$1(PhaseRunner.scala:47)

I'm gonna go ahead and close this.

Here is the type:

declare type ConstructFieldDefinition<Schema extends GenericSchema, Row extends Record<string, unknown>, Relationships, Field> = Field extends {
    star: true;
} ? Row : Field extends {
    name: string;
    original: string;
    hint: string;
    children: unknown[];
} ? {
    [_ in Field['name']]: GetResultHelper<Schema, (Schema['Tables'] & Schema['Views'])[Field['original']]['Row'], (Schema['Tables'] & Schema['Views'])[Field['original']] extends {
        Relationships: infer R;
    } ? R : unknown, Field['children'], unknown> extends infer Child ? Relationships extends unknown[] ? HasFKey<Field['hint'], Relationships> extends true ? Child | null : Child[] : Child[] : never;
} : Field extends {
    name: string;
    original: string;
    children: unknown[];
} ? {
    [_ in Field['name']]: GetResultHelper<Schema, (Schema['Tables'] & Schema['Views'])[Field['original']]['Row'], (Schema['Tables'] & Schema['Views'])[Field['original']] extends {
        Relationships: infer R;
    } ? R : unknown, Field['children'], unknown> extends infer Child ? Relationships extends unknown[] ? HasFKeyToFRel<Field['original'], Relationships> extends true ? Child | null : Child[] : Child[] : never;
} : Field extends {
    name: string;
    original: string;
} ? Field['original'] extends keyof Row ? {
    [K in Field['name']]: Row[Field['original']];
} : SelectQueryError<`Referencing missing column \`${Field['original']}\``> : Field extends {
    name: string;
    type: infer T;
} ? {
    [K in Field['name']]: T;
} : Record<string, unknown>;

PR welcome to fix the parser 😎