mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-24 07:18:54 +00:00
resources/jsconfig: Remove deprecated baseUrl setting
baseUrl is deprecated in TypeScript and is no longer required when paths is set (TypeScript 4.1+). Fixes #14991 Closes #14996
This commit is contained in:
@@ -61,8 +61,7 @@ func (b *Builder) AddSourceRoot(root string) {
|
||||
|
||||
// CompilerOptions holds compilerOptions for jsonconfig.json.
|
||||
type CompilerOptions struct {
|
||||
BaseURL string `json:"baseUrl"`
|
||||
Paths map[string][]string `json:"paths"`
|
||||
Paths map[string][]string `json:"paths"`
|
||||
}
|
||||
|
||||
// Config holds the data for jsconfig.json.
|
||||
@@ -73,8 +72,7 @@ type Config struct {
|
||||
func newJSConfig() *Config {
|
||||
return &Config{
|
||||
CompilerOptions: CompilerOptions{
|
||||
BaseURL: ".",
|
||||
Paths: make(map[string][]string),
|
||||
Paths: make(map[string][]string),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
package jsconfig
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
@@ -28,8 +29,12 @@ func TestJsConfigBuilder(t *testing.T) {
|
||||
b.AddSourceRoot("/d/assets")
|
||||
|
||||
conf := b.Build("/a/b")
|
||||
c.Assert(conf.CompilerOptions.BaseURL, qt.Equals, ".")
|
||||
c.Assert(conf.CompilerOptions.Paths["*"], qt.DeepEquals, []string{filepath.FromSlash("../../c/assets/*"), filepath.FromSlash("../../d/assets/*")})
|
||||
|
||||
// baseUrl is deprecated in TypeScript and not needed when paths is set; see issue 14991.
|
||||
data, err := json.Marshal(conf)
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(string(data), qt.Not(qt.Contains), "baseUrl")
|
||||
|
||||
c.Assert(NewBuilder().Build("/a/b"), qt.IsNil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user