Closed
Description
Describe the bug
Possibly a duplicate of #959 but that issue is very old.
Extending the example in https://typespec.io/docs/language-basics/templates/#template-parameter-value-types, it seems like you should be able to define a default value with a template parameter value:
alias TakesValue<StringValue extends valueof string> = {
@doc(StringValue)
property: typeof StringValue = StringValue;
};
const str: "a" | "b" = "a";
alias M1 = TakesValue<str>;
However, this isn't allowed, and we get the error:
StringValue refers to a type, but is being used as a value here. TypeSpec(expect-value)
Reproduction
Checklist
- Follow our Code of Conduct
- Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- The provided reproduction is a minimal reproducible example of the bug.