-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check that conversions to scalajs-dom refers to existing types, and v…
…erify number of type parameters.
- Loading branch information
1 parent
97e942a
commit b3efa41
Showing
3 changed files
with
56 additions
and
16 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...alablytyped/converter/internal/scalajs/flavours/ReportMissingScalaJsDomTranslations.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.scalablytyped.converter.internal.scalajs | ||
package flavours | ||
|
||
object ReportMissingScalaJsDomTranslations extends App { | ||
val conversions = new ScalaJsDomNames(new QualifiedName.StdNames(Name.std)).All | ||
val conversionTarget = conversions.map(_.to).toSet | ||
val ScalaJsDom = QualifiedName("org.scalajs.dom") | ||
val missing = ScalaJsClasses.ScalaJsTypes.collect { | ||
case (qname, _) | ||
if qname.startsWith(ScalaJsDom) && | ||
!conversionTarget(qname) && | ||
!qname.parts.contains(Name("raw")) && | ||
!qname.parts.contains(Name("experimental")) && | ||
!qname.parts.contains(Name("crypto")) && | ||
!qname.parts.contains(Name("svg")) && | ||
!qname.parts.contains(Name("html")) && | ||
!qname.parts.contains(Name("idb")) && | ||
!qname.parts(qname.parts.length - 2).unescaped.head.isUpper => | ||
qname | ||
} | ||
|
||
missing.toList.sortBy(_.parts).foreach(qname => println(qname.parts.map(_.unescaped).mkString("."))) | ||
} |
19 changes: 19 additions & 0 deletions
19
...est/scala/org/scalablytyped/converter/internal/scalajs/flavours/ScalaJsDomNamesTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.scalablytyped.converter.internal.scalajs | ||
package flavours | ||
|
||
class ScalaJsDomNamesTest extends org.scalatest.funsuite.AnyFunSuite { | ||
test("check that scalajs-dom names exist and matches expectations") { | ||
val conversions = new ScalaJsDomNames(new QualifiedName.StdNames(Name.std)).All | ||
conversions.foreach { conversion => | ||
ScalaJsClasses.ScalaJsTypes(conversion.to) match { | ||
case cls: ClassTree => | ||
if (conversion.tparams.length != cls.tparams.length) | ||
fail(s"Conversion $conversion should have had ${cls.tparams.length} tparams ") | ||
|
||
case ta: TypeAliasTree => | ||
if (conversion.tparams.length != ta.tparams.length) | ||
fail(s"Conversion $conversion should have had ${ta.tparams.length} tparams ") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters