[ANN] rescript-vitest 2.0 - uncurried mode, explicit bindings, etc
If you expect seamless integration with tools like Vitest explorer, sourcemap alone doesn’t help, it needs syntax analyzation from a dedicated extension, which is pretty overkill to me. And...
View Article[ANN] rescript-vitest 2.0 - uncurried mode, explicit bindings, etc
Thank you for your reply I feel that the Vitest Explorer, while powerful, is an extra step that isn’t strictly necessary for most of our workflows. It’s a nice-to-have but doesn’t really address the...
View ArticleHow to pass a component constructor as a prop
In React something I often do when creating a component library is something like this: type Props = { icon: JSXElementConstructor<{ className?: string }> } const SomeComponent = ({ icon: Icon...
View ArticleHow to pass a component constructor as a prop
Yes! It is possible with first-class modules: type iconProps = { size?: int, color?: string, strokeWidth?: int, absoluteStrokeWidth?: bool, className?: string, } module type Icon = { let make:...
View ArticleHow to pass a component constructor as a prop
Amazing, thank you so much! I’ll definitely need to look more into first class modules to understand how this actually works. But I was able to get optional icons working based off the code you...
View ArticleHow to pass a component constructor as a prop
Ah yes that is shorter. I typically just use render functions which are most of the time sufficient for my needs. I think this is the first time I see an FCM as a default parameter. We usually don’t...
View ArticleHow to pass a component constructor as a prop
What do you mean by “I typically just use render functions which are most of the time sufficient for my needs?” Also if there is a more idiomatic ReScript way to solve this problem I’d love to know, I...
View ArticleHow to pass a component constructor as a prop
Something like this: type iconProps = { size?: int, color?: string, strokeWidth?: int, absoluteStrokeWidth?: bool, className?: string, } module Check = { @module("lucide-react") external make:...
View ArticleHow to pass a component constructor as a prop
That seems super obvious in retrospect! I think I prefer it too, and I don’t mind losing the JSX. Thanks!
View Article[ANN] rescript-vitest 2.0 - uncurried mode, explicit bindings, etc
Yes, it’s more difficult than having our own extension. I’ve looked into Vitest a bit more, but even if we support sourcemap, there’s no guarantee that it will be reflected in the Vitest report...
View ArticleWebapi and input files
github.com TheSpyder/rescript-webapi/blob/main/src/Webapi/Dom/Webapi__Dom__HtmlInputElement.res#L102 /* Properties not yet categorized */ @get external defaultValue: t_htmlInputElement => string =...
View ArticleWebapi and input files
I’ve adapted my code (which parses a CSV file) to your requirements. module File = { type t } module FileReader = { type t type event = [ | #load | #abort ] @new external make: unit => t =...
View ArticleWebapi and input files
Thanks. That clears up the filereader. However I’m not using react or jsx. If it wasn’t clear by my need for webapi to get the input element. It’s for a chrome extension. I don’t own the input...
View ArticleWebapi and input files
Ok. That should be a matter of making the right bindings. Here is an attempt that adds a binding to the existing webapi bindings, combining it with the File.t module I defined in my previous post:...
View ArticleWebapi and input files
Meanwhile, here is an attempt to build minimal bindings to file input, independent of rescript-webapi. // File APIs. Also borrow the FileReader bindings from my previous post. module File = { type t }...
View ArticleWebapi and input files
The tests, while many of them are incomplete, show a rough guideline of how to start using the HtmlInputElement api (this pattern actually works for all element types): github.com...
View ArticleTrying to remove Caml_option in the generated JS
Hi there ! I have written a small library that I want to publish without any external dependencies. The only dependency left, is this: var p = proxied[extra$1]; if (p !== undefined) { return...
View ArticleTrying to remove Caml_option in the generated JS
I rewrote the code with a version of Dict that uses Reflect and check for existing key with Reflect.has. Still curious if there are any tricks for my weird use case (create a TypeScript and ReScript...
View ArticleTrying to remove Caml_option in the generated JS
It’s something that can hopefully be improved in the future, but for now the recommended approach is to use a bundler before publishing.
View ArticleTrying to remove Caml_option in the generated JS
One thing you can do is to create your own Dict bindings that return nullable instead of Option. module Dict = { type t<'a> = dict<'a> @get_index external get: (dict<'a>, string)...
View Article