Scala JS/JVM Shared Implicit conversion

I have the following in my shared project:

object PubKeyConverter {
  implicit def toString(pubKey: PubKey): String = pubKey.toString

  implicit def fromString(pubKeyString: String): PubKey = PubKey(pubKeyString)

case class PubKey(pubKey: String) {
  def shortString = pubKey.replace("-----END PUBLIC KEY-----", "").takeRight(15)

  override def toString: String = pubKey

When I import my PubKeyConverter._ into my Scala JS project,
any highlighted errors go away for the following

val something: String = PubKey("some pub key")

However, I get a type mismatch during the actual compile.
Any ideas as to why? The class itself works fine in both my JVM and JS projects. :expressionless:


Looks like the problem is this line:

implicit def toString(pubKey: PubKey): String = pubKey.toString

toString is laden with extra connotations, and it looks like it doesn’t work here for some reason. In my experiments, naming this def something else makes it work…


The imported toString is probably getting shadowed by the class member toString.