swachter / scala-ts

33 stars 2 forks source link

Wrong type mapping using type alias for js.Array #3

Closed daenenk closed 3 years ago

daenenk commented 3 years ago

Thanks for this project. Very useful!

The scala-js code

package example

import scala.scalajs.js
import scala.scalajs.js.annotation._

object Example {
  type Elem = js.Tuple2[String, js.Any]
  type Elems = js.Array[Elem]
}

@JSExportTopLevel("Example")
@JSExportAll
class Example() {

  import Example._

  def foo(a: Elems) = a

}

generates the TS facade

export class Example {
  constructor()
  foo(a: Array): Array    // <==== here is the error
}
export namespace example {
  namespace Example {
    type Elem = [string, any]
    type Elems = (example.Example.Elem)[]
  }
}

while

  def foo(a: js.Array[Elem]) = a

is transpiled correctly to

  foo(a: (example.Example.Elem)[]): (example.Example.Elem)[]
swachter commented 3 years ago

fixed in v0.11.0