Skip to content

Commit

Permalink
Updated latest typescript version to 4.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkmcc committed May 26, 2022
1 parent 53783c0 commit 2748646
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 3 deletions.
4 changes: 2 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"github.com/clarkmcc/go-typescript/utils"
"github.com/clarkmcc/go-typescript/versions"
_ "github.com/clarkmcc/go-typescript/versions/v4.2.4"
_ "github.com/clarkmcc/go-typescript/versions/v4.7.2"
"github.com/dop251/goja"
)

Expand Down Expand Up @@ -60,7 +60,7 @@ func NewDefaultConfig() *Config {
return &Config{
Runtime: goja.New(),
CompileOptions: nil,
TypescriptSource: versions.DefaultRegistry.MustGet("v4.2.4"),
TypescriptSource: versions.DefaultRegistry.MustGet("v4.7.2"),
ModuleName: "default",
}
}
Expand Down
7 changes: 7 additions & 0 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
_ "github.com/clarkmcc/go-typescript/versions/v4.1.5"
_ "github.com/clarkmcc/go-typescript/versions/v4.2.2"
v423 "github.com/clarkmcc/go-typescript/versions/v4.2.3"
_ "github.com/clarkmcc/go-typescript/versions/v4.2.4"
_ "github.com/clarkmcc/go-typescript/versions/v4.7.2"
"github.com/stretchr/testify/require"
"testing"
)
Expand Down Expand Up @@ -69,6 +71,11 @@ func TestVersionLoading(t *testing.T) {
require.NoError(t, err)
require.Equal(t, "var a = 10;", output)
})
t.Run("v4.7.2", func(t *testing.T) {
output, err := TranspileString("let a: number = 10;", WithVersion("v4.7.2"))
require.NoError(t, err)
require.Equal(t, "var a = 10;", output)
})
}

func TestCustomRegistry(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion evaluate.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"
"github.com/clarkmcc/go-typescript/packages"
_ "github.com/clarkmcc/go-typescript/versions/v4.2.3"
_ "github.com/clarkmcc/go-typescript/versions/v4.7.2"
"github.com/dop251/goja"
"io"
"io/ioutil"
Expand Down
8 changes: 8 additions & 0 deletions versions/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ func (r *Registry) MustGet(tag string) *goja.Program {
return source
}

// RegisteredVersions returns an unordered list of the versions that are registered in this registry
func (r *Registry) RegisteredVersions() (out []string) {
for k, _ := range r.versions {
out = append(out, k)
}
return
}

// supportedVersionsLocked returns a slice of supported version tags that are registered
// to this registry and can be accessed by calling Get. This function should only be called
// by a caller who has already acquired a lock on the registry.
Expand Down
3 changes: 3 additions & 0 deletions versions/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ func TestRegistry_Register(t *testing.T) {
err := r.Register("a", "type a struct{}")
require.Error(t, err)
})
t.Run("RegisteredVersions", func(t *testing.T) {
require.Len(t, r.RegisteredVersions(), 1)
})
}

func TestRegistry_MustGet(t *testing.T) {
Expand Down
13 changes: 13 additions & 0 deletions versions/v4.7.2/loader.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package v4_7_2

import (
_ "embed"
"github.com/clarkmcc/go-typescript/versions"
)

//go:embed v4.7.2.js
var Source string

func init() {
versions.DefaultRegistry.MustRegister("v4.7.2", Source)
}
1 change: 1 addition & 0 deletions versions/v4.7.2/v4.7.2.js

Large diffs are not rendered by default.

0 comments on commit 2748646

Please sign in to comment.