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

[Bug]: support mix types for enum types in tcgc #864

Open
4 tasks done
ArcturusZhang opened this issue May 20, 2024 · 4 comments · May be fixed by #888
Open
4 tasks done

[Bug]: support mix types for enum types in tcgc #864

ArcturusZhang opened this issue May 20, 2024 · 4 comments · May be fixed by #888
Assignees
Labels
bug Something isn't working lib:azure-core Issues for @azure-tools/typespec-azure-core library

Comments

@ArcturusZhang
Copy link
Member

ArcturusZhang commented May 20, 2024

Describe the bug

I have this enum:

enum Fixed {
	One: 1,
	Two: "2"
}

which is totally fine in typespec, but TCGC gives me string as its valueType, which is just incorrect.

Suggestion

I think it is reasonable that we return a union as its value type which is more intuitive.

Checklist

  • Follow our Code of Conduct
  • Check that this issue is about the Azure libraries for typespec. For bug in the typespec language or core libraries file it in the TypeSpec repo
  • Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.
@ArcturusZhang ArcturusZhang added the bug Something isn't working label May 20, 2024
@tadelesh
Copy link
Member

emm, i doubt if it should be fixed in tcgc enum type or add a lint rule to avoid it.

@tadelesh
Copy link
Member

@timotheeguerin is it a valid case for typespec?

@timotheeguerin
Copy link
Member

it is today a valid use case, we don't have a way to limit enums types. But either way I would agree that we probably would want a linting rule against that for azure.

@tadelesh tadelesh linked a pull request May 21, 2024 that will close this issue
@markcowl markcowl added the lib:tcgc Issues for @azure-tools/typespec-client-generator-core library label May 29, 2024
@tadelesh tadelesh self-assigned this Jun 11, 2024
@iscai-msft iscai-msft added lib:azure-core Issues for @azure-tools/typespec-azure-core library and removed lib:tcgc Issues for @azure-tools/typespec-client-generator-core library labels Jun 24, 2024
@iscai-msft iscai-msft changed the title [Bug]: TCGC returns wrong value type in mixed-type fixed enum [Bug]: add linter in azure-core to prevent mixed type enums Jun 24, 2024
@tadelesh tadelesh changed the title [Bug]: add linter in azure-core to prevent mixed type enums [Bug]: support mix types for enum types in tcgc Aug 27, 2024
@tadelesh
Copy link
Member

since we have lint in core that disallow azure service to have enums: https://github.com/Azure/typespec-azure/blob/main/packages/typespec-azure-core/src/rules/no-enum.ts, so i believe it is an only ask for unbranded. i finished the support pr, we could decide whether we need to have this breaking change in the sync up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lib:azure-core Issues for @azure-tools/typespec-azure-core library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants