glideapps / glideapps/quicktype
custom acronym names are not recognized as acronym
- Dominant language
- TypeScript
- Stars
- 13.9k
- Forks
- 1.2k
- Avg merge
- 8h 53m
- Merged PRs (30d)
- 369
Description
I'm using golang generator to generate type names with some custom enum values, such as
```json
"enum": [
"HLS",
"DASH",
"MSS"
]
```
These are not in the built-in acronym list, but they are all upper cases, so they should be considered as acronyms, but the generated golang code has:
```go
type Format string
const (
Dash Format = "DASH"
HLS Format = "HLS"
Mss Format = "MSS"
)
```
It should be:
```go
type Format string
const (
DASH Format = "DASH"
HLS Format = "HLS"
MSS Format = "MSS"
)
```
Then I checked the quicktype implementation and found this is how it detects acronyms:
https://github.com/quicktype/quicktype/blob/df66617104acd2f6b1022719463382a9b5b6cbe0/src/quicktype-core/support/Strings.ts#L438
When the whole string is like `DASH`, `lastLowerCaseIndex` is `undefined` and `allUpper` is `true`, hence `isAcronym` is `false`. Why is `lastLowerCaseIndex !== undefined` needed?
Contributor guide
Assessment
This issue has not been assessed yet.