Nameof operator
I can understand this. Accessing by keys rarely happens in pure ReScript code, but is useful when interacting with external JS codes. I used this pattenrs a lot type key = | @as("preferred_language")...
View ArticleCustom data-attributes in JSX
Hi, I want to propose Rescript in the company, starting with small individual components. The project I am working on uses libraries that rely heavily on data-attributes. In our own components we also...
View ArticleCustom data-attributes in JSX
So you’re saying all your elements don’t expect the same data attributes? How would you do it in a type-safe way in typescript? My advice would be to override the element attributes with all the data...
View ArticleCustom data-attributes in JSX
You can find bellow a working version in ReScript of your code, don’t forget to enable auto-run if you want to test it live. You can notice how close to the typescript version it is, it’s almost...
View ArticleCustom data-attributes in JSX
Small correction, the binding should obviously not be to “data-custom-state”, but “data-variant”.
View Article[Help wanted] Improving "Somewhere wanted" error messages
Came across this error where my function expects a tuple, but I pass two args instead. It’s hard to catch and tuples aren’t a common datatype in js. I think it could be helpful to add a suggestion to...
View Article[Help wanted] Improving "Somewhere wanted" error messages
Ahh very good idea to improve that.
View ArticleCustom data-attributes in JSX
Thank you for the link to playground with the code example. Now I understand where I was making a mistake. Thank You a lot! I’ll admit that this overwriting of modules, adding external is a bit...
View ArticleCustom data-attributes in JSX
No no, you only have to define it once in your whole project!
View ArticlePlayground - Core library error
I’m trying to run some simple code in the Playground and am getting an error when using auto-run feature: let mult = (a, b) => a * b let n = [1,2,3,4]->Array.reduce(1, mult) Console.log(n)...
View ArticlePlayground - Core library error
This is unfortunately a known bug, the js/runtime part of the libraries are not loaded, hopefully will be fixed when I have some free time ^^ If anybody wants to take a stab at it, don’t hesitate!
View Article[Help wanted] Improving "Somewhere wanted" error messages
This isn’t a “Somewhere wanted” error message but it is likely confusing to beginners regardless– type a = { "one": int } @val external myA: a = "a"; let b = switch myA { | { "one": 1 } => "foo" |...
View ArticleRescript vanilla web components (classes)
Web components have a class based API Is there a way to model using pure rescript? guess no, as there is no class construct equivalent Is there a way to bind rescript to js class definitions?
View ArticleLeverage ES decorators
JS has stage 3 decorators proposal Would it be posible/considered to use ES decorators from rescript? @defineElement("my-class") class C extends HTMLElement { @reactive accessor clicked = false; }
View ArticleRescript vanilla web components (classes)
Is there a way to model using pure rescript? guess no, as there is no class construct equivalent @@jsxConfig({ version: 4, mode: “automatic” }) Correct. There’s not a way to create classes in pure...
View ArticleRescript vanilla web components (classes)
Just tried out some stuff with web components a few months ago: let define: options => unit = %ffi(` function(options) { const clazz = class extends HTMLElement { constructor() { super() }...
View ArticleLeverage ES decorators
Only inside of the %%raw() block, since ReScript doesn’t support classes directly.
View ArticleMaking a module optional in a parent module signature
I’m creating a module signature and I would like to make a react component optional. I haven’t found a way yet how to do it? In the example below, I would like to make PageSubtitle optional so if I...
View ArticleMaking a module optional in a parent module signature
What are you trying to achieve? How would you use such a module? There are other ways to provide a set of functions, you could use a record for example.
View Article