We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
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)
https://typespec.io/playground/?c=YWxpYXMgVGFrZXNWYWx1ZTxTdHJpbmfFDCBleHRlbmRzIHbEDm9mIHPFHD4gPSB7DQogICAgQGRvYyjLMinGF3Byb3BlcnR5OiB0eXDEOcxVPcwOOw0KfTsNCg0KY29uc3TEYTogImEiIHwgImIiID3EDDsNCuYApU0xID3sAKpzdHI%2BOw%3D%3D&e=%40typespec%2Fopenapi3&options=%7B%7D
The text was updated successfully, but these errors were encountered:
No branches or pull requests
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:
However, this isn't allowed, and we get the error:
Reproduction
https://typespec.io/playground/?c=YWxpYXMgVGFrZXNWYWx1ZTxTdHJpbmfFDCBleHRlbmRzIHbEDm9mIHPFHD4gPSB7DQogICAgQGRvYyjLMinGF3Byb3BlcnR5OiB0eXDEOcxVPcwOOw0KfTsNCg0KY29uc3TEYTogImEiIHwgImIiID3EDDsNCuYApU0xID3sAKpzdHI%2BOw%3D%3D&e=%40typespec%2Fopenapi3&options=%7B%7D
Checklist
The text was updated successfully, but these errors were encountered: