oyvindberg on gh-pages
Deploy website Deploy website … (compare)
oyvindberg on v1.0.0-beta29.2
oyvindberg on v1.0.0-beta29-patch
Update ammonite-ops to 2.3.8 Update sbt-mdoc to 2.2.13 Better error logging in CI and 12 more (compare)
oyvindberg on gh-pages
Deploy website Deploy website … (compare)
oyvindberg on master
Update sbt-mdoc to 2.2.15 (compare)
oyvindberg on master
Update library-developer.md Ad… (compare)
oyvindberg on scala-companion-objects
oyvindberg on scala-companion-objects
Generate more specific types fo… (compare)
oyvindberg on v1.0.0-beta29.1
oyvindberg on v1.0.0-beta29-patch
Another bugfix for remote cache (compare)
oyvindberg on gh-pages
Deploy website Deploy website … (compare)
oyvindberg on master
Restore compatibility with old … (compare)
oyvindberg on master
Restore compatibility with old … (compare)
oyvindberg on master
Another bugfix for remote cache (compare)
oyvindberg on master
Reintroduce `^` classes (compare)
oyvindberg on gh-pages
Deploy website Deploy website … (compare)
oyvindberg on master
add scalablytyped icon (#235) … (compare)
oyvindberg on master
try to speed up CI (compare)
oyvindberg on improve-class-extraction
oyvindberg on master
Improve ExtractClasses and Reso… (compare)
"foo" | "bar"
will be interesting, and also T | Null
, and just general type inference and compile times. I hope it will be a big improvement :)
diff --git a/material-ui/src/main/scala/demo/button/Button.scala b/material-ui/src/main/scala/demo/button/Button.scala
index 56de112..f01beaf 100644
--- a/material-ui/src/main/scala/demo/button/Button.scala
+++ b/material-ui/src/main/scala/demo/button/Button.scala
@@ -12,7 +12,7 @@ import typings.materialUiCore.createMuiThemeMod.{Theme, ThemeOptions}
import typings.materialUiCore.spacingMod.SpacingOptions
import typings.materialUiCore.{stylesMod, components => Mui}
import typings.materialUiStyles.components.ThemeProvider
-import typings.std.global.window
+import typings.std.global.{console, window}
import scala.scalajs.js
@@ -47,10 +47,17 @@ object ButtonTest {
s"Increment it, ${props.name}"
)
+ val ref = Hooks.useRef[Any](null)
+
div(
/* text field controlled by the value of the state hook above*/
- Mui.TextField.StandardTextFieldProps().value(state).disabled(true),
- incrementButton
+ Mui.TextField.StandardTextFieldProps().value(state).disabled(true).innerRef(ref),
+ incrementButton,
+ Option(ref.current).map(x => {
+ val dynamic = x.asInstanceOf[js.Dynamic]
+ console.warn(dynamic)
+ "has reference"
+ })
)
}
}
What should I do in the situation where the generated class extends a base class and I need to call the constructor defined on the base class?
export as namespace ProgressBar;
declare const main: {
Circle: typeof Circle;
};
export = main;
declare class Circle extends Shape {
readonly containerAspectRatio: 1;
}
declare class Shape {
constructor(container: SVGPathElement | string | null, opts?: PathDrawingOptions);
}
Which TypeScript seems to allow:
const circle = new ProgressBar.Circle('#example-percent-container', {
color: '#FCB03C',
strokeWidth: 3,
trailWidth: 1,
text: {
value: '0',
},
});
object ^ {
var Circle: Instantiable0[typings.progressbarJs.circleMod.^] = js.native
}
class ^ () extends Circle
trait Circle
extends typings.progressbarJs.shapeMod.^ {
val containerAspectRatio: `1` = js.native
}
class ^ () extends Shape {
def this(container: String) = this()
def this(container: SVGPathElement) = this()
def this(container: String, opts: PathDrawingOptions) = this()
def this(container: Null, opts: PathDrawingOptions) = this()
def this(container: SVGPathElement, opts: PathDrawingOptions) = this()
}
class ^ () extends Circle
and add the wanted constructor by hand, should be easy enough
Instantiable0
is actually the class as a function, it has a newInstance0
method on it
Is this conversion correct?
export = Sortable;
declare class Sortable {
…
}
declare namespace Sortable {
…
}
to:
@JSImport("sortablejs", JSImport.Namespace)
@js.native
class ^ protected () extends Sortable {
def this(element: HTMLElement, options: Options) = this()
}
@JSImport("sortablejs", JSImport.Namespace)
@js.native
object ^ extends js.Object {
…
}
I’m getting a TypeError when trying to instantiate the class saying that it is not a constructor. It looks like its ending up as the module.
The library docs say:
import Sortable from "sortablejs”;
var sortable = new Sortable(…)
So shouldn’t it be:
@JSImport("sortablejs", JSImport.Default)
?
import ^, * as ^ from "sortablejs”;
?
Actually I think that is what it should be but in Scala.js that would be:
@JSImport("sortablejs", JSImport.Default)
@js.native
class ^ protected () extends Sortable {
def this(element: HTMLElement, options: Options) = this()
}
@JSImport("sortablejs", JSImport.Namespace)
@js.native
object ^ extends js.Object {
…
}
wouldn’t it?
default
. The reason why this works in typescript is that the esModuleInterop
compiler flag generates code that tries both ways somehow
esModuleInterop
behaviour in ST, but I haven't done any research in that direction
export default Sortable
instead of export = Sortable
@JSImport("broadcast-channel/types/broadcast-channel", "BroadcastChannel")
@js.native
class BroadcastChannel[T] protected () extends js.Object {
broadcast-channel/types/broadcast-channel
is a types script fills, specifically broadcast-channel.d.ts
import {BroadcastChannel} from "broadcast-channel/types/broadcast-channel"
, and it will compile and fail in the same way. the problem for ST is that there is in general no way of knowing if a module actually exists or not