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

fix: parse property types containing hyphens #125

Closed

Conversation

samuelmaddock
Copy link
Member

I was testing out adding a struct property which is a string literal. When the string literal contains a hyphen, it breaks parsing.

* `prop` 'string-enum' - description

would split the type into 'string with a description of enum' - description

@samuelmaddock samuelmaddock requested a review from a team as a code owner October 4, 2024 20:36
Copy link
Member

@MarshallOfSound MarshallOfSound left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't the correct way to declare a string enum and so shouldn't be supported.

You should declare this as a string that "Can be 'foo'" with only one value

@samuelmaddock
Copy link
Member Author

We have a couple places in the codebase where we type string literals

$ rg '\* `.*?` '\''' ./docs
./docs/api/structures/upload-raw-data.md
3:* `type` 'rawData' - `rawData`.

./docs/api/structures/upload-file.md
3:* `type` 'file' - `file`.

The * prop String - Can be 'foo' syntax just felt a bit awkward to write. If we feel strongly about it, I can use that though.

@MarshallOfSound
Copy link
Member

The problem is as it stands this makes things way stricter and probably breaks something where someone forgot a space, but also this will allow people to generate invalid typescript types. E.g. Foo-Bar will be accepted but is not a valid type name

@samuelmaddock
Copy link
Member Author

Works for me. Closing in favor of the "Can be" syntax for string enums.

@samuelmaddock samuelmaddock deleted the fix/parse-type-hyphens branch October 4, 2024 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants