The problem with Typescript
Typescript is an amazing language: All the good of JavaScript, with proper typing systems. This is why for a very long time, Typescript was my prefered language for a very long time. The problem is, Typescript typing are artificial – they are enforced only on “compile” time – when compiling the Typescript code to Javascript. Let’s take a look at one example:
Well, surprisingly (at least for me) this is a valid code. It will “compile” and run without any errors – printing
string
as the result.
Scala?
Scala (like Kotlin) is yet another language that compiles to Java bytecode and can run on JVM. It has many benefits, especially “many of Scala’s design decisions are aimed to address criticisms of Java.[7] (according to wikipedia)
Well, that’s a good start for a language, right? We all hate Java, so Scala should be a good thing!

And it is even more powerful – Refined types can be used for any input you can handle. For example, the popular ORM [Slick](https://scala-slick.org/) has support for Refined types – meaning, you can always trust the data you are fetching from your database.
Wrapping Up
Refined types help us kill classes of bugs just by well defining our typing systems. It has also other benefits, as well defined types (vs using arbitrary Strings everywhere) makes the code clearer and reduced bugs. This is exciting news both for us, Application Security Engineers and for developers, as it could free us all to focus on other, more exciting news.
Does it mean we all have to start writing Scala? Not necessary. The same thing can be done with any language that supports a real typing system (as in “Not Typescript”). Which language are you using? Maybe it has a similar library to Refined? Make sure to let me know!