Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hi! Update please for fresh TS version, in order not to create unnecessary forks #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
![](assets/banner.png)

# Fork with fresh TypeScript (5.1.6) version inside

Original readme

nzhenev marked this conversation as resolved.
Show resolved Hide resolved
This package provides a thin wrapper around [goja](https://github.com/dop251/goja) (a native Javascript runtime for Go). There are no direct dependencies besides goja, and [testify](https://github.com/stretchr/testify) (for testing only). This package supports the following features:
* Typescript compilation and evaluation.
* A context-aware evaluation API to support cancellation.
Expand All @@ -15,4 +19,4 @@ This package provides a thin wrapper around [goja](https://github.com/dop251/goj
* [Transpile Typescript](examples/typescript_test.go)
* [Transpile and Evaluate Typescript](examples/typescript_evaluate_test.go)
* [AMD Modules](examples/typescript_amd_modules_test.go)
* [Context Cancellation](examples/typescript_context_test.go)
* [Context Cancellation](examples/typescript_context_test.go)
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
Loading