Skip to content

Commit

Permalink
5.1.6 version added, and now it's default version
Browse files Browse the repository at this point in the history
  • Loading branch information
harbard-bare committed Jul 31, 2023
1 parent 4c23567 commit b988de0
Show file tree
Hide file tree
Showing 7 changed files with 20,515 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@

# Dependency directories (remove the comment below to include it)
# vendor/
.DS_Store
5 changes: 3 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package typescript
import (
"encoding/base64"
"fmt"

"github.com/clarkmcc/go-typescript/utils"
"github.com/clarkmcc/go-typescript/versions"
_ "github.com/clarkmcc/go-typescript/versions/v4.9.3"
_ "github.com/clarkmcc/go-typescript/versions/v5.1.6"
"github.com/dop251/goja"
)

Expand Down Expand Up @@ -60,7 +61,7 @@ func NewDefaultConfig() *Config {
return &Config{
Runtime: goja.New(),
CompileOptions: nil,
TypescriptSource: versions.DefaultRegistry.MustGet("v4.9.3"),
TypescriptSource: versions.DefaultRegistry.MustGet("v5.1.6"),
ModuleName: "default",
}
}
Expand Down
7 changes: 4 additions & 3 deletions evaluate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"context"
"errors"
"fmt"
"github.com/dop251/goja"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"io"
"strings"
"testing"

"github.com/dop251/goja"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

var (
Expand Down
7 changes: 4 additions & 3 deletions versions/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package versions

import (
"fmt"
"github.com/dop251/goja"
"sync"

"github.com/dop251/goja"
)

// DefaultRegistry is the default instance of the typescript tagged version registry.
Expand Down Expand Up @@ -56,7 +57,7 @@ func (r *Registry) MustGet(tag string) *goja.Program {

// 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 {
for k := range r.versions {
out = append(out, k)
}
return
Expand All @@ -66,7 +67,7 @@ func (r *Registry) RegisteredVersions() (out []string) {
// 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.
func (r *Registry) supportedVersionsLocked() (out []string) {
for k, _ := range r.versions {
for k := range r.versions {
out = append(out, k)
}
return
Expand Down
9 changes: 8 additions & 1 deletion versions/registry_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
package versions

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)

func TestRegistry_Get(t *testing.T) {
// 5.x test
t.Run("KnownTag", func(t *testing.T) {
DefaultRegistry.MustRegister("v5.1.6", "")
_, err := DefaultRegistry.Get("v5.1.6")
require.NoError(t, err)
})
t.Run("KnownTag", func(t *testing.T) {
DefaultRegistry.MustRegister("v4.2.3", "")
_, err := DefaultRegistry.Get("v4.2.3")
Expand Down
14 changes: 14 additions & 0 deletions versions/v5.1.6/loader.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package v5_1_6

import (
_ "embed"

"github.com/clarkmcc/go-typescript/versions"
)

//go:embed v5.1.6.js
var Source string

func init() {
versions.DefaultRegistry.MustRegister("v5.1.6", Source)
}
Loading

0 comments on commit b988de0

Please sign in to comment.