-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #171 from ScalablyTyped/recognize-react-fc-returni…
…ng-any recognize function components returning `any`
- Loading branch information
Showing
6 changed files
with
89 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,3 @@ lazy val testProject = | |
scalaVersion := "2.13.2", | ||
organization := "net.leibman", | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...t-integration-test/check-japgolly/s/stardust-ui__react-component-event-listener/build.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...cala/typingsJapgolly/stardustUiReactComponentEventListener/components/EventListener.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
} | ||
|
2 changes: 1 addition & 1 deletion
2
...act-integration-test/check-slinky/s/stardust-ui__react-component-event-listener/build.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
.../scala/typingsSlinky/stardustUiReactComponentEventListener/components/EventListener.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]])) | ||
} | ||
} | ||
|