mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 08:29:40 +08:00
fix optional field syntax and ioutil replace with os' (#3476)
changelog
This commit is contained in:
parent
0f66a98449
commit
035ede4701
@ -3,7 +3,7 @@ package typescriptify
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
@ -394,7 +394,7 @@ func loadCustomCode(fileName string) (map[string]string, error) {
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
bytes, err := ioutil.ReadAll(f)
|
||||
bytes, err := io.ReadAll(f)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
@ -430,7 +430,7 @@ func (t TypeScriptify) backup(fileName string) error {
|
||||
}
|
||||
defer fileIn.Close()
|
||||
|
||||
bytes, err := ioutil.ReadAll(fileIn)
|
||||
bytes, err := io.ReadAll(fileIn)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -440,7 +440,7 @@ func (t TypeScriptify) backup(fileName string) error {
|
||||
backupFn = path.Join(t.BackupDir, backupFn)
|
||||
}
|
||||
|
||||
return ioutil.WriteFile(backupFn, bytes, os.FileMode(0o700))
|
||||
return os.WriteFile(backupFn, bytes, os.FileMode(0o700))
|
||||
}
|
||||
|
||||
func (t TypeScriptify) ConvertToFile(fileName string, packageName string) error {
|
||||
@ -894,7 +894,7 @@ func (t *typeScriptClassBuilder) addField(fld, fldType string, isAnyType bool) {
|
||||
isOptional := strings.HasSuffix(fld, "?")
|
||||
strippedFieldName := strings.ReplaceAll(fld, "?", "")
|
||||
if !regexp.MustCompile(jsVariableNameRegex).Match([]byte(strippedFieldName)) {
|
||||
fld = fmt.Sprintf(`"%s"`, fld)
|
||||
fld = fmt.Sprintf(`"%s"`, strippedFieldName)
|
||||
if isOptional {
|
||||
fld += "?"
|
||||
}
|
||||
|
@ -21,6 +21,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Updated several broken links in the "How Does It Work?" page on the website. Changed by [@oguz-yilmaz](https://github.com/oguz-yilmaz) in [PR #3469](https://github.com/wailsapp/wails/pull/3469)
|
||||
- Upgraded Go version in CI to 1.22 by [@leaanthony](https://github.com/leaanthony) in [#3473](https://github.com/wailsapp/wails/pull/3473).
|
||||
|
||||
### Fixed
|
||||
- Fixed optional type generation where an extra `?` would be placed inside the field name instead of outside the name `"field?"?` vs `"field"?`. Fixed by [@atterpac](https://github.com/atterpac) in [#3476](https://github.com/wailsapp/wails/pull/3476)
|
||||
|
||||
## v2.8.2 - 2024-05-08
|
||||
|
||||
### Breaking Change
|
||||
|
Loading…
Reference in New Issue
Block a user