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)

Jakub Kozłowski
@kubukoz
Made ScalablyTyped/Converter#463, in the meantime I'm doing manual facades so I'll be fine
where I'm going I'm probably not going to need Scala.js :sweat_smile:
Casey Bailey
@SonicZentropy
hiya all! fair warning, i know almost nothing about scala, but ST was so overly cool i had to try it. I believe I've found a package that doesn't convert properly, but before I follow the site's instructions and submit an issue, I was hoping I could get a bit of help confirming it actually is an issue
I have hte example react-router-dom and @types for it working, but adding pixi.js showers me in logs I don't understand
[error] java.lang.RuntimeException: FromFolder(InFolder(/home/kc/workspace/scala/pixala/target/scala-2.13/scalajs-bundler/main/node_modules/pixi.js),TsIdentLibrarySimple(pixi.js)) -> Right(Compilation failed: )
this is the root error prior to stack trace
Casey Bailey
@SonicZentropy
ah nevermind, intellij was eating the error log i actually needed, it is indeed a bug
Øyvind Raddum Berg
@oyvindberg
@kubukoz feel free to, it'd be cool to have the channel on say the scala discord instead
@SonicZentropy feel free to open an issue if you couldnt resolve it
moritz bust
@busti
Has anyone here ever used interactjs with scalablytyped?
I am having a bit of trouble finding the right entrypoint
I wrote a facade for it a couple years back, but I wanted to give scalablytyped a go since there have been some updates to interactjs recently and the api is to complex to fully maintain on my own.
https://github.com/busti/scalajs-interactjs
moritz bust
@busti
I found that I can import typings.interactjsInteract.mod.{default => interact} and then calling interact(".foo").draggable() works, but it's return type is wrong. It returns Any while the library defines it as returning another library object to facilitate chain calling.
Ø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]
}