scala-ts / scala-ts Goto Github PK
View Code? Open in Web Editor NEW:wrench: Scala datamodel transpiler
Home Page: https://scala-ts.github.io/scala-ts
License: MIT License
:wrench: Scala datamodel transpiler
Home Page: https://scala-ts.github.io/scala-ts
License: MIT License
Followed your instructions to add the plugin to sbt but it is failing to resolve. Also noticed all the links to pom / jar on this page return 404s:
http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.miloszpp%22%20AND%20a%3A%22scala-ts%22
Hi,
I think I have a different use case then this project's goal. I just wanted to make sure. We use tapir for our backend and also use it to generate a scalajs client module and publish this as a npm package. This module will then be used by typescript front-end developers. I believe the difference between this project and our need, is that we have implemented the scalajs client and just would want to include d.ts
files next to the compiled js.
Is this something that could be accomplished using this project?
Hi everyone, will there be a public Scala 3 build version of this library? I see that you are still active, I wonder if this is happening any time soon? I would like to export type definitions of projects in Scala 3 which will expose some API stuff to the typescript environment. And this scala-ts is just the right tool to do it. Do you have roadmap for Scala 3 release? Are you close? I would like to know :) Or maybe there is something I can help with, maybe testing if it works fine ;)
Hi @miloszpp ,
About 2 years ago my company encountered your library and since it was pretty awesome, we tried to use it. Unfortunately we encountered limitations in its design, so we made scala-tsi, to solve the same problem in a different way.
I noticed you are currently not maintaining the project. Is it an idea to mention scala-tsi in the README as a maintained alternative?
Hi,
Currently, scala-ts is preventing us to upgrade our project to SBT 1.0. I've seen that that support has already been implemented in returntocorp's fork. Should I create a Pull Request to provide the support?
Thank you very much!
Luis
I have a multi-module setup with a following structure:
There are plenty of enums and generic ADTs that reside in commons, because they are used in both apis
I was fighting for quite a while, but didn't find if it's possible to include class from dependent project into scalats compilation pipeline. In the end I would have *.ts file like this one:
import SomeEnum from './SomeEnum.ts'
interface SomeEntity {
field: string
field2: SomeEnum
}
But the SomeEnum.ts
doesn't exist and not resolved.
I would appreciate if you could give me some directions for this investigation, in case I'm missing something. Otherwise I would be more than happy to discuss and/or implement possible solution if it's part of the project scope
Any plans to support Scala ?
Can it be done in standalone mode and if so how does one go about it? I compiled a jar using SBT and followed the readme on how to use scala-ts in standalone mode, but I keep getting ava.lang.NoClassDefFoundError
errors.
Is there a FAQ or common issues doc available?
Under certain circumstances, the default file printer results in duplicate type declaration if not cleaning before compile (1. Compile, 2. Update type T in source file, 3. Duplicate in T.ts ?)
Currently it's only possible to set them when using as SBT plugin.
Currently, the plugin will fail on the following class hierarchy :
case class Foo[T](a : T)
case class Bar(b: Foo[String], c:Foo[Int])
will give the following typings :
export interface IBar {
c: IFoo;
b: IFoo;
}
export class Bar {
constructor(
public c: Foo,
public b: Foo
) {}
}
export interface IFoo {
a: string;
}
export class Foo {
constructor(
public a: string
) {}
}
In which Foo as a string attribute, which is incorrect.
Please let me know if there's any plan for you to maintain this plugin (for example fixing this case :D)
Thanks for the great work anyway :)
Nico
How to make this installation process simpler?
sealed trait Foo {
def name: String
}
sealed trait FooCat extends Foo
sealed trait FooCatVariant extends FooCat
case object Bar extends FooCatVariant {
val name = "Bar"
}
Describe the bug/feature request
Tried to install the sbt plugin via plugins.sbt and build file. Plugin finally got downloaded but facing the following error
https://repo1.maven.org/maven2/io/github/scala-ts/sbt-scala-ts_2.12_1.0/0.5.13/sbt-scala-ts-0.5.13.jar 100.0% [##########] 30.5 KiB (60.5 KiB / s) [info] Fetched artifacts of [error] java.lang.RuntimeException: found version conflict(s) in library dependencies; some are suspected to be binary incompatible: [error] [error] * org.scala-lang.modules:scala-xml_2.12:2.1.0 (early-semver) is selected over {1.0.6} [error] +- org.scala-lang:scala-compiler:2.12.17 (depends on 2.1.0) [error] +- org.scalariform:scalariform_2.12:0.2.0 (depends on 1.0.6) [error] [error] [error] this can be overridden using libraryDependencySchemes or evictionErrorLevel [error] at scala.sys.package$.error(package.scala:30) [error] at sbt.internal.LibraryManagement$.resolve$1(LibraryManagement.scala:89) [error] at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$12(LibraryManagement.scala:133) [error] at sbt.util.Tracked$.$anonfun$lastOutput$1(Tracked.scala:73) [error] at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$20(LibraryManagement.scala:146) [error] at scala.util.control.Exception$Catch.apply(Exception.scala:228) [error] at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$11(LibraryManagement.scala:146) [error] at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$11$adapted(LibraryManagement.scala:127) [error] at sbt.util.Tracked$.$anonfun$inputChangedW$1(Tracked.scala:219) [error] at sbt.internal.LibraryManagement$.cachedUpdate(LibraryManagement.scala:160) [error] at sbt.Classpaths$.$anonfun$updateTask0$1(Defaults.scala:3687) [error] at scala.Function1.$anonfun$compose$1(Function1.scala:49) [error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62) [error] at sbt.std.Transform$$anon$4.work(Transform.scala:68) [error] at sbt.Execute.$anonfun$submit$2(Execute.scala:282) [error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23) [error] at sbt.Execute.work(Execute.scala:291) [error] at sbt.Execute.$anonfun$submit$1(Execute.scala:282) [error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265) [error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:64) [error] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) [error] at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577) [error] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) [error] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) [error] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) [error] at java.base/java.lang.Thread.run(Thread.java:1589) [error] (update) found version conflict(s) in library dependencies; some are suspected to be binary incompatible: [error] [error] * org.scala-lang.modules:scala-xml_2.12:2.1.0 (early-semver) is selected over {1.0.6} [error] +- org.scala-lang:scala-compiler:2.12.17 (depends on 2.1.0) [error] +- org.scalariform:scalariform_2.12:0.2.0 (depends on 1.0.6) [error] [error] [error] this can be overridden using libraryDependencySchemes or evictionErrorLevel
To Reproduce
Steps to reproduce the behavior:
java version at 17
(base) BLRL-300075517:spark 300075517$ java --version java 17 2021-09-14 LTS Java(TM) SE Runtime Environment (build 17+35-LTS-2724) Java HotSpot(TM) 64-Bit Server VM (build 17+35-LTS-2724, mixed mode, sharing)
add plugin in addSbtPlugin("io.github.scala-ts" % "sbt-scala-ts" % "0.5.13")
for github clone of apache spark: https://github.com/apache/spark
try sbt compile
Expected behavior
sbt compile
should run without issues
Additional context
None, the build fails in the add plugin command itself
Currently, I meet with the wrong/unexpected behaviour during generating ADT with AnyVal. For instance, while generating the following ADT's:
case class Name(value: String) extend AnyVal
case class Age(value: Int) extend AnyVal
case class Person(name: Name, age: Age)
and I receive:
export interface Name {
value: string;
}
export interface Age {
value: number;
}
export interface Person {
name: Name;
age: Age;
}
but the result should be just:
export interface Person {
name: string;
age: number;
}
What do you think about it? Of course, It is just a proposition.
With scalaVersion := "3.2.2"
sbt compile
doesn't work in custom-cfg
project
[error] java.lang.reflect.InvocationTargetException
[error] java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[error] java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[error] java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[error] java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
[error] io.github.scalats.plugins.Configuration$.instances$$anonfun$1(Configuration.scala:241)
[error] scala.collection.StrictOptimizedIterableOps.flatMap(StrictOptimizedIterableOps.scala:118)
[error] scala.collection.StrictOptimizedIterableOps.flatMap$(StrictOptimizedIterableOps.scala:105)
[error] scala.collection.convert.JavaCollectionWrappers$JListWrapper.flatMap(JavaCollectionWrappers.scala:107)
[error] io.github.scalats.plugins.Configuration$.instances(Configuration.scala:246)
[error] io.github.scalats.plugins.Configuration$.insts$1(Configuration.scala:189)
[error] io.github.scalats.plugins.Configuration$.declarationMappers$1(Configuration.scala:197)
[error] io.github.scalats.plugins.Configuration$.load(Configuration.scala:205)
[error] io.github.scalats.plugins.ScalaTSPhase$.parse$1(CompilerPlugin.scala:96)
[error] io.github.scalats.plugins.ScalaTSPhase$.initer(CompilerPlugin.scala:117)
[error] io.github.scalats.plugins.CompilerPlugin.init(CompilerPlugin.scala:33)
[error] dotty.tools.dotc.plugins.Plugins.$anonfun$7(Plugins.scala:126)
[error] scala.collection.immutable.List.flatMap(List.scala:293)
[error] dotty.tools.dotc.plugins.Plugins.addPluginPhases(Plugins.scala:126)
[error] dotty.tools.dotc.plugins.Plugins.addPluginPhases$(Plugins.scala:19)
[error] dotty.tools.dotc.core.Contexts$ContextBase.addPluginPhases(Contexts.scala:828)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:224)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:266)
[error] dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
[error] dotty.tools.dotc.Run.compileUnits(Run.scala:266)
[error] dotty.tools.dotc.Run.compileSources(Run.scala:190)
[error] dotty.tools.dotc.Run.compile(Run.scala:174)
[error] dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
[error] dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:88)
[error] dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
[error] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:193)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:248)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:183)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:163)
[error] sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:163)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:211)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:179)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:177)
[error] sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:463)
[error] sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
[error] sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:263)
[error] sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:418)
[error] sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:506)
[error] sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:405)
[error] sbt.internal.inc.Incremental$.apply(Incremental.scala:171)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:488)
[error] sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:425)
[error] sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error] sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2364)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2314)
[error] sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:30)
[error] sbt.internal.io.Retry$.apply(Retry.scala:46)
[error] sbt.internal.io.Retry$.apply(Retry.scala:28)
[error] sbt.internal.io.Retry$.apply(Retry.scala:23)
[error] sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:30)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2312)
[error] scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error] sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error] sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error] sbt.Execute.work(Execute.scala:291)
[error] sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error] sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[error] java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[error] java.base/java.lang.Thread.run(Thread.java:834)
Hi,
I just wanted to let you now that we (Elium.tv) are maintaining a fork of this lib. We have diverged some commits ago regarding implementation of common needs (like sealed traits handling), but some people may find it useful ๐
Nevertheless, thanks for the time you contributed maintaining this project, it definitely helped us !
I want to use scala-ts as d.ts generator from scala.js code
For example, I have
case class Foo(x: Int) {
def calc(y: Int): Int = x + y
}
I would like to generate
export interface Foo {
x: Int
calc: (y: Int) => Int
}
Is it possible?
I'm encoutering a problem when running the plugin on
case class Bar(foo: Boolean) {
def func(other: Bar): Int = {
(this.foo, other.foo) match {
case (true, b) => 1
case (false, b) => 1
}
}
}
The plugin will crash with the following error message : java.lang.VerifyError: class scala.Tuple2$mcZZ$sp overrides final method _1$mcZ$sp.()Z
It works correctly if I change the function to this (not equivalent) one :
case class Bar(foo: Boolean) {
def func(other: Bar): Int = {
(this.foo, other.foo) match {
case (a,b) => 1
}
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.