scala-js-ts-importer icon indicating copy to clipboard operation
scala-js-ts-importer copied to clipboard

Default values

Open antonkulaga opened this issue 11 years ago • 3 comments

When I import ts files I often get methods like def this(object: Object3D, size: Double = ???, hex: Double = ???, linewidth: Double = ???) = this() with a lot of default arguments and corresponding " multiple overloaded alternatives of method " Maybe for such kind of methods it would be better to generate several methods without defaults, like def this(object: Object3D) = this() def this(object: Object3D, size: Double) = this() def this(object: Object3D, size: Double, hex: Double) = this() def this(object: Object3D, size: Double, hex: Double, linewidth: Double) = this()

I understand it is verbose but it allows to avoid doing many manual corrections.

antonkulaga avatar Sep 06 '14 08:09 antonkulaga

I suppose we could try to revert to the verbose way if there are two methods with default arguments.

sjrd avatar Sep 06 '14 16:09 sjrd

I don't know if this is the same issue that I'm thinking, but if it is not, I can open another issue.

What about

import scala.scalajs.js.UndefOr
import scala.scalajs.js.undefined

def this(
  object: Object3D,
  size: UndefOr[Double] = undefined,
  hex: UndefOr[Double] = undefined,
  linewidth: UndefOr[Double] = undefined) = this()

Could this be a possible solution?

onilton avatar Jun 14 '16 20:06 onilton

@onilton I don't think this is the same issue, no. The current issue is specifically about the "multiple overloaded alternatives have default arguments" compile error.

sjrd avatar Jun 16 '16 05:06 sjrd