Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Sep 17 20:29

    oyvindberg on master

    Note which standard all members… Merge pull request #347 from Sc… (compare)

  • Sep 17 20:29

    oyvindberg on add-std-comment

    (compare)

  • Sep 17 12:31

    oyvindberg on master

    Update sbt-bloop to 1.4.9 Merge pull request #349 from sc… (compare)

  • Sep 17 12:31

    oyvindberg on master

    fix: scala 2 intersection type … Merge pull request #355 from in… (compare)

  • Sep 17 12:13

    oyvindberg on add-support-for-renamed-type-mappings

    (compare)

  • Sep 17 12:13

    oyvindberg on master

    Guard against a rare error enco… Implement support for renaming … Merge pull request #352 from Sc… (compare)

  • Sep 17 12:12

    oyvindberg on document-standard

    (compare)

  • Sep 17 12:12

    oyvindberg on master

    Note which standard all members… (compare)

  • Sep 17 12:06

    oyvindberg on add-support-for-renamed-type-mappings

    Guard against a rare error enco… Implement support for renaming … (compare)

  • Sep 17 09:02

    oyvindberg on document-standard

    Note which standard all members… (compare)

  • Sep 17 09:01

    oyvindberg on add-support-for-renamed-type-mappings

    Guard against a rare error enco… Implement support for renaming … (compare)

  • Sep 17 09:01

    oyvindberg on add-support-for-renamed-type-mappings

    Implement support for renaming … Guard against a rare error enco… (compare)

  • Sep 08 20:49

    oyvindberg on master

    Update sbt-assembly to 1.1.0 (#… (compare)

  • Sep 01 20:00

    oyvindberg on true-literal-types

    towards true literal types (compare)

  • Sep 01 18:51

    oyvindberg on add-std-comment

    Note which standard all members… (compare)

  • Aug 29 18:57

    oyvindberg on master

    Update sbt-mdoc to 2.2.23 Merge pull request #345 from sc… (compare)

  • Aug 28 22:32

    oyvindberg on master

    run yarn before site publish in… (compare)

  • Aug 28 22:32

    oyvindberg on gh-pages

    Deploy website Deploy website … (compare)

  • Aug 28 22:30

    oyvindberg on v1.0.0-beta36

    (compare)

  • Aug 28 21:03

    oyvindberg on master

    Inline "trivial" interfaces as … (compare)

Roberto Leibman
@rleibman
My runtime should be up to date at 2.4.2 and my plugin is set to 1.0.0-beta36
Roberto Leibman
@rleibman
Sadly not, the version of react-big-calendar I'm using is not the same as yours.
Roberto Leibman
@rleibman
And interestingly, I don't get anything from the moment library either.
Roberto Leibman
@rleibman
.... ah, I was minimizing too much, apparently.
That did it.
Jason Pickens
@steinybot:matrix.org
[m]
How do I create a props for slinky that also extends RefAttributes?
The generated component definition is:
  @js.native
  trait CompoundedComponent
    extends StObject
       with ForwardRefExoticComponent[CheckboxProps with RefAttributes[HTMLInputElement]] {
There is an apply method for CheckboxProps but that only gives me a CheckboxProps and not a CheckboxProps with RefAttributes[HTMLInputElement].
Jason Pickens
@steinybot:matrix.org
[m]
Ah well I can do CheckboxProps().combineWith(RefAttributes[HTMLInputElement]()). Is that the best way?
Feels like there ought to be a simpler way since one would always have to do that.
Øyvind Raddum Berg
@oyvindberg
@steinybot:matrix.org yes, that's how you do it, see also https://scalablytyped.org/docs/objects
Though if this is react you may want to check out the react flavours which generate react boilerplate for you
Jason Pickens
@steinybot:matrix.org
[m]
Thanks. Yes this is react (slinky). I'm not too sure where I should be looking.
Øyvind Raddum Berg
@oyvindberg
I've meant to work on this documentation, but this is an entry point https://scalablytyped.org/docs/flavour
Jason Pickens
@steinybot:matrix.org
[m]
Oh cool, thanks for that. That demo also uses antd but doesn't seem to have this awkwardness. Something must be different. I'll clone that and dig a bit deeper.
Jason Pickens
@steinybot:matrix.org
[m]
Found one thing I wasn't doing right. I was importing from import typings.antd.checkboxMod instead of import typings.antd.components. Is components just a convention?
The other main difference is that the demo uses the fluent API and never uses withProps.
Jason Pickens
@steinybot:matrix.org
[m]

ST is creating typings.antd.components.Form.Form which looks like:

  object Form {

    @scala.inline
    def apply[Values](): SharedBuilder_FormItemProps_1607966002[Values] = {
      val __props = js.Dynamic.literal()
      new SharedBuilder_FormItemProps_1607966002[Values](js.Array(this.component, __props.asInstanceOf[FormItemProps[Values]]))
    }

    @JSImport("antd", "Form.Item")
    @js.native
    val component: js.Object = js.native

    implicit def make[Values](companion: Form.type): SharedBuilder_FormItemProps_1607966002[Values] = new SharedBuilder_FormItemProps_1607966002[Values](js.Array(this.component, js.Dictionary.empty))()

    def withProps[Values](p: FormItemProps[Values]): SharedBuilder_FormItemProps_1607966002[Values] = new SharedBuilder_FormItemProps_1607966002[Values](js.Array(this.component, p.asInstanceOf[js.Any]))
  }

Shouldn't this be named typings.antd.components.Form.Item?

Øyvind Raddum Berg
@oyvindberg
@steinybot:matrix.org yes, the components folder is special. pretty much everything else of the generated code is 1-1 from typescript. The different "flavour"s are more advanced codegen which generates more idiomatic scala code based on the types in the generated code.
so when you specify stFlavour := Flavour.Slinky and run the conversion, a program will run which tries to identify all react components, names them, builds a hierarchy of them, tries to deduplicate, and outputs something which is hopefully very nice to use in the components folder. think of it as providing nicer syntax, somewhat similar to what JSX does in Javascript
Øyvind Raddum Berg
@oyvindberg
Also yes, that component name is a bug. unfortunately naming the components is a bit harder than you would think, and I haven't had much time to invest into that part of the code. feel free to open an issue though
Jason Pickens
@steinybot:matrix.org
[m]
I appreciate you taking the time to answer my questions. I hope to be able to help out sometime, even if it is just with docs.

One other question. antd has a Radio.Group which looks like:

declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<RadioGroupProps & React.RefAttributes<HTMLDivElement>>>;

https://unpkg.com/browse/antd@4.16.13/es/radio/group.d.ts

This comes out as:

  @JSImport("antd/lib/radio/group", JSImport.Default)
  @js.native
  val default: ReactComponentClass[ForwardRefExoticComponent[RadioGroupProps with RefAttributes[HTMLDivElement]]] = js.native

Is there a way to actually use this? In TS MemoExoticComponent is still callable because it extracts the props from the nested component. Going from MemoExoticComponent to ReactComponentClass doesn't seem to work in the same way.

Jason Pickens
@steinybot:matrix.org
[m]
Doesn't look like Slinky has a good representation for MemoExoticComponent so I'm not sure what ST should be doing in this case.
Øyvind Raddum Berg
@oyvindberg
no problem @steinybot:matrix.org
this taps into some react things I'm not familiar with honestly
can you still use it like a normal react component in typescript though, do you know? one thing which can easily be changed is to translate the whole thing to ReactComponentClass[RadioGroupProps with RefAttributes[HTMLDivElement].
Jason Pickens
@steinybot:matrix.org
[m]
It's a bit funny in JSX, I'm not sure why.
Yeah. Just expanding the TS types, the nested component disappears so just going to ReactComponentClass[RadioGroupProps with RefAttributes[HTMLDivElement] I think is the best solution.
Øyvind Raddum Berg
@oyvindberg
1 reply
I'll make a PR soonish
I still have no clue what an exotic component is
Jason Pickens
@steinybot:matrix.org
[m]
My guess is that has something to do with $$typeof (https://overreacted.io/why-do-react-elements-have-typeof-property/)
Although I thought ReactElement would have that too 🤔
ridaEl
@ridaEl
image.png
image.png
hello mr @oyvind, when i try to compile the react dnd demo i have the above error
elkhadirzyad
@elkhadirzyad
I have the same problem as @ridaEl
Øyvind Raddum Berg
@oyvindberg
@ridaEl @elkhadirzyad this seems like an error while using refs in scalajs-react. The error message says to use TopNode instead of HTMLElement - does that work?
in any case try to create a val foo: RefFn[TopNode] = node => ... and give that to untypedRef, that should help the compiler out
elkhadirzyad
@elkhadirzyad
@oyvindberg the function is `` implicit def whyyyDoesItHaveToBeSoComplicated: ValueType[HTMLElement => Callback, RefFn[HTMLElement]] =
ValueType[HTMLElement => Callback, RefFn[HTMLElement]] { (consume, f) =>
val massaged: RefFn[HTMLElement] =
(e: HTMLElement | Null) => Option(e.asInstanceOf[HTMLElement]).foreach(e => f(e).runNow())
  consume(massaged)
} `` should i replace html eimplicit def whyyyDoesItHaveToBeSoComplicated: ValueType[HTMLElement => Callback, RefFn[HTMLElement]] =
ValueType[HTMLElement => Callback, RefFn[HTMLElement]] { (consume, f) =>
  val massaged: RefFn[HTMLElement] =
    (e: HTMLElement | Null) => Option(e.asInstanceOf[HTMLElement]).foreach(e => f(e).runNow())

  consume(massaged)
} `` i should replace HTMlelement with TopNode ?
elkhadirzyad
@elkhadirzyad

@oyvind when i replace the function with

implicit def importantFunctionTodragTopNode :ValueType[HTMLElement => Callback, RefFn[TopNode]] =
    ValueType[HTMLElement => Callback, RefFn[TopNode]] { (consume, f) =>
      val massaged: RefFn[TopNode] =
        (e: TopNode | Null) => Option(e.asInstanceOf[HTMLElement]).foreach(e => f(e.asInstanceOf[HTMLElement]).runNow())

      consume(massaged)
    }

the drag is not working anymore

elkhadirzyad
@elkhadirzyad
the original function is
implicit def importantFunctionTodrag: ValueType[HTMLElement => Callback, RefFn[HTMLElement]] =
    ValueType[HTMLElement => Callback, RefFn[HTMLElement]] { (consume, f) =>
      val massaged: RefFn[HTMLElement] =
        (e: HTMLElement | Null) => Option(e.asInstanceOf[HTMLElement]).foreach(e => f(e).runNow())

      consume(massaged)
    }
Jason Pickens
@steinybot:matrix.org
[m]
Any particular reason for using js.Any over Any? Sébastien is saying that js.Any should never really be used except for in extends (https://matrix.to/#/!GPcZOobOJQzJgrKPRT:gitter.im/$ytxkthOd4OpqjqyVRH__7iVQv7QlSmyttWrOFvS_YR8?via=gitter.im&via=matrix.org)
Øyvind Raddum Berg
@oyvindberg
It's pretty arbitrary I'd say, i thought that was most correct @steinybot:matrix.org
I'd be happy to change it, it should be quite easy
Jason Pickens
@steinybot:matrix.org
[m]
The issue is when value?: any becomes value: UndefOf[js.Any]. There is no Evidence[String, js.Any] so you can't do value = "foo".