Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Nov 17 09:50

    oyvindberg on master

    Update sbt-scalafmt to 2.5.0 (#… (compare)

  • Nov 17 09:49

    oyvindberg on master

    Update coursier to 2.1.0-RC2 (#… (compare)

  • Nov 16 20:53

    oyvindberg on true-literal-and-union-types

    True literal types and union ty… (compare)

  • Nov 16 17:59

    oyvindberg on v1.0.0-beta40

    (compare)

  • Nov 16 17:59

    oyvindberg on gh-pages

    Deploy website Deploy website … (compare)

  • Nov 16 05:50

    oyvindberg on master

    FakeLiterals: fix a scala perfo… (compare)

  • Nov 15 22:20

    oyvindberg on master

    PreferTypeAlias: exclude trivia… (compare)

  • Nov 15 21:55

    oyvindberg on master

    conditional types approximation… (compare)

  • Nov 15 21:23

    oyvindberg on master

    conditional types approximation… (compare)

  • Nov 15 18:11

    oyvindberg on master

    build: fix sbt assembly (compare)

  • Nov 15 12:45

    oyvindberg on master

    release: bump versions in demo … (compare)

  • Nov 15 09:42

    oyvindberg on master

    coursier resolve: always retry … (compare)

  • Nov 15 04:33

    oyvindberg on delegate-build-and-package-to-bleep

    Delegate compilation and packag… (compare)

  • Nov 15 04:31

    oyvindberg on delegate-build-and-package-to-bleep

    Delegate compilation and packag… (compare)

  • Nov 15 04:21

    oyvindberg on delegate-build-and-package-to-bleep

    Delegate compilation and packag… (compare)

  • Nov 15 04:15

    oyvindberg on delegate-build-and-package-to-bleep

    Delegate compilation and packag… debug (compare)

  • Nov 15 04:11

    oyvindberg on master

    ping? (compare)

  • Nov 15 04:09

    oyvindberg on master

    ping? (compare)

  • Nov 15 04:09

    oyvindberg on master

    ping? (compare)

  • Nov 15 04:08

    oyvindberg on master

    ping? (compare)

Øyvind Raddum Berg
@oyvindberg
(this: Interactable, options: Partial<OrBoolean<T>> | boolean): typeof this; I never cease to be surprised what they come up with!
the typeof this ends up being any
moritz bust
@busti

So I wasn't going crazy then 😮‍💨
Thanks a lot for the quick reply. The typings of interactjs seem to be absolutely wild, because scalablytyped generates an absolute ton of confusing stuff.
I assumed it was working at first because I got a confusing error message in the browser console, but now I cannot get it to do anything at all.
The typings.interactjsInteract.mod.{default => interact} import definitely works, because printing it to the console yields a method that just makes sense.

However, calling any method on it, i.e. .draggable causes the frontend to just hang indefinitely.
The .apply method of the DraggableOptions object that has to be passed to the .draggable method also has no arguments.

I have no idea what's going on here.
Is there maybe another entrypoint that makes more sense to use?
Alexis Hernandez
@AlexITC
@oyvindberg we got to play with https://github.com/oyvindberg/st-material-ui/tree/master/st-material-ui-slinky which has worked nicely, I just wonder if you happen to have examples for styling components, by default, we can propagate CSSProperties but it can be annoying
Øyvind Raddum Berg
@oyvindberg
@busti DraggableOptions is meant to be mutated after you call apply, see https://scalablytyped.org/docs/objects
cool @AlexITC . I havent done any work on that part yet. I would need help with coming up with a nice way to integrate styled components -like libraries with the reactcomponents output from the ST flavours
Alexis Hernandez
@AlexITC
Thanks for sharing, let's see where we can get
moritz bust
@busti

@oyvindberg Ah, I did not see the setter methods on that object.
Doesn't matter though, since I cannot pass it to the .draggable method since the compiler cannot find the right method for that parameter.

[error] /<path>/foo.scala:60:16: overloaded method draggable with alternatives:
[error]   (options: typings.std.Partial[typings.interactjsTypes.typesMod.OrBoolean[typings.interactjsTypes.pluginMod.DraggableOptions]])Any <and>
[error]   (options: Boolean)Any
[error]  cannot be applied to (typings.interactjsTypes.pluginMod.DraggableOptions)
[error]               .draggable(draggableOptions)
[error]

The type signature of the .draggable method is also plenty weird.
options: Partial[OrBoolean[DraggableOptions]]
From what that sounds like, I should just be able to pass a DraggableOptions object, right?

Finally, I am unable to set an event listener on the DraggableOptions object, since it's setOnmove method expects a

type ListenersArg = typings.interactjsTypes.typesMod._ListenersArg | (js.Array[
    typings.interactjsTypes.typesMod.Listener | typings.interactjsTypes.typesMod.ListenerMap
  ])

and following those types just leaves me with a trait _ListenersArg extends StObject or

@js.native
trait Listener
  extends StObject
     with _ListenersArg {

  def apply(args: Any*): Any = js.native
}
moritz bust
@busti
I am sorry if I am asking questions with obvious answers. I just cannot make heads or tails of this. I have tried reading the docs of scalablytyped and looked at all the examples, but none seem to be this confusing.
Øyvind Raddum Berg
@oyvindberg
I think it's fair to accept that some libraries are too weirdly defined to 1-1 translate, this seems to be one of them
in that case a valid approach is to generate source code with ST to get a starting point, and then refactor it until it's workable
typings.std.Partial[typings.interactjsTypes.typesMod.OrBoolean[typings.interactjsTypes.pluginMod.DraggableOptions]] for instance is very javascripty
it looks like you can supply a subset of the fields in (DraggableOptions | boolean) because Partial, whatever that means
ST has support for evaluating statically the type for Partial<DraggableOptions>, but not Partial<DraggableOptions | boolean> (if that is what OrBoolean does)
and Listener is awkward because it's an untyped vararg function. there is no good scala syntax for that
Øyvind Raddum Berg
@oyvindberg
FTR casts will get you out of both situations. you can cast a js.FunctionN to Listener safely, and you can cast DraggableOptions to that weird type
moritz bust
@busti

I am guessing that this would be right?

interact(element).draggable(
        DraggableOptions()
          .setOnstart(((event: InteractEvent) => println(event)).asInstanceOf[ListenersArg])
          .asInstanceOf[Partial[OrBoolean[DraggableOptions]]],
      )

While that does compile, it does not run. Javascript complains that:

scala.scalajs.js.JavaScriptException: TypeError: $$x1.draggable is not a function
Imports are:
import typings.interactjsInteract.mod.{default => interact}
import typings.interactjsTypes.dropPluginMod.interactjsCoreInteractEventAugmentingMod.InteractEvent
import typings.interactjsTypes.pluginMod.DraggableOptions
import typings.interactjsTypes.typesMod.{ListenersArg, OrBoolean}
import typings.std.Partial
Øyvind Raddum Berg
@oyvindberg
You need to make that a js.Function before you cast it
moritz bust
@busti
Turns out I also had to import typings.interactjs.mod.{default => interact} instead of what I did before since the @interactjs/interact namespace does not seem to be importable. It's probably a package that just contains the typings and nothing else.
That plus casting to js.Function1 before now makes it work.
Well, I now also need to cast interact.asInstanceOf[InteractStatic]
Gianluca Aguzzi
@cric96

Hey!
First of all, congratulations on the project, it's really cool :) I tried it out this morning and everything works really well!
Unfortunately, however, this afternoon I got this error:

Bundling the application with its NPM dependencies
[error] ModuleNotFoundError: Module not found: Error: Can't resolve 'js-quadtree/dist/QuadTree' in '/home/gianluca/Programming/IdeaProjects/scala-boids/boids/js/target/scala-3.1.3/scalajs-bundler/main

I'm using js-quadtree (https://www.npmjs.com/package/js-quadtree), if I just write typings.jsQuadtree.jsQuadtreeRequire it's ok, but if I import QuadTree (import typings.jsQuadtree.quadTreeMod.QuadTree) it gives me the error above.
Any ideas?
The npmDependecies are:

Compile / npmDependencies ++=
      Seq(
        "@types/p5" -> "1.4.2",
        "js-quadtree" -> "3.3.6",
        "p5" -> "1.4.2"
      ),
Øyvind Raddum Berg
@oyvindberg
@cric96 try to import through typings.jsQuadtree.mod.QuadTree instead, see https://scalablytyped.org/docs/usage#modules
peterstorm
@peterstorm:matrix.org
[m]
Hello! Has anyone run into problems with react-router-dom and RouteProps.setPath?
It complains about not being able to accept a string, and when you jump-to-definition, there's a comment saying that "the props of this component has an unsupported shape. You can set manually..."...
peterstorm
@peterstorm:matrix.org
[m]
Oh, found an answer further up, thank you!
peterstorm
@peterstorm:matrix.org
[m]
How about useLocation - it now returns any, for some reason...
elkhadirzyad
@elkhadirzyad

hello @oyvindberg , i'm always trying with Tabs in mui5, i could not find the appropriate props, in mui 3, it was

Tabs(activeTabId)
      .withKey(key)
    //  .id(key)
      .className(s"HicpTabsHeader ${className}")
      .indicatorColor(indicatorColor)
      .textColor(textColor)
      .centered(centered)

in mui 5, here is the definition of Tabs :

object Tabs {

  def apply(
    p: /* props */ (DefaultComponentProps[
      TabsTypeMap[
        js.Object, 
        js.Function1[
          /* props */ OverridePropsExtendButtonBaseTypeMapButtAbout | DefaultComponentPropsExtendButtonBaseTypAction, 
          Element | Null
        ]
      ]
    ]) with `26`
  ): Default[js.Object] = new Default[js.Object](js.Array(this.component, p.asInstanceOf[js.Any]))

  @JSImport("@mui/material", "Tabs")
  @js.native
  val component: js.Object = js.native

  implicit def make(companion: Tabs.type): Default[js.Object] = new Default[js.Object](js.Array(this.component, js.Dictionary.empty))()
}
Alexis Hernandez
@AlexITC
@elkhadirzyad are you using https://github.com/oyvindberg/st-material-ui ?
elkhadirzyad
@elkhadirzyad
@AlexITC yes
zetashift
@sp33der89:matrix.org
[m]

Am I doing something wrong, I want to try to get some very basic bindings going for https://www.npmjs.com/package/edgedb and this is my build.sbt:

name := "EdgeDB Scala.js experiment"

lazy val root = project
  .in(file("."))
  .enablePlugins(ScalaJSPlugin)
  .enablePlugins(ScalablyTypedConverterPlugin)
  .settings(
    scalaVersion := "3.1.3",
    scalaJSUseMainModuleInitializer := true,
    Compile / npmDependencies ++= Seq(
      "edgedb" -> "latest",
    )
  )

The result seems to be a [success] but I don't see any generated classes

Øyvind Raddum Berg
@oyvindberg
You should get jars attached to your classpath and added to your project. Try to see if there is anything inside the typings package
zetashift
@sp33der89:matrix.org
[m]
Aaaah I see it, thank you!
moritz bust
@busti
As a follow-up on using interactjs.io with scalablytyped; the following definitions make it much more workable:
import typings.interactjsTypes.dropPluginMod.DropzoneOptions
import typings.interactjsTypes.gesturePluginMod.GesturableOptions
import typings.interactjsTypes.interactEventMod.EventPhase
import typings.interactjsTypes.pluginMod.DraggableOptions
import typings.interactjsTypes.resizePluginMod.ResizableOptions
import typings.interactjsTypes.typesMod.{ListenersArg, OrBoolean, Target}
import typings.interactjsTypes._
import typings.std.Partial

import scala.scalajs.js

object InteractJSHelper {
  type InteractEvent = interactEventMod.InteractEvent[Any, EventPhase]
  type DragEvent     = InteractEvent
  type DropEvent     = InteractEvent
  type GestureEvent  = gesturePluginMod.GestureEvent
  type ResizeEvent   = resizePluginMod.ResizeEvent[EventPhase]

  /** Converts any [[scala.Function1]] whose parameter contains any [[InteractEvent]] to an InteractJS compatible one */
  implicit def scalaFunction2ListenersArg[E <: InteractEvent](fn: E => Unit): ListenersArg =
    (fn: js.Function1[E, Unit]).asInstanceOf[ListenersArg]

  /** Converts any type `T` to a `Partial[OrBoolean[T]]` where required */
  implicit def any2PartialOrBoolean[T](obj: T): typings.std.Partial[typesMod.OrBoolean[T]] =
    obj.asInstanceOf[typings.std.Partial[typesMod.OrBoolean[T]]]

  @js.native
  private trait InteractableActions extends anon.InteractableActions {
    override def draggable(options: Boolean): InteractableActions                              = js.native
    override def draggable(options: Partial[OrBoolean[DraggableOptions]]): InteractableActions = js.native

    override def dropzone(options: Boolean): InteractableActions         = js.native
    override def dropzone(options: DropzoneOptions): InteractableActions = js.native

    override def gesturable(options: Boolean): InteractableActions                               = js.native
    override def gesturable(options: Partial[OrBoolean[GesturableOptions]]): InteractableActions = js.native

    override def resizable(options: Boolean): InteractableActions                              = js.native
    override def resizable(options: Partial[OrBoolean[ResizableOptions]]): InteractableActions = js.native
  }

  @js.native
  private trait InteractStatic extends interactStaticMod.InteractStatic {
    override def apply(target: Target): InteractableActions                              = js.native
    override def apply(target: Target, options: optionsMod.Options): InteractableActions = js.native
  }

  val interact = typings.interactjs.mod.default.asInstanceOf[InteractStatic]
}
mn98
@mn98
Hi all, I'm wondering if anyone has had success with using Vega-Lite with ScalablyTyped.
I've had a quick stab at creating a Slinky demo for it here, but I've failed miserably. I think I'm missing something fundamental. It would be great if anyone is able to offer me any hints or solutions as to why I can't get the chart to 'embed'. Thanks!
mn98
@mn98

I got a little further with the Vega-Lite example and pushed the changes to the same repo linked above. Now I'm battling with how to set some of the 'encoding' parameters on the chart.
Also, I see lots of DevTools warnings in Chrome, e.g.

DevTools failed to load source map: Could not load content for webpack:///node_modules/vega-embed/build/vega-embed.module.js.map: Fetch through target failed: Unsupported URL scheme; Fallback: HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME

Is there anything I can do to remedy those?

Øyvind Raddum Berg
@oyvindberg
@busti that looks reasonable, great way to patch up when the types come out badly. You can also use the source generation plugin and manually patch with search/replace and distribute it through maven like a normal library
@mn98 i May have time to take a look in a day or two. First thought is that is can go in the "demos" repo instead, since the library doesn't use react. Then it's normally good advice to use the library outside of react first, and then when it works wrap it
Øyvind Raddum Berg
@oyvindberg
Also i dont know if you did that, but i have always started with some typescript example and translated. That way it's fairly mechanical
mn98
@mn98
@oyvindberg, thanks for the pointers! I agree the Slinky part is a distraction (but working) and I will move the demo.
I also thought copying a typescript example would be straightforward, but I've been stumped by the "encoding" part (which is commented out in the code I checked in).
image.png
mn98
@mn98
It's now mechanically operational, but I can't figure out how to create instances of some of the required types, e.g. Test with NumericValueRef.
Øyvind Raddum Berg
@oyvindberg
All ST types have a combineWith method which helps you construct intersection types
Lorenzo Gabriele
@lolgab
Hello :)
Released mill-scalablytyped 0.0.7 which bumps Scalablytyped to 1.0.0-beta39
Anton Sviridov
@velvetbaldmime:matrix.org
[m]
It's notably missing from ScalablyTyped.org :)
3 replies
Simon Parten
@Quafadas

@mn98 I hope your experiments are going well. A while back, I also wanted scala to do more with vega / lite. This is off topic - but after a while playing with them in scalably typed and learning, I went my own way and did something slightly different. I would note in general, it's worth knowing scalably typed, because it's amazing. In the very specific case of vega / lite, I ended up writing my own much more custom wrapper around it, leaning into it's JSON-ness, rather than it's typescript-ness.

https://quafadas.github.io/dedav4s/

If you do give it a go any feedback would be welcomed... but either way wishing you luck with whatever works!

mn98
@mn98
@Quafadas, I like to think I'm not incompetent but I'm really struggling to create even the simplest vega-lite VisualizationSpec, I'm still stumped on the "encoding" piece!
I'm using ScalablyTyped for a host of other libraries and it is indeed amazing and a largely painless experience.
Your alternative approach looks very interesting indeed, I shall certainly have a play around with that! After all, I'm just looking for a good charting experience with scala-js.