question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`js.UndefOr` is no longer considered a subtype of `js.Any`

See original GitHub issue

Compiler version

  • 2.13.5 - pass
  • 3.0.0-RC1 - pass
  • 3.0.0-RC2 - fail
  • 3.0.0-RC3 - fail

Minimized code

import scala.scalajs.js

object Test {
  def x: js.UndefOr[Int] = 1
  x: js.Any
}

Output

[error] 5 |  x: js.Any
[error]   |  ^
[error]   |  Found:    scala.scalajs.js.UndefOr[Int]
[error]   |  Required: scalajs.js.Any
[error] one error found

Expectation

Success.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
smartercommented, Apr 28, 2021

if we just wanted to support conversions from js.UndefOr and not all unions of primitives, we could add an implicit def to https://github.com/lampepfl/dotty/blob/master/library-js/src/scala/scalajs/js/internal/UnitOps.scala in 3.1.

0reactions
japgollycommented, Apr 28, 2021

Oh silly me, 99% of the time we import scala.scalajs.js, not import scala.scalajs.js._ which is different to expected usage with most of my own libraries. Ok yep my bad, you’re right.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript types - Scala.js
Understanding how different types are mapped between Scala.js and JavaScript is crucial for correct interoperability. Some types map quite directly (like ...
Read more >
An unboxed js.Option[+A] type with undefined as None #422
Any (including all js.Dynamic inputs), or should it be converted to a runtime representation which is more likely to please the called code?...
Read more >
What types are special to the Scala compiler? - Stack Overflow
js.Any : conceptually a third subtype of Any , besides AnyVal and AnyRef . They have JavaScript semantics instead of Scala semantics.
Read more >
JavaScript types - 《Scala.js 1.0 Document》 - 书栈网
Understanding how different types are mapped between Scala.js and JavaScript is crucial for correct interoperability.Some types map quite ...
Read more >
scala-js/scala-js - Gitter
got it, I believe any subtype of js. ... I know is not magic but it seems far better than typescript and it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found