How to use @taggedTemplate generate js with tagged template literals

I am using Rescript v11 to bind the Postgress.js API. Since returned by the “make” binding is a tagged Template function , I cannot use @taggedTemplate to descript it. The generated js file is not with tagged Template. How can I use @taggedTemplate so that gen the js code with tagged Template ?

[GitHub - porsager/postgres: Postgres.js]
(GitHub - porsager/postgres: Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare)

bind

type t<'sqlParam, 'data> = (array<string>, array<'sqlParam>) => promise<result<'data>>
@module("postgres") external make: (~url: string, ~config: config=?) => t<'sqlParam, 'data> = "default"

usage

let sql = Postgresql.make(~url="postgres://xxx:xxxx@localhost:5432/xxxxxx")
let abc = "abc"
let result: Postgresql.result<userInfo> = await sql`select name, sigup_date from user_tbl where name=${ abc }`

output:

var result = await sql([
              "select name, sigup_date from user_tbl where name=",
              ""
            ], ["abc"]);

Hi @liang, sorry for the late reply but there’s no easy way to do this today, we should support such tags (like @taggedTemplate or @variadic) in function parameters which we don’t today. It was too much of a pain originally, but I’ll take a look at it now that v12 is uncurried only and has a cleaner AST.

1 Like