# Is there any library similar to Typescript for Julia?

**URL:** https://discourse.julialang.org/t/is-there-any-library-similar-to-typescript-for-julia/80160
**Category:** Teaching & Outreach
**Tags:** question
**Created:** [April 27, 2022, 5:38pm UTC](https://discourse.julialang.org/t/is-there-any-library-similar-to-typescript-for-julia/80160 "2022-04-27T17:38:58Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![anon29721930](https://avatars.discourse-cdn.com/v4/letter/a/58956e/32.png) [@anon29721930](https://discourse.julialang.org/u/anon29721930)
#### Post date: [April 27, 2022, 5:38pm UTC](https://discourse.julialang.org/t/is-there-any-library-similar-to-typescript-for-julia/80160/1 "2022-04-27T17:38:58Z")

</div>

Is there any library similar to Typescript for Julia?

#### example.ts

```julia-auto
let a: number = 1 ;
console.log(a) // output: 1

```

#### example.jl

```julia-auto
# Assign the value 10 to the variable x
julia> x = 10
10

```

#### example.jl

```julia-auto
# Assign the value 10 to the variable x
julia> x:number = 10
10

```

#### reference

- [https://www.typescriptlang.org/](https://www.typescriptlang.org/)
- [TS Playground - An online editor for exploring TypeScript and JavaScript](https://www.typescriptlang.org/play)

---

<div class="post-metadata">

### Author: ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)
#### Post date: [April 27, 2022, 6:10pm UTC](https://discourse.julialang.org/t/is-there-any-library-similar-to-typescript-for-julia/80160/2 "2022-04-27T18:10:38Z")

</div>

> [@anon29721930](#):
>
> Is there any library similar to Typescript for Julia?

Julia has a type system built-in, so there is no need to build a library on top for type support.

For example, the TypeScript website shows

```ts
interface Account {
  id: number
  displayName: string
  version: 1
}
 
function welcome(user: Account) {
  console.log(user.id)
}

```

In Julia, you can write this as

```julia
julia> Base.@kwdef struct Account
           id::Number
           name::String
           version::Int = 1
       end;

julia> function welcome(user::Account)
           println("Welcome $(user.name)!")
       end;

julia> user = Account(; id=1, name="Sally")
Account(1, "Sally", 1)

julia> welcome(user)
Welcome Sally!

```

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [April 27, 2022, 6:47pm UTC](https://discourse.julialang.org/t/is-there-any-library-similar-to-typescript-for-julia/80160/3 "2022-04-27T18:47:10Z")

</div>

Julia supports annotating the type of local variables and [intends to support the same for global variables](https://github.com/JuliaLang/julia/issues/964) types:

```julia
julia> let
       x::Int = 1
       end
1

julia> y::Int = 1
ERROR: syntax: type declarations on global variables are not yet supported
Stacktrace:
 [1] top-level scope at REPL[2]:1

```

In fact, I am using Julia 1.5.3, maybe the most recent Julia versions already support annotating the type of global variables.

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [April 27, 2022, 8:26pm UTC](https://discourse.julialang.org/t/is-there-any-library-similar-to-typescript-for-julia/80160/4 "2022-04-27T20:26:56Z")

</div>

> [@Henrique\_Becker](#):
>
> In fact, I am using Julia 1.5.3, maybe the most recent Julia versions already support annotating the type of global variables.

v1.8 does

---

<div class="post-metadata">

### Author: ![anon29721930](https://avatars.discourse-cdn.com/v4/letter/a/58956e/32.png) [@anon29721930](https://discourse.julialang.org/u/anon29721930)
#### Post date: [July 2, 2022, 2:58am UTC](https://discourse.julialang.org/t/is-there-any-library-similar-to-typescript-for-julia/80160/5 "2022-07-02T02:58:15Z")

</div>

please, close topic here.
