You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While trying to implement a local tooling pipeline, it seems that it's not quite possible to achieve the same fidelity as hand-written TypeScript definition files.
Given the following demo.res file:
// Demo.res
@genType @ocaml.doc("A module for deciding on a subject matter for a poem.")
moduleDecideSubject= {
@genType.as("payload")
typepayload= {
@genType.as("hint") @ocaml.doc("A hint to use as a guide when thinking of your poem.")
hint: string,
}
@genType.as("input") @ocaml.doc("The input used to generate the prompt and system prompt.")
typeinput
@genType.as("output") @ocaml.doc("The output from evaluating the llm prompt")
typeoutput= {
@genType.as("text") @ocaml.doc("The text of the poem.")
text: string,
@genType.as("prompt") @ocaml.doc("The prompt used to generate the poem.")
prompt: string,
@genType.as("systemPrompt") @ocaml.doc("The system prompt used to generate the poem.")
systemPrompt: string,
}
@genType @ocaml.doc("Decide on a subject matter for a poem.")
let_placeholder= (
@ocaml.doc("The runner specification") run: string,
@ocaml.doc("The number of times to cycle through the runner") times: int,
) => (run, times)->ignore
}
We get out the the Demo.gen.tsx file (I've elided the preamble to just show the relevant parts):
// demo.gen.tsx// tslint:disable-next-line:interface-over-type-literalexporttypeDecideSubject_payload={readonlyhint: string};exporttypepayload=DecideSubject_payload;// tslint:disable-next-line:max-classes-per-fileexportabstractclassDecideSubject_input{protectedopaque!: any;}/* simulate opaque types */exporttypeinput=DecideSubject_input;// tslint:disable-next-line:interface-over-type-literalexporttypeDecideSubject_output={readonlytext: string;readonlyprompt: string;readonlysystemPrompt: string;};exporttypeoutput=DecideSubject_output;/** Decide on a subject matter for a poem. */exportconstDecideSubject__placeholder: (run: string,times: number)=>void=function(Arg1: any,Arg2: any){constresult=Curry._2(DemoBS.DecideSubject._placeholder,Arg1,Arg2);returnresult;};
The docstrings don't carry over for each of the fields, so the consumer of the TypeScript library doesn't get on-hover support
The output names can't be controlled (notice the const output: Demo.DecideSubject_output = {}; vs const output: Demo.DecideSubject.output = {}; in the usage code below
Adding "generatedFileExtension": ".ts" to gentypeconfig in bsconfig.json will output .tsx files instead of .ts (this could be PEBKAC)
The arguments in the placeholder function don't have any docstrings
Here's a screenshot of the pipeline and experience:
Separately, potentially another PEBKAC (maybe mentioned under some special TypeScript mangling rules), the output Demo.bs.js:
// Generated by ReScript, PLEASE EDIT WITH CARE"use strict";function_placeholder(run,times){}varDecideSubject={_placeholder: _placeholder,};exports.DecideSubject=DecideSubject;/* No side effect */
Doesn't have DecideSubject__placeholder, but the generated types export it so it autocompletes, e.g. Demo.DecideSubject__placeholder("run", 1);
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
While trying to implement a local tooling pipeline, it seems that it's not quite possible to achieve the same fidelity as hand-written TypeScript definition files.
Given the following
demo.res
file:We get out the the
Demo.gen.tsx
file (I've elided the preamble to just show the relevant parts):const output: Demo.DecideSubject_output = {};
vsconst output: Demo.DecideSubject.output = {};
in the usage code below"generatedFileExtension": ".ts"
togentypeconfig
inbsconfig.json
will output.tsx
files instead of.ts
(this could be PEBKAC)placeholder
function don't have any docstringsHere's a screenshot of the pipeline and experience:
Separately, potentially another PEBKAC (maybe mentioned under some special TypeScript mangling rules), the output
Demo.bs.js
:Doesn't have
DecideSubject__placeholder
, but the generated types export it so it autocompletes, e.g.Demo.DecideSubject__placeholder("run", 1);
The text was updated successfully, but these errors were encountered: