Skip to content

Commit

Permalink
Do not create properties with empty name
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampire committed Sep 22, 2024
1 parent 9bc7000 commit 7ac1ee5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/converter/plugins/StringUnionTypePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ export function convertStringUnionType(
checkCoverageService?.cover(literal)

const value = literal.text
const key = value === ""
const valueAsIdentifier = identifier(value)
const key = (value === "") || (valueAsIdentifier === "")
? "`_`"
: identifier(value)
: valueAsIdentifier
return [key, value] as const
})

Expand Down
15 changes: 15 additions & 0 deletions test/functional/base/generated/union/stringEnum.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ val multipartFormData: FormEncType
}

external fun switcher(): SwitcherResult

sealed external interface Operator {
companion object {
@seskar.js.JsValue("")
val `_`: Operator
/*
Duplicated names were generated:
`_` for "="
`_` for "<"
`_` for ">"
`_` for "<="
`_` for ">="
*/
}
}
sealed external interface SwitcherResult {
companion object {
@seskar.js.JsValue("on")
Expand Down
2 changes: 2 additions & 0 deletions test/functional/base/lib/union/stringEnum.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export declare type FormEncType = "application/x-www-form-urlencoded" | "multipart/form-data";

export declare function switcher(): "on" | "off"

export declare type Operator = "" | "=" | "<" | ">" | "<=" | ">=";

0 comments on commit 7ac1ee5

Please sign in to comment.