Skip to content
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

recognize function components returning any #171

Merged
merged 1 commit into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion sbt-converter/src/sbt-test/react/external/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ lazy val testProject =
scalaVersion := "2.13.2",
organization := "net.leibman",
)

Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class IdentifyReactComponents(reactNames: ReactNames, parentsResolver: ParentsRe
def maybeMethodComponent(method: MethodTree, owner: ContainerTree, scope: TreeScope): Option[Component] = {
def returnsElement(scope: TreeScope, current: TypeRef): Option[TypeRef] =
if (reactNames.isElement(current.typeName)) Some(current)
else if (current === TypeRef.Any)
Some(current) // unfortunately this conforms on the TS side, let's see how it works out
else if (scope.isAbstract(current)) None
else
current match {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
organization := "org.scalablytyped"
name := "stardust-ui__react-component-event-listener"
version := "0.38.0-ffa70f"
version := "0.38.0-ad5fb5"
scalaVersion := "2.13.2"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package typingsJapgolly.stardustUiReactComponentEventListener.components

import japgolly.scalajs.react.Callback
import japgolly.scalajs.react.Children.Varargs
import japgolly.scalajs.react.CtorType.ChildArg
import japgolly.scalajs.react.JsComponent
import japgolly.scalajs.react.Key
import japgolly.scalajs.react.component.Js.MountedWithRawType
import japgolly.scalajs.react.component.Js.RawMounted
import japgolly.scalajs.react.component.Js.UnmountedSimple
import japgolly.scalajs.react.raw.React.RefHandle
import org.scalablytyped.runtime.StringDictionary
import typingsJapgolly.stardustUiReactComponentEventListener.typesMod.EventListenerOptions
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

object EventListener {
def apply[/* <: typingsJapgolly.stardustUiReactComponentEventListener.typesMod.EventTypes */ T](
listener: /* import warning: importer.ImportType#apply Failed type conversion: / * import warning: transforms.QualifyReferences#resolveTypeRef many Couldn't qualify DocumentEventMap * / any[T] */ /* e */ js.Any => Callback,
targetRef: RefHandle[
/* import warning: transforms.QualifyReferences#resolveTypeRef many Couldn't qualify Node */ js.Any
],
`type`: T,
capture: js.UndefOr[Boolean] = js.undefined,
key: Key = null,
_overrides: StringDictionary[js.Any] = null
)(
children: ChildArg*
): UnmountedSimple[
EventListenerOptions[T],
MountedWithRawType[EventListenerOptions[T], js.Object, RawMounted[EventListenerOptions[T], js.Object]]
] = {
val __obj = js.Dynamic.literal(listener = js.Any.fromFunction1((t0: /* import warning: importer.ImportType#apply Failed type conversion: / * import warning: transforms.QualifyReferences#resolveTypeRef many Couldn't qualify DocumentEventMap * / any[T] */ /* e */ js.Any) => listener(t0).runNow()), targetRef = targetRef.asInstanceOf[js.Any])
__obj.updateDynamic("type")(`type`.asInstanceOf[js.Any])
if (!js.isUndefined(capture)) __obj.updateDynamic("capture")(capture.get.asInstanceOf[js.Any])
if (key != null) __obj.updateDynamic("key")(key.asInstanceOf[js.Any])
if (_overrides != null) js.Dynamic.global.Object.assign(__obj, _overrides)
val f = JsComponent[EventListenerOptions[T], Varargs, js.Object](this.componentImport)
f(__obj.asInstanceOf[EventListenerOptions[T]])(children :_*)
}
@JSImport("@stardust-ui/react-component-event-listener/dist/es/EventListener", JSImport.Default)
@js.native
object componentImport extends js.Object

}

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
organization := "org.scalablytyped"
name := "stardust-ui__react-component-event-listener"
version := "0.38.0-dc344e"
version := "0.38.0-8f5a38"
scalaVersion := "2.13.2"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package typingsSlinky.stardustUiReactComponentEventListener.components

import slinky.core.facade.ReactRef
import slinky.web.html.`*`.tag
import typingsSlinky.StBuildingComponent
import typingsSlinky.stardustUiReactComponentEventListener.typesMod.EventListenerOptions
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

object EventListener {
@JSImport("@stardust-ui/react-component-event-listener/dist/es/EventListener", JSImport.Default)
@js.native
object component extends js.Object

@scala.inline
class Builder[/* <: typingsSlinky.stardustUiReactComponentEventListener.typesMod.EventTypes */ T] (val args: js.Array[js.Any])
extends AnyVal
with StBuildingComponent[tag.type, js.Object] {
@scala.inline
def capture(value: Boolean): this.type = set("capture", value.asInstanceOf[js.Any])
}

def withProps[/* <: typingsSlinky.stardustUiReactComponentEventListener.typesMod.EventTypes */ T](p: EventListenerOptions[T]): Builder[T] = new Builder[T](js.Array(this.component, p.asInstanceOf[js.Any]))
@scala.inline
def apply[/* <: typingsSlinky.stardustUiReactComponentEventListener.typesMod.EventTypes */ T](
listener: /* import warning: importer.ImportType#apply Failed type conversion: / * import warning: transforms.QualifyReferences#resolveTypeRef many Couldn't qualify DocumentEventMap * / any[T] */ /* e */ js.Any => Unit,
targetRef: ReactRef[
/* import warning: transforms.QualifyReferences#resolveTypeRef many Couldn't qualify Node */ js.Any
],
`type`: T
): Builder[T] = {
val __props = js.Dynamic.literal(listener = js.Any.fromFunction1(listener), targetRef = targetRef.asInstanceOf[js.Any])
__props.updateDynamic("type")(`type`.asInstanceOf[js.Any])
new Builder[T](js.Array(this.component, __props.asInstanceOf[EventListenerOptions[T]]))
}
}