Skip to content

Commit

Permalink
Added test case to show issue with export default
Browse files Browse the repository at this point in the history
Some pacakges such as pixi.js re-export 3rd party libraries under their
own namespace, e.g. @pixi/util does the following:

export { default as EventEmitter } from 'eventemitter3'

in order to provide the EventEmitter module from eventemitter3 under the
@pixi/util namespace.

The converter appears to ignore exports of this form and no module is
created. This breaks libraries that rely on this behavior such as Pixi.
  • Loading branch information
jmcclell committed Jul 30, 2024
1 parent 02257bf commit 2039cd5
Show file tree
Hide file tree
Showing 27 changed files with 215 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ trait ImporterTest extends AnyFunSuite with ImporterHarness with ParallelTestExe
test("pixi.js")(assertImportsOk("pixi.js", pedantic = false))
test("augment-module")(assertImportsOk("augment-module", pedantic = false))
test("typings-json")(assertImportsOk("typings-json", pedantic = true))
test("export-default")(assertImportsOk("export-default", pedantic = true))
test("export-as-namespace")(assertImportsOk("export-as-namespace", pedantic = true))
test("babylon")(assertImportsOk("babylon", pedantic = true))
test("bigint")(assertImportsOk("bigint", pedantic = true))
Expand Down
11 changes: 11 additions & 0 deletions tests/export-default/check-3/e/export-default/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
organization := "org.scalablytyped"
name := "export-default"
version := "0.0-unknown-d7a32e"
scalaVersion := "3.3.1"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
"com.olvind" %%% "scalablytyped-runtime" % "2.4.2",
"org.scalablytyped" %%% "foo" % "0.0-unknown-f52260")
publishArtifact in packageDoc := false
scalacOptions ++= List("-encoding", "utf-8", "-feature", "-language:implicitConversions", "-language:higherKinds", "-language:existentials", "-no-indent", "-source:future")
licenses += ("MIT", url("http://opensource.org/licenses/MIT"))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=1.9.6
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("org.scala-js" %% "sbt-scalajs" % "1.11.0")
15 changes: 15 additions & 0 deletions tests/export-default/check-3/e/export-default/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

# Scala.js typings for export-default




## Note
This library has been generated from typescript code from first party type definitions.

Provided with :purple_heart: from [ScalablyTyped](https://github.com/oyvindberg/ScalablyTyped)

## Usage
See [the main readme](../../readme.md) for instructions.


Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package typings.exportDefault

import org.scalablytyped.runtime.StObject
import scala.scalajs.js
import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, JSBracketAccess}

/* This can be used to `require` the library as a side effect.
If it is a global library this will make scalajs-bundler include it */
@JSImport("export-default", JSImport.Namespace)
@js.native
object exportDefaultRequire extends StObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package typings.exportDefault

import typings.foo.mod.default
import org.scalablytyped.runtime.StObject
import scala.scalajs.js
import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, JSBracketAccess}

object mod {

@JSImport("export-default", "Foo")
@js.native
open class Foo () extends default
}
10 changes: 10 additions & 0 deletions tests/export-default/check-3/f/foo/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
organization := "org.scalablytyped"
name := "foo"
version := "0.0-unknown-f52260"
scalaVersion := "3.3.1"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
"com.olvind" %%% "scalablytyped-runtime" % "2.4.2")
publishArtifact in packageDoc := false
scalacOptions ++= List("-encoding", "utf-8", "-feature", "-language:implicitConversions", "-language:higherKinds", "-language:existentials", "-no-indent", "-source:future")
licenses += ("MIT", url("http://opensource.org/licenses/MIT"))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=1.9.6
1 change: 1 addition & 0 deletions tests/export-default/check-3/f/foo/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("org.scala-js" %% "sbt-scalajs" % "1.11.0")
15 changes: 15 additions & 0 deletions tests/export-default/check-3/f/foo/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

# Scala.js typings for foo




## Note
This library has been generated from typescript code from first party type definitions.

Provided with :purple_heart: from [ScalablyTyped](https://github.com/oyvindberg/ScalablyTyped)

## Usage
See [the main readme](../../readme.md) for instructions.


Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package typings.foo

import org.scalablytyped.runtime.StObject
import scala.scalajs.js
import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, JSBracketAccess}

/* This can be used to `require` the library as a side effect.
If it is a global library this will make scalajs-bundler include it */
@JSImport("foo", JSImport.Namespace)
@js.native
object fooRequire extends StObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package typings.foo

import org.scalablytyped.runtime.StObject
import scala.scalajs.js
import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, JSBracketAccess}

object mod {

@JSImport("foo", JSImport.Default)
@js.native
open class default ()
extends StObject
with Foo

trait Foo extends StObject
}
1 change: 1 addition & 0 deletions tests/export-default/in/export-default/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as Foo } from "foo";
1 change: 1 addition & 0 deletions tests/export-default/in/foo/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default class Foo {}
10 changes: 10 additions & 0 deletions tests/pixi-utils-7.4.0/check-3/e/eventemitter3/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
organization := "org.scalablytyped"
name := "eventemitter3"
version := "0.0-unknown-f8988b"
scalaVersion := "3.3.1"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
"com.olvind" %%% "scalablytyped-runtime" % "2.4.2")
publishArtifact in packageDoc := false
scalacOptions ++= List("-encoding", "utf-8", "-feature", "-language:implicitConversions", "-language:higherKinds", "-language:existentials", "-no-indent", "-source:future")
licenses += ("MIT", url("http://opensource.org/licenses/MIT"))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=1.9.6
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("org.scala-js" %% "sbt-scalajs" % "1.11.0")
15 changes: 15 additions & 0 deletions tests/pixi-utils-7.4.0/check-3/e/eventemitter3/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

# Scala.js typings for eventemitter3




## Note
This library has been generated from typescript code from first party type definitions.

Provided with :purple_heart: from [ScalablyTyped](https://github.com/oyvindberg/ScalablyTyped)

## Usage
See [the main readme](../../readme.md) for instructions.


Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package typings.eventemitter3

import org.scalablytyped.runtime.StObject
import scala.scalajs.js
import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, JSBracketAccess}

/* This can be used to `require` the library as a side effect.
If it is a global library this will make scalajs-bundler include it */
@JSImport("eventemitter3", JSImport.Namespace)
@js.native
object eventemitter3Require extends StObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package typings.eventemitter3

import org.scalablytyped.runtime.StObject
import scala.scalajs.js
import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, JSBracketAccess}

object mod {

@JSImport("eventemitter3", JSImport.Namespace)
@js.native
open class ^[EventTypes, Context /* <: Any */] ()
extends StObject
with EventEmitter[EventTypes, Context]

trait EventEmitter[EventTypes, Context /* <: Any */] extends StObject
}
11 changes: 11 additions & 0 deletions tests/pixi-utils-7.4.0/check-3/p/pixi__utils/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
organization := "org.scalablytyped"
name := "pixi__utils"
version := "0.0-unknown-02740c"
scalaVersion := "3.3.1"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
"com.olvind" %%% "scalablytyped-runtime" % "2.4.2",
"org.scalablytyped" %%% "eventemitter3" % "0.0-unknown-f8988b")
publishArtifact in packageDoc := false
scalacOptions ++= List("-encoding", "utf-8", "-feature", "-language:implicitConversions", "-language:higherKinds", "-language:existentials", "-no-indent", "-source:future")
licenses += ("MIT", url("http://opensource.org/licenses/MIT"))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=1.9.6
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("org.scala-js" %% "sbt-scalajs" % "1.11.0")
15 changes: 15 additions & 0 deletions tests/pixi-utils-7.4.0/check-3/p/pixi__utils/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

# Scala.js typings for pixi__utils




## Note
This library has been generated from typescript code from first party type definitions.

Provided with :purple_heart: from [ScalablyTyped](https://github.com/oyvindberg/ScalablyTyped)

## Usage
See [the main readme](../../readme.md) for instructions.


Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package typings.pixiUtils

import typings.eventemitter3.mod.^
import org.scalablytyped.runtime.StObject
import scala.scalajs.js
import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, JSBracketAccess}

object libMod {

@JSImport("@pixi/utils/lib", "EventEmitter")
@js.native
open class EventEmitter[EventTypes, Context /* <: Any */] () extends ^[EventTypes, Context]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package typings.pixiUtils

import org.scalablytyped.runtime.StObject
import scala.scalajs.js
import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, JSBracketAccess}

/* This can be used to `require` the library as a side effect.
If it is a global library this will make scalajs-bundler include it */
@JSImport("@pixi/utils", JSImport.Namespace)
@js.native
object pixiUtilsRequire extends StObject

0 comments on commit 2039cd5

Please sign in to comment.