5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 06:20:48 +08:00

fix optional field syntax and ioutil replace with os' (#3476)

changelog
This commit is contained in:
Atterpac 2024-05-13 14:40:31 -06:00 committed by GitHub
parent 0f66a98449
commit 035ede4701
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 5 deletions

View File

@ -3,7 +3,7 @@ package typescriptify
import ( import (
"bufio" "bufio"
"fmt" "fmt"
"io/ioutil" "io"
"log" "log"
"os" "os"
"path" "path"
@ -394,7 +394,7 @@ func loadCustomCode(fileName string) (map[string]string, error) {
} }
defer f.Close() defer f.Close()
bytes, err := ioutil.ReadAll(f) bytes, err := io.ReadAll(f)
if err != nil { if err != nil {
return result, err return result, err
} }
@ -430,7 +430,7 @@ func (t TypeScriptify) backup(fileName string) error {
} }
defer fileIn.Close() defer fileIn.Close()
bytes, err := ioutil.ReadAll(fileIn) bytes, err := io.ReadAll(fileIn)
if err != nil { if err != nil {
return err return err
} }
@ -440,7 +440,7 @@ func (t TypeScriptify) backup(fileName string) error {
backupFn = path.Join(t.BackupDir, backupFn) 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 { 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, "?") isOptional := strings.HasSuffix(fld, "?")
strippedFieldName := strings.ReplaceAll(fld, "?", "") strippedFieldName := strings.ReplaceAll(fld, "?", "")
if !regexp.MustCompile(jsVariableNameRegex).Match([]byte(strippedFieldName)) { if !regexp.MustCompile(jsVariableNameRegex).Match([]byte(strippedFieldName)) {
fld = fmt.Sprintf(`"%s"`, fld) fld = fmt.Sprintf(`"%s"`, strippedFieldName)
if isOptional { if isOptional {
fld += "?" fld += "?"
} }

View File

@ -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) - 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). - 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 ## v2.8.2 - 2024-05-08
### Breaking Change ### Breaking Change