Skip to content

Commit

Permalink
Merge pull request #325 from ScalablyTyped/enable-scalajs-defined-tra…
Browse files Browse the repository at this point in the history
…its-by-default-for-scala-3

Enable `@ScalaJSDefined` by default for Scala 3
  • Loading branch information
oyvindberg authored Jul 16, 2021
2 parents ba66bf6 + 7e870d6 commit d209b8e
Show file tree
Hide file tree
Showing 648 changed files with 4,208 additions and 4,766 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object Main {
val DefaultOptions = ConversionOptions(
useScalaJsDomTypes = true,
outputPackage = Name.typings,
enableScalaJsDefined = Selection.None,
enableScalaJsDefined = Selection.All,
flavour = Flavour.Normal,
ignored = SortedSet("typescript"),
stdLibs = SortedSet("es6"),
Expand Down
2 changes: 1 addition & 1 deletion docs/conversion-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ project.settings(
)
```

By default this is off, that is `Selection.None()`
By default this is *on* for Scala 3, and *off* for Scala 2.

### `stStdLib`
This mirrors the `--lib` option to typescript, see
Expand Down
4 changes: 2 additions & 2 deletions docs/devel/running.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ For development you'll always use "debug mode".
| `-dontCleanProject` | Normally the CI build aggressively resets the ScalablyTyped git repo. Enabling this will skip that
| `-enableParseCache` | The Typescript parser is somewhat slow. Enabling this uses java serialization to cache when possible
| `-forceCommit` | Commit and build sbt plugin in debug mode
| `-scala212` | Build libraries with Scala 2.12 instead of 2.13
| `-scalajs06` | Build libraries with Scala.js 0.6 instead of 1
| `-scala212` | Build libraries with Scala 2.12 instead of 3.0.0
| `-scala213` | Build libraries with Scala 2.13 instead of 3.0.0
| `-offline` | Skip pulling newest DefinitelyTyped and running `npm update`
| `-pedantic` | Make the converter more strict. Most things don't work yet in this mode
| `-softWrites` | Will only write changed/deleted files. This is essential if you want to keep ScalablyTyped products open in an IDE to avoid reindexing the world.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import org.scalablytyped.converter.internal.ts._
*/
object IsUserImplementable {
def apply(interface: WithParents[TsDeclInterface]): Boolean =
pred(interface.value) && interface.parents.forall(pred)
if (interface.unresolved.nonEmpty) false
else pred(interface.value) && interface.parents.forall(pred)

def legalName(name: TsIdent): Boolean =
name =/= TsIdent.Apply && name =/= TsIdent.namespaced
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,12 @@ object Ci {
"org.scalablytyped",
)

val enableScalaJsDefined: Selection[TsIdentLibrary] =
if (flags contains "-enableScalaJsDefined")
Selection.AllExcept(Libraries.Slow.to[Seq]: _*)
else Selection.None

Some(
Config(
conversion = ConversionOptions(
useScalaJsDomTypes = shouldUseScalaJsDomTypes,
outputPackage = outputPackage,
enableScalaJsDefined = enableScalaJsDefined,
enableScalaJsDefined = Selection.All,
flavour = flavour,
ignored = Libraries.ignored.map(_.value),
stdLibs = SortedSet("esnext.full"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ trait ImporterHarness extends AnyFunSuite {
new Phase2ToScalaJs(
pedantic,
scalaVersion = version.scala,
enableScalaJsDefined = Selection.None,
enableScalaJsDefined = Selection.All,
outputPkg = flavour.outputPkg,
flavour = flavour,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ object ScalablyTypedPluginBase extends AutoPlugin {
override lazy val projectSettings =
Seq(
stInternalExpandTypeMappings := EnabledTypeMappingExpansion.DefaultSelection.map(_.value),
stEnableScalaJsDefined := converter.Selection.None,
stEnableScalaJsDefined := {
if ((Compile / Keys.scalaVersion).value.startsWith("3")) converter.Selection.All else converter.Selection.None
},
stFlavour := converter.Flavour.Normal,
stIgnore := List("typescript"),
stOutputPackage := Name.typings.unescaped,
Expand Down
2 changes: 1 addition & 1 deletion tests/antd/check/a/antd/build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
organization := "org.scalablytyped"
name := "antd"
version := "4.3.1-8e4ccb"
version := "4.3.1-f83bb0"
scalaVersion := "3.0.1"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
Expand Down
5 changes: 2 additions & 3 deletions tests/antd/check/a/antd/src/main/scala/typings/antd/mod.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, J
object mod {

/* Inlined parent std.Omit<rc-field-form.rc-field-form/es/Form.FormProps, 'form'> */
@js.native
trait FormProps extends StObject {

var name: js.UndefOr[String] = js.native
var name: js.UndefOr[String] = js.undefined

var prefixCls: js.UndefOr[String] = js.native
var prefixCls: js.UndefOr[String] = js.undefined
}
object FormProps {

Expand Down
2 changes: 1 addition & 1 deletion tests/antd/check/r/rc-field-form/build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
organization := "org.scalablytyped"
name := "rc-field-form"
version := "1.4.4-f48d99"
version := "1.4.4-d9cd5b"
scalaVersion := "3.0.1"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, J

object mod {

@js.native
trait FormProps extends StObject {

var name: js.UndefOr[String] = js.native
var name: js.UndefOr[String] = js.undefined
}
object FormProps {

Expand Down
4 changes: 2 additions & 2 deletions tests/augment-module/check/l/lodash/build.sbt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
organization := "org.scalablytyped"
name := "lodash"
version := "4.14-f636d6"
version := "4.14-5cc4a6"
scalaVersion := "3.0.1"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
"com.olvind" %%% "scalablytyped-runtime" % "2.4.2",
"org.scalablytyped" %%% "std" % "0.0-unknown-58cf91")
"org.scalablytyped" %%% "std" % "0.0-unknown-434525")
publishArtifact in packageDoc := false
scalacOptions ++= List("-encoding", "utf-8", "-feature", "-language:implicitConversions", "-language:higherKinds", "-language:existentials", "-no-indent")
licenses += ("MIT", url("http://opensource.org/licenses/MIT"))
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ object fpMod extends Shortcut {
@js.native
val ^ : LoDashFp = js.native

@js.native
trait LoDashFp extends StObject {

def curry[T1, R](func: js.Function1[/* t1 */ T1, R]): CurriedFunction1[T1, R] = js.native
def curry[T1, T2, R](func: js.Function2[/* t1 */ T1, /* t2 */ T2, R]): CurriedFunction2[T1, T2, R] = js.native
def curry[T1, R](func: js.Function1[/* t1 */ T1, R]): CurriedFunction1[T1, R]
def curry[T1, T2, R](func: js.Function2[/* t1 */ T1, /* t2 */ T2, R]): CurriedFunction2[T1, T2, R]
@JSName("curry")
var curry_Original: Curry = js.native
var curry_Original: Curry
}
object LoDashFp {

Expand All @@ -47,19 +46,15 @@ object fpMod extends Shortcut {
object global {

// tslint:disable-next-line:no-empty-interface
@js.native
trait Map[K, V] extends StObject

// tslint:disable-next-line:no-empty-interface
@js.native
trait Set[T] extends StObject

// tslint:disable-next-line:no-empty-interface
@js.native
trait WeakMap[K /* <: js.Object */, V] extends StObject

// tslint:disable-next-line:no-empty-interface
@js.native
trait WeakSet[T] extends StObject
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,15 @@ object mod extends Shortcut {
object global {

// tslint:disable-next-line:no-empty-interface
@js.native
trait Map[K, V] extends StObject

// tslint:disable-next-line:no-empty-interface
@js.native
trait Set[T] extends StObject

// tslint:disable-next-line:no-empty-interface
@js.native
trait WeakMap[K /* <: js.Object */, V] extends StObject

// tslint:disable-next-line:no-empty-interface
@js.native
trait WeakSet[T] extends StObject
}
}
2 changes: 1 addition & 1 deletion tests/augment-module/check/s/std/build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
organization := "org.scalablytyped"
name := "std"
version := "0.0-unknown-58cf91"
version := "0.0-unknown-434525"
scalaVersion := "3.0.1"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ import org.scalablytyped.runtime.StObject
import scala.scalajs.js
import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, JSBracketAccess}

@js.native
trait Array[T] extends StObject
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ import org.scalablytyped.runtime.StObject
import scala.scalajs.js
import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, JSBracketAccess}

@js.native
trait ArrayLike[T] extends StObject
2 changes: 1 addition & 1 deletion tests/aws-sdk/check/a/aws-sdk/build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
organization := "org.scalablytyped"
name := "aws-sdk"
version := "2.247.1-8dbdeb"
version := "2.247.1-8fb9b0"
scalaVersion := "3.0.1"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,17 @@ object configMod {
def loadFromPath(path: String): Config & ConfigurationServicePlaceholders & APIVersions = js.native
}

@js.native
trait APIVersions extends StObject {

/**
* A string in YYYY-MM-DD format that represents the latest possible API version that can be used in all services (unless overridden by apiVersions). Specify \'latest\' to use the latest possible version.
*/
var apiVersion: js.UndefOr[latest | String] = js.native
var apiVersion: js.UndefOr[latest | String] = js.undefined

/**
* A map of service identifiers (the lowercase service class name) with the API version to use when instantiating a service. Specify 'latest' for each individual that can use the latest available version.
*/
var apiVersions: js.UndefOr[ConfigurationServiceApiVersions] = js.native
var apiVersions: js.UndefOr[ConfigurationServiceApiVersions] = js.undefined
}
object APIVersions {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ object configServicePlaceholdersMod {
var dynamodb: js.UndefOr[ClientConfiguration] = js.native
}

@js.native
trait ConfigurationServiceApiVersions extends StObject {

var dynamodb: js.UndefOr[apiVersion] = js.native
var dynamodb: js.UndefOr[apiVersion] = js.undefined
}
object ConfigurationServiceApiVersions {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,20 @@ object documentClientMod {
*/
type AttributeAction = _AttributeAction | String

@js.native
trait ConverterOptions extends StObject {

/**
* An optional flag indicating that the document client should cast
* empty strings, buffers, and sets to NULL shapes
*/
var convertEmptyValues: js.UndefOr[Boolean] = js.native
var convertEmptyValues: js.UndefOr[Boolean] = js.undefined

/**
* Whether to return numbers as a NumberValue object instead of
* converting them to native JavaScript numbers. This allows for the
* safe round-trip transport of numbers of arbitrary size.
*/
var wrapNumbers: js.UndefOr[Boolean] = js.native
var wrapNumbers: js.UndefOr[Boolean] = js.undefined
}
object ConverterOptions {

Expand All @@ -69,20 +68,19 @@ object documentClientMod {
}
}

@js.native
trait DocumentClientOptions
extends StObject
with ConverterOptions {

/**
* An optional map of parameters to bind to every request sent by this service object.
*/
var params: js.UndefOr[StringDictionary[js.Any]] = js.native
var params: js.UndefOr[StringDictionary[js.Any]] = js.undefined

/**
* An optional pre-configured instance of the AWS.DynamoDB service object to use for requests. The object may bound parameters used by the document client.
*/
var service: js.UndefOr[^] = js.native
var service: js.UndefOr[^] = js.undefined
}
object DocumentClientOptions {

Expand Down
4 changes: 2 additions & 2 deletions tests/bigint/check/b/bigint/build.sbt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
organization := "org.scalablytyped"
name := "bigint"
version := "v5.5.3-27693a"
version := "v5.5.3-3a5bb3"
scalaVersion := "3.0.1"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
"com.olvind" %%% "scalablytyped-runtime" % "2.4.2",
"org.scalablytyped" %%% "std" % "0.0-unknown-1c9490")
"org.scalablytyped" %%% "std" % "0.0-unknown-b11d9a")
publishArtifact in packageDoc := false
scalacOptions ++= List("-encoding", "utf-8", "-feature", "-language:implicitConversions", "-language:higherKinds", "-language:existentials", "-no-indent")
licenses += ("MIT", url("http://opensource.org/licenses/MIT"))
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import org.scalablytyped.runtime.StObject
import scala.scalajs.js
import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, JSBracketAccess}

@js.native
trait Test extends StObject {

var a: js.BigInt = js.native
var a: js.BigInt

var b: js.BigInt = js.native
var b: js.BigInt

var c: typings.bigint.BigInt.BigInt = js.native
var c: typings.bigint.BigInt.BigInt
}
object Test {

Expand Down
2 changes: 1 addition & 1 deletion tests/bigint/check/s/std/build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
organization := "org.scalablytyped"
name := "std"
version := "0.0-unknown-1c9490"
version := "0.0-unknown-b11d9a"
scalaVersion := "3.0.1"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ import org.scalablytyped.runtime.StObject
import scala.scalajs.js
import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, JSBracketAccess}

@js.native
trait Array[T] extends StObject
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ import org.scalablytyped.runtime.StObject
import scala.scalajs.js
import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, JSBracketAccess}

@js.native
trait BigInt extends StObject
4 changes: 2 additions & 2 deletions tests/chart.js/check/c/chart_dot_js/build.sbt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
organization := "org.scalablytyped"
name := "chart_dot_js"
version := "0.0-unknown-6a0b5b"
version := "0.0-unknown-9b65c8"
scalaVersion := "3.0.1"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
"com.olvind" %%% "scalablytyped-runtime" % "2.4.2",
"org.scalablytyped" %%% "std" % "0.0-unknown-06ca5c")
"org.scalablytyped" %%% "std" % "0.0-unknown-7d3007")
publishArtifact in packageDoc := false
scalacOptions ++= List("-encoding", "utf-8", "-feature", "-language:implicitConversions", "-language:higherKinds", "-language:existentials", "-no-indent")
licenses += ("MIT", url("http://opensource.org/licenses/MIT"))
Loading

0 comments on commit d209b8e

Please sign in to comment.