You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Invalid TS code is generated from this model. Looks like the logic to generate unions doesn't take into account scalars or enums.
namespace [email protected]
concept Address {
o String street
o String city
o String zip
}
concept Order {
o String sku
o Integer amount
}
concept LoyaltyStatus {
o String level
}
enum Color {
o RED
o GREEN
o BLUE
o PINK
o BLACK
o WHITE
}
concept Preferences {
o Color[] favoriteColors optional
}
@template
concept TemplateData {
o String firstName
o String lastName
o String[] middleNames
o Boolean active
o DateTime lastVisit
o Address address
o Order[] orders
o LoyaltyStatus loyaltyStatus optional
o Preferences preferences
}
Expected Behavior
Generates code that compiles.
Current Behavior
Code doesn't compile because a union is created containing IColor, even though Color is an enum.
Possible Solution
Steps to Reproduce
Context (Environment)
Desktop
OS: [e.g. macOS]
Browser: [e.g. Chrome, Safari]
Version: [e.g. 0.22.15]
Detailed Description
Possible Implementation
The text was updated successfully, but these errors were encountered:
Hi @dselman
I've done some basic investigation and found out that, enum is a subclass under the class declaration Concept. Which shouldn't be the case right?
In the case of scalar, it is treated as a field, but there is no check in place to generate a specific code for it.
What would be the expected output for the input above?
Hi @dselman
I Would like to tackle this issue :The generated TypeScript code incorrectly treats the Color enum as a concept, leading to the inclusion of IColor in unions. Since Color is defined as an enum in the model, it should not be mapped to an interface (IColor) but rather as a TypeScript enum or a string literal union.
This is solved by using String Literal union.
will you please let me know, any other changes are required. And where i can start to solve this issue.
Bug Report 🐛
Invalid TS code is generated from this model. Looks like the logic to generate unions doesn't take into account scalars or enums.
Expected Behavior
Generates code that compiles.
Current Behavior
Code doesn't compile because a union is created containing
IColor
, even though Color is an enum.Possible Solution
Steps to Reproduce
Context (Environment)
Desktop
Detailed Description
Possible Implementation
The text was updated successfully, but these errors were encountered: