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
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.
Øyvind Raddum Berg
@oyvindberg
@mn98 I had a closer look at vega-lite, and it's not a joy to use in its current state, unfortunately. The library is not too crazily modelled, but it does push the limits of the conversion and scala capabilities
For instance a lot of usage of Partial, so you end up with monstrosities like js.UndefOr[Partial[js.UndefOr[LatLongDef[F]]]]
For the concrete encoding thing you're missing, note that typings.vegaEmbed.mod.default takes a spec which can have one of many shapes. one of them is TopLevelLayerSpecField, which has an encoding member. maybe some of the other have that as well
so yeah. I'd try @Quafadas library :)
mn98
@mn98
@oyvindberg thanks for sharing your thoughts on this one, I might well let @Quafadas's library do the work for me here :-)
Simon Parten
@Quafadas
Out of curiosity, has anyone tried ST with this lib;
https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-browser? Any public prior art :-)?
elkhadirzyad
@elkhadirzyad
Hello, is there a solution for the component Tabs in mui5 ;) ?
Krišjānis Veinbahs
@kshaa

Architecturally speaking. Should it possible to:
1) develop a Scala.JS React component which uses some NPM packages with types generated using ScalablyTyped
2) publish this component in a package repository (e.g. an Artifactory Maven repository) as a Scala.JS JAR
3) use this Scala.JS component in a project which doesn't integrate with or use the ScalablyTyped plugin

I executed step no. 1 and no. 2., but it seems that on step no. 3. i.e. when I'm attempting to build the project sbt seems to be trying to read ScalablyTyped definitions. E.g. my component uses Fuse.JS and even though it was compiled and published to a repo, the non-ScalablyTyped project is still trying to once again find and use ScalablyTyped definitions.

[2022-09-23T06:53:38.671Z] [error] Error downloading org.scalablytyped:fuse_dot_js_sjs1_2.13:6.6.2-5a0c84
[2022-09-23T06:53:38.671Z] [error]   Not found
[2022-09-23T06:53:38.671Z] [error]   Not found
[2022-09-23T06:53:38.671Z] [error]   not found: /home/<BUILD_USER>/.ivy2/local/org.scalablytyped/fuse_dot_js_sjs1_2.13/6.6.2-5a0c84/ivys/ivy.xml
[2022-09-23T06:53:38.671Z] [error]   not found: https://<PRIVATE_REPO_1>/org/scalablytyped/fuse_dot_js_sjs1_2.13/6.6.2-5a0c84/fuse_dot_js_sjs1_2.13-6.6.2-5a0c84.pom
[2022-09-23T06:53:38.671Z] [error]   not found: https://<PRIVATE_REPO_2>/org.scalablytyped/fuse_dot_js_sjs1_2.13/6.6.2-5a0c84/ivys/ivy.xml

TL;DR - Is it possible to somehow export a ScalablyTyped Scala.JS package and have it be standalone i.e. independant of ScalablyTyped?

Krišjānis Veinbahs
@kshaa

Ah. I see that the published ScalablyTyped Scala.js React component artifact consists of an SJS JAR and a POM file referring to dependencies on org.scalablytyped.... I guess the solution to my problem might be to also publish these ScalablyTyped-generated packages from the cache into the Maven repository alongside my component. That way whomever imports my component would have everything ready and available and wouldn't need to depend on ScalablyTyped - thereby making my component standalone.

P.S. Sorry for the rubber duck debugging :D

Øyvind Raddum Berg
@oyvindberg
@kshaa this is the preferred workflow for distributing libraries which uses ST https://scalablytyped.org/docs/library-developer
Krišjānis Veinbahs
@kshaa
@oyvindberg That indeed fixes my problems. Thanks! :bow:
Øyvind Raddum Berg
@oyvindberg
Hey everybody, I've finally had some time for ST again. I want to showcase two upcoming changes, which together should make the generated code way easier to work with! See ScalablyTyped/Converter#485 and ScalablyTyped/Converter#487
elkhadirzyad
@elkhadirzyad
hello @oyvindberg , i hope u r in good shape, i'm trying to use "react-dnd" -> "11.1.3" with addSbtPlugin("org.scalablytyped.converter" % "sbt-converter" % "1.0.0-beta39") but it gives me the error
[error] (hicpBasicComponentsJS / stImport) TsHelperFile(InFile(/home/asaunix/git/hicp-sales-tool/hicp-basic-components/js/target/scala-2.13/scalajs-bundler/main/node_modules/redux/index.d.ts),FromFolder(InFolder(/home/asaunix/git/hicp-sales-tool/hicp-basic-components/js/target/scala-2.13/scalajs-bundler/main/node_modules/redux),TsIdentLibrarySimple(redux)),IArray(TsIdentModule(None,List(redux)), TsIdentModule(None,List(redux)))) -> Right(Parse error at 402.32 end of input expected)
tomzheng77
@tomzheng77
just want to say a huge thanks for this project! its so good its almost creepy, saved me tens, no likely hundreds of hours of porting the latest three.js and pixi.js
Øyvind Raddum Berg
@oyvindberg
Thanks @tomzheng77 <3
tomzheng77
@tomzheng77
I have a question. has anyone got sbt test working with scalablytyped? I'm a little stumped because the test command by default doesn't build a bundle
tomzheng77
@tomzheng77
I've made some progress now using requireJsDomEnv in Test := true, but the tests still aren't running for some reason. likely just a mistake in my setup though
Alexis Hernandez
@AlexITC
sbt test shouldn't have any issues with scalablytyped