Skip to content

Commit 0344c84

Browse files
committed
String enums containing a - should be escaped with backtick
Fix #44
1 parent 32b8347 commit 0344c84

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
* Transform `Promise` to `JS.Promise` (by @nojaf) ([GH-33](https://github.com/glutinum-org/cli/pull/33))
1313
* Optional argument of F# Method are prefixed with `?` instead of suffixing them with `option`
1414
* Sanitize names coming from TypeScript by removing surrounding quotes (`"`, `'`)
15+
* String enums containing a `-` should be escaped with backtick ([GH-44](https://github.com/glutinum-org/cli/issues/44))
1516

1617
### Added
1718

18-
* Add support for `MethodSignature` on interface ([GH-28](https://github.com/glutinum-org/cli/issues/28]))
19+
* Add support for `MethodSignature` on interface ([GH-28](https://github.com/glutinum-org/cli/issues/28))
1920
* Ignore `ExportAssignment` as we don't know what to do with it yet
2021
* Add support for literal type alias ([GH-45](https://github.com/glutinum-org/cli/issues/45))
2122

src/Glutinum.Converter/Utils/Naming.fs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ let nameNotEqualsDefaultFableValue (name: string) (value: string) : bool =
2020
not (nameEqualsDefaultFableValue name value)
2121

2222
let escapeName (name: string) : string =
23-
if Keywords.fsharp.Contains name then
23+
if Keywords.fsharp.Contains name || name.Contains("-") then
2424
$"``%s{name}``"
2525
else
2626
name
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export type GPUTextureViewDimension =
2+
| "cube-array"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module rec Glutinum
2+
3+
open Fable.Core
4+
open System
5+
6+
[<RequireQualifiedAccess>]
7+
[<StringEnum(CaseRules.None)>]
8+
type GPUTextureViewDimension =
9+
| ``cube-array``
10+
11+
(***)
12+
#r "nuget: Fable.Core"
13+
(***)

0 commit comments

Comments
 (0)