-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature request] Integrate with @deriving({abstract: light})
#183
Comments
Deriving abstract is expected to be used less and less in future. Either objects, or records, in the latest compiler versions, should be able to express all the needed functionality. |
We use it heavily in a custom integration we have of a React-like framework based on Mithril -- this is mainly because our app is offline-first and the connection is very limited; so we wanted a really small library. This, is for instance a very small component: open Prelude
open Mithril
open CompletionStatus
@deriving({abstract: light})
type makeProps = {
@optional completion: completionInformation,
@optional children: element,
}
let make = _ => {
component()->view(vnode => {
let completion = vnode.attrs->completion->default(CompletionStatus.Defaults.completion)
let {totalNested, totalInspected, isOverdue} = completion
<div className="tile-action">
{show(
if completion->isFullyInspected {
<Feather icon=#check_circle className="text-success" />
} else {
<span className={isOverdue ? "text-error" : ""}>
{show(totalInspected->Int.toString ++ "/" ++ totalNested->Int.toString)}
</span>
},
)}
</div>
})
} And it can be used like It would require some rethinking to remove the dependency on |
@mattdamon108 this seems doable with JSX V4? |
Yes, I think so too. @mvaled Can you try the latest compiler and rescript-react as posted on the forum? https://forum.rescript-lang.org/t/call-for-help-2-test-jsx-v4/3781 type props<'completion, 'children> = {
completion: 'completion,
children: 'children
}
let make = props => {
let {completion, children} = props
component()->view(vnode => {
let completion = vnode.attrs->completion->default(CompletionStatus.Defaults.completion)
let {totalNested, totalInspected, isOverdue} = completion
<div className="tile-action">
{show(
if completion->isFullyInspected {
<Feather icon=#check_circle className="text-success" />
} else {
<span className={isOverdue ? "text-error" : ""}>
{show(totalInspected->Int.toString ++ "/" ++ totalNested->Int.toString)}
</span>
},
)}
</div>
})
} |
If it is not working then try this: type props = {
completion: completionInformation,
children: element
} |
@mattdamon108
Thanks. One question, though. Would this require the actual React JS library or it's just the transformation, that would work with any compatible "react" binding? e.g Our rescript-mithril instead of '@rescript/react'. If it's just the transformation, then I'll try to upgrade our Mithril bindings to be compatible with JSX v4. |
I just checked about |
I've looked into your bindings. I think it would be working highly possibility. You can check the latest rescript-react binding and update your Mithrill bindings accordingly, then try with latest compiler's JSX v4. |
Just transformation and working with react binding. |
None, actually. This is our whole {
"name": "kaiko-survey-tool",
"sources": [
{
"dir": "src/",
"subdirs": true
}
],
"suffix": ".js",
"reason": {
"react-jsx": 3
},
"bs-dependencies": [
"@kaiko/reindexed",
"rescript-webapi",
"@ryyppy/rescript-promise",
"rescript-mithril",
"bs-fetch",
"rescript-prelude",
"rescript-deser",
"rescript-action-queue"
],
"package-specs": {
"module": "es6"
},
"warnings": {
"error": "+8+11+26+27+33+56"
}
} |
|
When you try the latest compiler with JSX v4, change this property in bsconfig.json "reason": {
"react-jsx": 3
}, to "jsx": {
"version": 4
} |
Right! Somehow my eyes skip over those lines 😄 |
All the fields in the following script are reported as dead:
Report:
However, only
age
is not actually used in the code, whilename
shouldn't be reported.The text was updated successfully, but these errors were encountered: