Skip to content

Commit

Permalink
Fixes #803 (#805)
Browse files Browse the repository at this point in the history
* Fixes #803

Allow JS file validation to parse TS.

* fix import order.
  • Loading branch information
limbic-derek authored Mar 1, 2024
1 parent b639c70 commit 619c06f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"time"

"github.com/Masterminds/semver/v3"
"github.com/ije/esbuild-internal/config"
"github.com/ije/esbuild-internal/js_ast"
"github.com/ije/esbuild-internal/js_parser"
"github.com/ije/esbuild-internal/logger"
Expand Down Expand Up @@ -202,13 +203,18 @@ func validateJS(filename string) (isESM bool, namedExports []string, err error)
return
}
log := logger.NewDeferLog(logger.DeferLogNoVerboseOrDebug, nil)
parserOpts := js_parser.OptionsFromConfig(&config.Options{
TS: config.TSOptions {
Parse: true,
},
})
ast, pass := js_parser.Parse(log, logger.Source{
Index: 0,
KeyPath: logger.Path{Text: "<stdin>"},
PrettyPath: "<stdin>",
Contents: string(data),
IdentifierName: "stdin",
}, js_parser.Options{})
}, parserOpts)
if !pass {
err = errors.New("invalid syntax, require javascript/typescript")
return
Expand Down

0 comments on commit 619c06f

Please sign in to comment.