Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not create properties with empty name #20

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = "" | "=" | "<" | ">" | "<=" | ">=";