Replies: 1 comment 2 replies
-
Yeah you cannot decorate I think the enum case however should maybe work, could be worth fillying an issue for it. It however works with a union like that union Constants {
MY_CONSTANT: 10,
}
model Test {
b: safeint = Constants.MY_CONSTANT;
}
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to make a TypeSpec emitter that emits constant values that come from TypeSpec definitions.
Naively, I expected
const
s to work for this purpose, but they seem very similar toalias
es in that I can't seem to access them in an emitter.For example, the
defaultValue
offield
here is numeric value 10:Trying to decorate a
const
produces the TypeSpec error: "Cannot decorate const statement.TypeSpec(invalid-decorator-location)".I also tried to use
enum
s for the same goal, butenum
values can't be used in numeric contexts:Is there another way to do this?
Beta Was this translation helpful? Give feedback.
All reactions