Open
Description
Rescript v11.1.3
Writing the following code:
@genType.import(("@supabase/supabase-js", "SupabaseClient"))
type client<'database>
@genType.import("@supabase/supabase-js")
external createClient: (int, string) => client<'database> = "createClient"
generates the following typescript:
import {createClient as createClientNotChecked} from '@supabase/supabase-js';
// In case of type error, check the type of 'createClient' in 'Supabase.res' and '@supabase/supabase-js'.
export const createClientTypeChecked: <database>(_1:number, _2:string) => client<database> = createClientNotChecked as any;
// Export 'createClient' early to allow circular import from the '.bs.js' file.
export const createClient: unknown = createClientTypeChecked as <database>(_1:number, _2:string) => client<database> as any;
import type {SupabaseClient as $$client} from '@supabase/supabase-js';
export type client<database> = $$client<database>;
This should fail tsc typechecking, because the API of createClient
is (string, string)
, not (int, string)
. It doesn't however, because of createClientNotChecked as any
. Simply removing that as any
makes tsc complain and therefore fixes this issue.
At first I thought this was a deliberate change from previous versions of genType, and asked about that on the forum, but now I think that it's a bug due to the wording of the comment in the generated typescript:
// In case of type error, check the type of 'createClient' in 'Supabase.res' and '@supabase/supabase-js'.
I would argue that the generated code is not doing what that comment says it is doing.
Maybe I have made a mistake somewhere 😅 thanks for your help!
Metadata
Metadata
Assignees
Labels
No labels