File tree Expand file tree Collapse file tree 4 files changed +26
-2
lines changed Expand file tree Collapse file tree 4 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 11export { $int64AsString } from "./int64AsString.js" ;
2+ export { $uint64AsString } from "./uint64AsString.js" ;
Original file line number Diff line number Diff line change 11import "./int64AsString.js" ;
2+ import "./uint64AsString.js" ;
23
34using TypeSpec .Reflection ;
45
@@ -7,3 +8,9 @@ using TypeSpec.Reflection;
78 * This decorator is equivalent to `@ encode ("int64", string)`.
89 */
910extern dec int64AsString (target : ModelProperty );
11+
12+ /**
13+ * Emit string type from uint64.
14+ * This decorator is equivalent to `@ encode ("uint64", string)`.
15+ */
16+ extern dec uint64AsString (target : ModelProperty );
Original file line number Diff line number Diff line change 1616 ],
1717 "type" : " module" ,
1818 "main" : " index.js" ,
19- "tspMain" : " int64AsString .tsp" ,
19+ "tspMain" : " index .tsp" ,
2020 "files" : [
2121 " index.js" ,
22+ " index.tsp" ,
2223 " int64AsString.js" ,
23- " int64AsString.tsp "
24+ " uint64AsString.js "
2425 ],
2526 "peerDependencies" : {
2627 "@typespec/compiler" : " ^0.67.1"
Original file line number Diff line number Diff line change 1+ import { $encode } from "@typespec/compiler" ;
2+
3+ /**
4+ * @param context {import("@typespec/compiler").DecoratorContext }
5+ * @param target {import("@typespec/compiler").ModelProperty }
6+ */
7+ export function $uint64AsString ( context , target ) {
8+ if ( "name" in target . type && target . type . name === "uint64" ) {
9+ $encode ( context , target , "uint64" ) ;
10+ } else {
11+ throw new Error (
12+ "@uint64AsString decorator can only be used for uint64 properties." ,
13+ ) ;
14+ }
15+ }
You can’t perform that action at this time.
0 commit comments