Skip to content

Commit 2748646

Browse files
committed
Updated latest typescript version to 4.7.2
1 parent 53783c0 commit 2748646

File tree

7 files changed

+35
-3
lines changed

7 files changed

+35
-3
lines changed

config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"fmt"
66
"github.com/clarkmcc/go-typescript/utils"
77
"github.com/clarkmcc/go-typescript/versions"
8-
_ "github.com/clarkmcc/go-typescript/versions/v4.2.4"
8+
_ "github.com/clarkmcc/go-typescript/versions/v4.7.2"
99
"github.com/dop251/goja"
1010
)
1111

@@ -60,7 +60,7 @@ func NewDefaultConfig() *Config {
6060
return &Config{
6161
Runtime: goja.New(),
6262
CompileOptions: nil,
63-
TypescriptSource: versions.DefaultRegistry.MustGet("v4.2.4"),
63+
TypescriptSource: versions.DefaultRegistry.MustGet("v4.7.2"),
6464
ModuleName: "default",
6565
}
6666
}

config_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
_ "github.com/clarkmcc/go-typescript/versions/v4.1.5"
1212
_ "github.com/clarkmcc/go-typescript/versions/v4.2.2"
1313
v423 "github.com/clarkmcc/go-typescript/versions/v4.2.3"
14+
_ "github.com/clarkmcc/go-typescript/versions/v4.2.4"
15+
_ "github.com/clarkmcc/go-typescript/versions/v4.7.2"
1416
"github.com/stretchr/testify/require"
1517
"testing"
1618
)
@@ -69,6 +71,11 @@ func TestVersionLoading(t *testing.T) {
6971
require.NoError(t, err)
7072
require.Equal(t, "var a = 10;", output)
7173
})
74+
t.Run("v4.7.2", func(t *testing.T) {
75+
output, err := TranspileString("let a: number = 10;", WithVersion("v4.7.2"))
76+
require.NoError(t, err)
77+
require.Equal(t, "var a = 10;", output)
78+
})
7279
}
7380

7481
func TestCustomRegistry(t *testing.T) {

evaluate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"fmt"
66
"github.com/clarkmcc/go-typescript/packages"
7-
_ "github.com/clarkmcc/go-typescript/versions/v4.2.3"
7+
_ "github.com/clarkmcc/go-typescript/versions/v4.7.2"
88
"github.com/dop251/goja"
99
"io"
1010
"io/ioutil"

versions/registry.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ func (r *Registry) MustGet(tag string) *goja.Program {
5454
return source
5555
}
5656

57+
// RegisteredVersions returns an unordered list of the versions that are registered in this registry
58+
func (r *Registry) RegisteredVersions() (out []string) {
59+
for k, _ := range r.versions {
60+
out = append(out, k)
61+
}
62+
return
63+
}
64+
5765
// supportedVersionsLocked returns a slice of supported version tags that are registered
5866
// to this registry and can be accessed by calling Get. This function should only be called
5967
// by a caller who has already acquired a lock on the registry.

versions/registry_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ func TestRegistry_Register(t *testing.T) {
2727
err := r.Register("a", "type a struct{}")
2828
require.Error(t, err)
2929
})
30+
t.Run("RegisteredVersions", func(t *testing.T) {
31+
require.Len(t, r.RegisteredVersions(), 1)
32+
})
3033
}
3134

3235
func TestRegistry_MustGet(t *testing.T) {

versions/v4.7.2/loader.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package v4_7_2
2+
3+
import (
4+
_ "embed"
5+
"github.com/clarkmcc/go-typescript/versions"
6+
)
7+
8+
//go:embed v4.7.2.js
9+
var Source string
10+
11+
func init() {
12+
versions.DefaultRegistry.MustRegister("v4.7.2", Source)
13+
}

versions/v4.7.2/v4.7.2.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)