@typespec/compiler 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (352) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +9 -0
  3. package/cmd/tsp-server.js +3 -0
  4. package/cmd/tsp.js +3 -0
  5. package/dist/cmd/runner.d.ts +9 -0
  6. package/dist/cmd/runner.d.ts.map +1 -0
  7. package/dist/cmd/runner.js +62 -0
  8. package/dist/cmd/runner.js.map +1 -0
  9. package/dist/config/config-interpolation.d.ts +11 -0
  10. package/dist/config/config-interpolation.d.ts.map +1 -0
  11. package/dist/config/config-interpolation.js +109 -0
  12. package/dist/config/config-interpolation.js.map +1 -0
  13. package/dist/config/config-loader.d.ts +25 -0
  14. package/dist/config/config-loader.d.ts.map +1 -0
  15. package/dist/config/config-loader.js +182 -0
  16. package/dist/config/config-loader.js.map +1 -0
  17. package/dist/config/config-schema.d.ts +4 -0
  18. package/dist/config/config-schema.d.ts.map +1 -0
  19. package/dist/config/config-schema.js +84 -0
  20. package/dist/config/config-schema.js.map +1 -0
  21. package/dist/config/index.d.ts +3 -0
  22. package/dist/config/index.d.ts.map +1 -0
  23. package/dist/config/index.js +3 -0
  24. package/dist/config/index.js.map +1 -0
  25. package/dist/config/types.d.ts +79 -0
  26. package/dist/config/types.d.ts.map +1 -0
  27. package/dist/config/types.js +2 -0
  28. package/dist/config/types.js.map +1 -0
  29. package/dist/core/binder.d.ts +29 -0
  30. package/dist/core/binder.d.ts.map +1 -0
  31. package/dist/core/binder.js +455 -0
  32. package/dist/core/binder.js.map +1 -0
  33. package/dist/core/charcode.d.ts +130 -0
  34. package/dist/core/charcode.d.ts.map +1 -0
  35. package/dist/core/charcode.js +115 -0
  36. package/dist/core/charcode.js.map +1 -0
  37. package/dist/core/checker.d.ts +138 -0
  38. package/dist/core/checker.d.ts.map +1 -0
  39. package/dist/core/checker.js +4070 -0
  40. package/dist/core/checker.js.map +1 -0
  41. package/dist/core/cli/args.d.ts +18 -0
  42. package/dist/core/cli/args.d.ts.map +1 -0
  43. package/dist/core/cli/args.js +108 -0
  44. package/dist/core/cli/args.js.map +1 -0
  45. package/dist/core/cli/cli.d.ts +2 -0
  46. package/dist/core/cli/cli.d.ts.map +1 -0
  47. package/dist/core/cli/cli.js +477 -0
  48. package/dist/core/cli/cli.js.map +1 -0
  49. package/dist/core/cli/index.d.ts +2 -0
  50. package/dist/core/cli/index.d.ts.map +1 -0
  51. package/dist/core/cli/index.js +2 -0
  52. package/dist/core/cli/index.js.map +1 -0
  53. package/dist/core/decorator-utils.d.ts +108 -0
  54. package/dist/core/decorator-utils.d.ts.map +1 -0
  55. package/dist/core/decorator-utils.js +326 -0
  56. package/dist/core/decorator-utils.js.map +1 -0
  57. package/dist/core/diagnostics.d.ts +93 -0
  58. package/dist/core/diagnostics.d.ts.map +1 -0
  59. package/dist/core/diagnostics.js +315 -0
  60. package/dist/core/diagnostics.js.map +1 -0
  61. package/dist/core/emitter-utils.d.ts +14 -0
  62. package/dist/core/emitter-utils.d.ts.map +1 -0
  63. package/dist/core/emitter-utils.js +16 -0
  64. package/dist/core/emitter-utils.js.map +1 -0
  65. package/dist/core/formatter-fs.d.ts +21 -0
  66. package/dist/core/formatter-fs.d.ts.map +1 -0
  67. package/dist/core/formatter-fs.js +79 -0
  68. package/dist/core/formatter-fs.js.map +1 -0
  69. package/dist/core/formatter.d.ts +10 -0
  70. package/dist/core/formatter.d.ts.map +1 -0
  71. package/dist/core/formatter.js +24 -0
  72. package/dist/core/formatter.js.map +1 -0
  73. package/dist/core/helpers/discriminator-utils.d.ts +14 -0
  74. package/dist/core/helpers/discriminator-utils.d.ts.map +1 -0
  75. package/dist/core/helpers/discriminator-utils.js +169 -0
  76. package/dist/core/helpers/discriminator-utils.js.map +1 -0
  77. package/dist/core/helpers/index.d.ts +6 -0
  78. package/dist/core/helpers/index.d.ts.map +1 -0
  79. package/dist/core/helpers/index.js +6 -0
  80. package/dist/core/helpers/index.js.map +1 -0
  81. package/dist/core/helpers/operation-utils.d.ts +15 -0
  82. package/dist/core/helpers/operation-utils.d.ts.map +1 -0
  83. package/dist/core/helpers/operation-utils.js +35 -0
  84. package/dist/core/helpers/operation-utils.js.map +1 -0
  85. package/dist/core/helpers/projected-names-utils.d.ts +20 -0
  86. package/dist/core/helpers/projected-names-utils.d.ts.map +1 -0
  87. package/dist/core/helpers/projected-names-utils.js +40 -0
  88. package/dist/core/helpers/projected-names-utils.js.map +1 -0
  89. package/dist/core/helpers/type-name-utils.d.ts +14 -0
  90. package/dist/core/helpers/type-name-utils.d.ts.map +1 -0
  91. package/dist/core/helpers/type-name-utils.js +122 -0
  92. package/dist/core/helpers/type-name-utils.js.map +1 -0
  93. package/dist/core/helpers/usage-resolver.d.ts +20 -0
  94. package/dist/core/helpers/usage-resolver.d.ts.map +1 -0
  95. package/dist/core/helpers/usage-resolver.js +108 -0
  96. package/dist/core/helpers/usage-resolver.js.map +1 -0
  97. package/dist/core/index.d.ts +26 -0
  98. package/dist/core/index.d.ts.map +1 -0
  99. package/dist/core/index.js +26 -0
  100. package/dist/core/index.js.map +1 -0
  101. package/dist/core/install.d.ts +2 -0
  102. package/dist/core/install.d.ts.map +1 -0
  103. package/dist/core/install.js +26 -0
  104. package/dist/core/install.js.map +1 -0
  105. package/dist/core/library.d.ts +34 -0
  106. package/dist/core/library.d.ts.map +1 -0
  107. package/dist/core/library.js +100 -0
  108. package/dist/core/library.js.map +1 -0
  109. package/dist/core/logger/console-sink.browser.d.ts +4 -0
  110. package/dist/core/logger/console-sink.browser.d.ts.map +1 -0
  111. package/dist/core/logger/console-sink.browser.js +14 -0
  112. package/dist/core/logger/console-sink.browser.js.map +1 -0
  113. package/dist/core/logger/console-sink.d.ts +9 -0
  114. package/dist/core/logger/console-sink.d.ts.map +1 -0
  115. package/dist/core/logger/console-sink.js +81 -0
  116. package/dist/core/logger/console-sink.js.map +1 -0
  117. package/dist/core/logger/index.d.ts +3 -0
  118. package/dist/core/logger/index.d.ts.map +1 -0
  119. package/dist/core/logger/index.js +3 -0
  120. package/dist/core/logger/index.js.map +1 -0
  121. package/dist/core/logger/logger.d.ts +7 -0
  122. package/dist/core/logger/logger.d.ts.map +1 -0
  123. package/dist/core/logger/logger.js +32 -0
  124. package/dist/core/logger/logger.js.map +1 -0
  125. package/dist/core/logger/tracer.d.ts +3 -0
  126. package/dist/core/logger/tracer.d.ts.map +1 -0
  127. package/dist/core/logger/tracer.js +91 -0
  128. package/dist/core/logger/tracer.js.map +1 -0
  129. package/dist/core/manifest.d.ts +21 -0
  130. package/dist/core/manifest.d.ts.map +1 -0
  131. package/dist/core/manifest.js +8 -0
  132. package/dist/core/manifest.js.map +1 -0
  133. package/dist/core/messages.d.ts +2253 -0
  134. package/dist/core/messages.d.ts.map +1 -0
  135. package/dist/core/messages.js +749 -0
  136. package/dist/core/messages.js.map +1 -0
  137. package/dist/core/module-resolver.d.ts +84 -0
  138. package/dist/core/module-resolver.d.ts.map +1 -0
  139. package/dist/core/module-resolver.js +170 -0
  140. package/dist/core/module-resolver.js.map +1 -0
  141. package/dist/core/node-host.browser.d.ts +2 -0
  142. package/dist/core/node-host.browser.d.ts.map +1 -0
  143. package/dist/core/node-host.browser.js +2 -0
  144. package/dist/core/node-host.browser.js.map +1 -0
  145. package/dist/core/node-host.d.ts +7 -0
  146. package/dist/core/node-host.d.ts.map +1 -0
  147. package/dist/core/node-host.js +43 -0
  148. package/dist/core/node-host.js.map +1 -0
  149. package/dist/core/nonascii.d.ts +2 -0
  150. package/dist/core/nonascii.d.ts.map +1 -0
  151. package/dist/core/nonascii.js +712 -0
  152. package/dist/core/nonascii.js.map +1 -0
  153. package/dist/core/options.d.ts +46 -0
  154. package/dist/core/options.d.ts.map +1 -0
  155. package/dist/core/options.js +2 -0
  156. package/dist/core/options.js.map +1 -0
  157. package/dist/core/parser.d.ts +17 -0
  158. package/dist/core/parser.d.ts.map +1 -0
  159. package/dist/core/parser.js +2561 -0
  160. package/dist/core/parser.js.map +1 -0
  161. package/dist/core/path-utils.d.ts +193 -0
  162. package/dist/core/path-utils.d.ts.map +1 -0
  163. package/dist/core/path-utils.js +427 -0
  164. package/dist/core/path-utils.js.map +1 -0
  165. package/dist/core/program.d.ts +104 -0
  166. package/dist/core/program.d.ts.map +1 -0
  167. package/dist/core/program.js +898 -0
  168. package/dist/core/program.js.map +1 -0
  169. package/dist/core/projection-members.d.ts +8 -0
  170. package/dist/core/projection-members.d.ts.map +1 -0
  171. package/dist/core/projection-members.js +387 -0
  172. package/dist/core/projection-members.js.map +1 -0
  173. package/dist/core/projector.d.ts +26 -0
  174. package/dist/core/projector.d.ts.map +1 -0
  175. package/dist/core/projector.js +523 -0
  176. package/dist/core/projector.js.map +1 -0
  177. package/dist/core/scanner.d.ts +125 -0
  178. package/dist/core/scanner.d.ts.map +1 -0
  179. package/dist/core/scanner.js +1012 -0
  180. package/dist/core/scanner.js.map +1 -0
  181. package/dist/core/schema-validator.d.ts +6 -0
  182. package/dist/core/schema-validator.d.ts.map +1 -0
  183. package/dist/core/schema-validator.js +38 -0
  184. package/dist/core/schema-validator.js.map +1 -0
  185. package/dist/core/semantic-walker.d.ts +53 -0
  186. package/dist/core/semantic-walker.d.ts.map +1 -0
  187. package/dist/core/semantic-walker.js +355 -0
  188. package/dist/core/semantic-walker.js.map +1 -0
  189. package/dist/core/type-utils.d.ts +49 -0
  190. package/dist/core/type-utils.d.ts.map +1 -0
  191. package/dist/core/type-utils.js +95 -0
  192. package/dist/core/type-utils.js.map +1 -0
  193. package/dist/core/types.d.ts +1345 -0
  194. package/dist/core/types.d.ts.map +1 -0
  195. package/dist/core/types.js +105 -0
  196. package/dist/core/types.js.map +1 -0
  197. package/dist/core/util.d.ts +150 -0
  198. package/dist/core/util.d.ts.map +1 -0
  199. package/dist/core/util.js +417 -0
  200. package/dist/core/util.js.map +1 -0
  201. package/dist/emitter-framework/asset-emitter.d.ts +5 -0
  202. package/dist/emitter-framework/asset-emitter.d.ts.map +1 -0
  203. package/dist/emitter-framework/asset-emitter.js +610 -0
  204. package/dist/emitter-framework/asset-emitter.js.map +1 -0
  205. package/dist/emitter-framework/builders/array-builder.d.ts +7 -0
  206. package/dist/emitter-framework/builders/array-builder.d.ts.map +1 -0
  207. package/dist/emitter-framework/builders/array-builder.js +45 -0
  208. package/dist/emitter-framework/builders/array-builder.js.map +1 -0
  209. package/dist/emitter-framework/builders/object-builder.d.ts +9 -0
  210. package/dist/emitter-framework/builders/object-builder.d.ts.map +1 -0
  211. package/dist/emitter-framework/builders/object-builder.js +30 -0
  212. package/dist/emitter-framework/builders/object-builder.js.map +1 -0
  213. package/dist/emitter-framework/builders/string-builder.d.ts +13 -0
  214. package/dist/emitter-framework/builders/string-builder.d.ts.map +1 -0
  215. package/dist/emitter-framework/builders/string-builder.js +98 -0
  216. package/dist/emitter-framework/builders/string-builder.js.map +1 -0
  217. package/dist/emitter-framework/custom-key-map.d.ts +29 -0
  218. package/dist/emitter-framework/custom-key-map.d.ts.map +1 -0
  219. package/dist/emitter-framework/custom-key-map.js +62 -0
  220. package/dist/emitter-framework/custom-key-map.js.map +1 -0
  221. package/dist/emitter-framework/index.d.ts +8 -0
  222. package/dist/emitter-framework/index.d.ts.map +1 -0
  223. package/dist/emitter-framework/index.js +8 -0
  224. package/dist/emitter-framework/index.js.map +1 -0
  225. package/dist/emitter-framework/placeholder.d.ts +12 -0
  226. package/dist/emitter-framework/placeholder.d.ts.map +1 -0
  227. package/dist/emitter-framework/placeholder.js +27 -0
  228. package/dist/emitter-framework/placeholder.js.map +1 -0
  229. package/dist/emitter-framework/type-emitter.d.ts +314 -0
  230. package/dist/emitter-framework/type-emitter.d.ts.map +1 -0
  231. package/dist/emitter-framework/type-emitter.js +612 -0
  232. package/dist/emitter-framework/type-emitter.js.map +1 -0
  233. package/dist/emitter-framework/types.d.ts +124 -0
  234. package/dist/emitter-framework/types.d.ts.map +1 -0
  235. package/dist/emitter-framework/types.js +39 -0
  236. package/dist/emitter-framework/types.js.map +1 -0
  237. package/dist/formatter/index.d.ts +11 -0
  238. package/dist/formatter/index.d.ts.map +1 -0
  239. package/dist/formatter/index.js +28 -0
  240. package/dist/formatter/index.js.map +1 -0
  241. package/dist/formatter/parser.d.ts +16 -0
  242. package/dist/formatter/parser.d.ts.map +1 -0
  243. package/dist/formatter/parser.js +23 -0
  244. package/dist/formatter/parser.js.map +1 -0
  245. package/dist/formatter/print/comment-handler.d.ts +7 -0
  246. package/dist/formatter/print/comment-handler.d.ts.map +1 -0
  247. package/dist/formatter/print/comment-handler.js +81 -0
  248. package/dist/formatter/print/comment-handler.js.map +1 -0
  249. package/dist/formatter/print/index.d.ts +3 -0
  250. package/dist/formatter/print/index.d.ts.map +1 -0
  251. package/dist/formatter/print/index.js +3 -0
  252. package/dist/formatter/print/index.js.map +1 -0
  253. package/dist/formatter/print/needs-parens.d.ts +10 -0
  254. package/dist/formatter/print/needs-parens.d.ts.map +1 -0
  255. package/dist/formatter/print/needs-parens.js +27 -0
  256. package/dist/formatter/print/needs-parens.js.map +1 -0
  257. package/dist/formatter/print/printer.d.ts +62 -0
  258. package/dist/formatter/print/printer.d.ts.map +1 -0
  259. package/dist/formatter/print/printer.js +1025 -0
  260. package/dist/formatter/print/printer.js.map +1 -0
  261. package/dist/formatter/print/types.d.ts +9 -0
  262. package/dist/formatter/print/types.d.ts.map +1 -0
  263. package/dist/formatter/print/types.js +2 -0
  264. package/dist/formatter/print/types.js.map +1 -0
  265. package/dist/init/index.d.ts +2 -0
  266. package/dist/init/index.d.ts.map +1 -0
  267. package/dist/init/index.js +2 -0
  268. package/dist/init/index.js.map +1 -0
  269. package/dist/init/init-template.d.ts +45 -0
  270. package/dist/init/init-template.d.ts.map +1 -0
  271. package/dist/init/init-template.js +45 -0
  272. package/dist/init/init-template.js.map +1 -0
  273. package/dist/init/init.d.ts +49 -0
  274. package/dist/init/init.d.ts.map +1 -0
  275. package/dist/init/init.js +224 -0
  276. package/dist/init/init.js.map +1 -0
  277. package/dist/lib/decorators.d.ts +222 -0
  278. package/dist/lib/decorators.d.ts.map +1 -0
  279. package/dist/lib/decorators.js +745 -0
  280. package/dist/lib/decorators.js.map +1 -0
  281. package/dist/lib/service.d.ts +38 -0
  282. package/dist/lib/service.d.ts.map +1 -0
  283. package/dist/lib/service.js +78 -0
  284. package/dist/lib/service.js.map +1 -0
  285. package/dist/manifest.js +4 -0
  286. package/dist/server/completion.d.ts +10 -0
  287. package/dist/server/completion.d.ts.map +1 -0
  288. package/dist/server/completion.js +207 -0
  289. package/dist/server/completion.js.map +1 -0
  290. package/dist/server/index.d.ts +3 -0
  291. package/dist/server/index.d.ts.map +1 -0
  292. package/dist/server/index.js +3 -0
  293. package/dist/server/index.js.map +1 -0
  294. package/dist/server/language-config.d.ts +195 -0
  295. package/dist/server/language-config.d.ts.map +1 -0
  296. package/dist/server/language-config.js +102 -0
  297. package/dist/server/language-config.js.map +1 -0
  298. package/dist/server/server.d.ts +2 -0
  299. package/dist/server/server.d.ts.map +1 -0
  300. package/dist/server/server.js +131 -0
  301. package/dist/server/server.js.map +1 -0
  302. package/dist/server/serverlib.d.ts +72 -0
  303. package/dist/server/serverlib.d.ts.map +1 -0
  304. package/dist/server/serverlib.js +1034 -0
  305. package/dist/server/serverlib.js.map +1 -0
  306. package/dist/server/symbol-structure.d.ts +4 -0
  307. package/dist/server/symbol-structure.d.ts.map +1 -0
  308. package/dist/server/symbol-structure.js +121 -0
  309. package/dist/server/symbol-structure.js.map +1 -0
  310. package/dist/server/tmlanguage.d.ts +3 -0
  311. package/dist/server/tmlanguage.d.ts.map +1 -0
  312. package/dist/server/tmlanguage.js +713 -0
  313. package/dist/server/tmlanguage.js.map +1 -0
  314. package/dist/server/type-details.d.ts +11 -0
  315. package/dist/server/type-details.d.ts.map +1 -0
  316. package/dist/server/type-details.js +72 -0
  317. package/dist/server/type-details.js.map +1 -0
  318. package/dist/server/type-signature.d.ts +2 -0
  319. package/dist/server/type-signature.d.ts.map +1 -0
  320. package/dist/server/type-signature.js +108 -0
  321. package/dist/server/type-signature.js.map +1 -0
  322. package/dist/testing/expect.d.ts +49 -0
  323. package/dist/testing/expect.d.ts.map +1 -0
  324. package/dist/testing/expect.js +83 -0
  325. package/dist/testing/expect.js.map +1 -0
  326. package/dist/testing/index.d.ts +6 -0
  327. package/dist/testing/index.d.ts.map +1 -0
  328. package/dist/testing/index.js +6 -0
  329. package/dist/testing/index.js.map +1 -0
  330. package/dist/testing/test-host.d.ts +14 -0
  331. package/dist/testing/test-host.d.ts.map +1 -0
  332. package/dist/testing/test-host.js +271 -0
  333. package/dist/testing/test-host.js.map +1 -0
  334. package/dist/testing/test-server-host.d.ts +39 -0
  335. package/dist/testing/test-server-host.d.ts.map +1 -0
  336. package/dist/testing/test-server-host.js +112 -0
  337. package/dist/testing/test-server-host.js.map +1 -0
  338. package/dist/testing/test-utils.d.ts +22 -0
  339. package/dist/testing/test-utils.d.ts.map +1 -0
  340. package/dist/testing/test-utils.js +60 -0
  341. package/dist/testing/test-utils.js.map +1 -0
  342. package/dist/testing/types.d.ts +69 -0
  343. package/dist/testing/types.d.ts.map +1 -0
  344. package/dist/testing/types.js +7 -0
  345. package/dist/testing/types.js.map +1 -0
  346. package/dist/typespec.tmLanguage +1760 -0
  347. package/lib/decorators.tsp +420 -0
  348. package/lib/lib.tsp +158 -0
  349. package/lib/main.tsp +4 -0
  350. package/lib/projected-names.tsp +94 -0
  351. package/lib/reflection.tsp +10 -0
  352. package/package.json +119 -0
@@ -0,0 +1,477 @@
1
+ try {
2
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3
+ // @ts-ignore
4
+ await import("source-map-support/register.js");
5
+ }
6
+ catch {
7
+ // package only present in dev.
8
+ }
9
+ /* eslint-disable no-console */
10
+ import { spawnSync } from "child_process";
11
+ import { mkdtemp, readdir, rm } from "fs/promises";
12
+ import watch from "node-watch";
13
+ import os from "os";
14
+ import { resolve } from "path";
15
+ import { fileURLToPath } from "url";
16
+ import yargs from "yargs";
17
+ import { loadTypeSpecConfigForPath } from "../../config/index.js";
18
+ import { initTypeSpecProject } from "../../init/index.js";
19
+ import { compilerAssert, logDiagnostics } from "../diagnostics.js";
20
+ import { findUnformattedTypeSpecFiles, formatTypeSpecFiles } from "../formatter-fs.js";
21
+ import { installTypeSpecDependencies } from "../install.js";
22
+ import { createConsoleSink } from "../logger/index.js";
23
+ import { NodeHost } from "../node-host.js";
24
+ import { getAnyExtensionFromPath, getBaseFileName, joinPaths } from "../path-utils.js";
25
+ import { compile } from "../program.js";
26
+ import { ExternalError, typespecVersion } from "../util.js";
27
+ import { getCompilerOptions } from "./args.js";
28
+ async function main() {
29
+ console.log(`TypeSpec compiler v${typespecVersion}\n`);
30
+ await yargs(process.argv.slice(2))
31
+ .scriptName("tsp")
32
+ .help()
33
+ .strict()
34
+ .parserConfiguration({
35
+ "greedy-arrays": false,
36
+ "boolean-negation": false,
37
+ })
38
+ .option("debug", {
39
+ type: "boolean",
40
+ description: "Output debug log messages.",
41
+ default: false,
42
+ })
43
+ .option("pretty", {
44
+ type: "boolean",
45
+ description: "Enable color and formatting in TypeSpec's output to make compiler errors easier to read.",
46
+ default: true,
47
+ })
48
+ .command("compile <path>", "Compile TypeSpec source.", (cmd) => {
49
+ return cmd
50
+ .positional("path", {
51
+ description: "The path to the main.tsp file or directory containing main.tsp.",
52
+ type: "string",
53
+ demandOption: true,
54
+ })
55
+ .option("output-path", {
56
+ type: "string",
57
+ deprecated: "Use `output-dir` instead.",
58
+ hidden: true,
59
+ })
60
+ .option("output-dir", {
61
+ type: "string",
62
+ describe: "The output path for generated artifacts. If it does not exist, it will be created.",
63
+ })
64
+ .option("options", {
65
+ type: "array",
66
+ alias: "option",
67
+ string: true,
68
+ describe: "Key/value pairs that can be used to set emitter options. The format is '<emitterName>.<key>=<value>'. This parameter can be used multiple times to add more options.",
69
+ })
70
+ .option("nostdlib", {
71
+ type: "boolean",
72
+ default: false,
73
+ describe: "Don't load the TypeSpec standard library.",
74
+ })
75
+ .option("import", {
76
+ type: "array",
77
+ string: true,
78
+ describe: "Additional imports to include. This parameter can be used multiple times to add more imports.",
79
+ })
80
+ .option("watch", {
81
+ type: "boolean",
82
+ default: false,
83
+ describe: "Watch project files for changes and recompile.",
84
+ })
85
+ .option("emit", {
86
+ type: "array",
87
+ string: true,
88
+ describe: "Name of the emitters",
89
+ })
90
+ .option("trace", {
91
+ type: "array",
92
+ string: true,
93
+ describe: "List of areas that should have the trace shown. e.g. `import-resolution.*`",
94
+ })
95
+ .option("warn-as-error", {
96
+ type: "boolean",
97
+ default: false,
98
+ describe: "Treat warnings as errors and return non-zero exit code if there are any.",
99
+ })
100
+ .option("no-emit", {
101
+ type: "boolean",
102
+ default: false,
103
+ describe: "Run emitters but do not emit any output.",
104
+ })
105
+ .option("arg", {
106
+ type: "array",
107
+ alias: "args",
108
+ string: true,
109
+ describe: "Key/value of arguments that are used in the configuration.",
110
+ });
111
+ }, async (args) => {
112
+ const host = createCLICompilerHost(args);
113
+ const cliOptions = await getCompilerOptionsOrExit(host, args);
114
+ const program = await compileInput(host, args.path, cliOptions);
115
+ if (program.hasError()) {
116
+ process.exit(1);
117
+ }
118
+ if (program.emitters.length === 0 && !program.compilerOptions.noEmit) {
119
+ console.log("No emitter was configured, no output was generated. Use `--emit <emitterName>` to pick emitter or specify it in the typespec config.");
120
+ }
121
+ })
122
+ .command("code", "Manage VS Code Extension.", (cmd) => {
123
+ return cmd
124
+ .demandCommand(1, "No command specified.")
125
+ .option("insiders", {
126
+ type: "boolean",
127
+ description: "Use VS Code Insiders",
128
+ default: false,
129
+ })
130
+ .command("install", "Install VS Code Extension", () => { }, (args) => installVSCodeExtension(args.insiders, args.debug))
131
+ .command("uninstall", "Uninstall VS Code Extension", () => { }, (args) => uninstallVSCodeExtension(args.insiders, args.debug));
132
+ })
133
+ .command("vs", "Manage Visual Studio Extension.", (cmd) => {
134
+ return cmd
135
+ .demandCommand(1, "No command specified")
136
+ .command("install", "Install Visual Studio Extension.", () => { }, (args) => installVSExtension(args.debug))
137
+ .command("uninstall", "Uninstall VS Extension", () => { }, () => uninstallVSExtension());
138
+ })
139
+ .command("format <include...>", "Format given list of TypeSpec files.", (cmd) => {
140
+ return cmd
141
+ .positional("include", {
142
+ description: "Wildcard pattern of the list of files.",
143
+ type: "string",
144
+ array: true,
145
+ demandOption: true,
146
+ })
147
+ .option("exclude", {
148
+ alias: "x",
149
+ type: "string",
150
+ array: true,
151
+ describe: "Pattern to exclude",
152
+ })
153
+ .option("check", {
154
+ alias: "c",
155
+ type: "boolean",
156
+ describe: "Verify the files are formatted.",
157
+ });
158
+ }, async (args) => {
159
+ if (args["check"]) {
160
+ const unformatted = await findUnformattedTypeSpecFiles(args["include"], {
161
+ exclude: args["exclude"],
162
+ debug: args.debug,
163
+ });
164
+ if (unformatted.length > 0) {
165
+ console.log(`Found ${unformatted.length} unformatted files:`);
166
+ for (const file of unformatted) {
167
+ console.log(` - ${file}`);
168
+ }
169
+ process.exit(1);
170
+ }
171
+ }
172
+ else {
173
+ await formatTypeSpecFiles(args["include"], {
174
+ exclude: args["exclude"],
175
+ debug: args.debug,
176
+ });
177
+ }
178
+ })
179
+ .command("init [templatesUrl]", "Create a new TypeSpec project.", (cmd) => cmd.positional("templatesUrl", {
180
+ description: "Url of the initialization template",
181
+ type: "string",
182
+ }), (args) => initTypeSpecProject(createCLICompilerHost(args), process.cwd(), args.templatesUrl))
183
+ .command("install", "Install typespec dependencies", () => { }, () => installTypeSpecDependencies(process.cwd()))
184
+ .command("info", "Show information about current TypeSpec compiler.", () => { }, (args) => printInfo(createCLICompilerHost(args)))
185
+ .version(typespecVersion)
186
+ .demandCommand(1, "You must use one of the supported commands.").argv;
187
+ }
188
+ function compileInput(host, path, compilerOptions, printSuccess = true) {
189
+ let compileRequested = false;
190
+ let currentCompilePromise = undefined;
191
+ const log = (message, ...optionalParams) => {
192
+ const prefix = compilerOptions.watchForChanges ? `[${new Date().toLocaleTimeString()}] ` : "";
193
+ console.log(`${prefix}${message}`, ...optionalParams);
194
+ };
195
+ const runCompilePromise = () => {
196
+ // Don't run the compiler if it's already running
197
+ if (!currentCompilePromise) {
198
+ // Clear the console before compiling in watch mode
199
+ if (compilerOptions.watchForChanges) {
200
+ console.clear();
201
+ }
202
+ currentCompilePromise = compile(host, resolve(path), compilerOptions)
203
+ .then(onCompileFinished)
204
+ .catch(internalCompilerError);
205
+ }
206
+ else {
207
+ compileRequested = true;
208
+ }
209
+ return currentCompilePromise;
210
+ };
211
+ const runCompile = () => void runCompilePromise();
212
+ const onCompileFinished = (program) => {
213
+ if (program.diagnostics.length > 0) {
214
+ log("Diagnostics were reported during compilation:\n");
215
+ logDiagnostics(program.diagnostics, host.logSink);
216
+ logDiagnosticCount(program.diagnostics);
217
+ }
218
+ else {
219
+ if (printSuccess) {
220
+ log(`Compilation completed successfully, output files are in ${compilerOptions.outputDir}.`);
221
+ }
222
+ }
223
+ console.log(); // Insert a newline
224
+ currentCompilePromise = undefined;
225
+ if (compilerOptions.watchForChanges && compileRequested) {
226
+ compileRequested = false;
227
+ runCompile();
228
+ }
229
+ return program;
230
+ };
231
+ if (compilerOptions.watchForChanges) {
232
+ runCompile();
233
+ return new Promise((resolve, reject) => {
234
+ const watcher = watch(path, {
235
+ recursive: true,
236
+ filter: (f) => [".js", ".tsp", ".cadl"].indexOf(getAnyExtensionFromPath(f)) > -1 &&
237
+ !/node_modules/.test(f),
238
+ }, (e, name) => {
239
+ runCompile();
240
+ });
241
+ // Handle Ctrl+C for termination
242
+ process.on("SIGINT", () => {
243
+ watcher.close();
244
+ console.info("Terminating watcher...\n");
245
+ });
246
+ });
247
+ }
248
+ else {
249
+ return runCompilePromise();
250
+ }
251
+ }
252
+ function logDiagnosticCount(diagnostics) {
253
+ const errorCount = diagnostics.filter((x) => x.severity === "error").length;
254
+ const warningCount = diagnostics.filter((x) => x.severity === "warning").length;
255
+ const addSuffix = (count, suffix) => count > 1 ? `${count} ${suffix}s` : count === 1 ? `${count} ${suffix}` : undefined;
256
+ const errorText = addSuffix(errorCount, "error");
257
+ const warningText = addSuffix(warningCount, "warning");
258
+ console.log(`\nFound ${[errorText, warningText].filter((x) => x !== undefined).join(", ")}.`);
259
+ }
260
+ function createCLICompilerHost(args) {
261
+ return { ...NodeHost, logSink: createConsoleSink({ pretty: args.pretty }) };
262
+ }
263
+ async function getCompilerOptionsOrExit(host, args) {
264
+ const [options, diagnostics] = await getCompilerOptions(host, process.cwd(), args, process.env);
265
+ if (diagnostics.length > 0) {
266
+ logDiagnostics(diagnostics, host.logSink);
267
+ }
268
+ if (options === undefined) {
269
+ logDiagnosticCount(diagnostics);
270
+ process.exit(1);
271
+ }
272
+ return options;
273
+ }
274
+ async function installVsix(pkg, install, debug) {
275
+ var _a;
276
+ // download npm package to temporary directory
277
+ const temp = await mkdtemp(joinPaths(os.tmpdir(), "typespec"));
278
+ const npmArgs = ["install"];
279
+ // hide npm output unless --debug was passed to typespec
280
+ if (!debug) {
281
+ npmArgs.push("--silent");
282
+ }
283
+ // NOTE: Using cwd=temp with `--prefix .` instead of `--prefix ${temp}` to
284
+ // workaround https://github.com/npm/cli/issues/3256. It's still important
285
+ // to pass --prefix even though we're using cwd as otherwise, npm might
286
+ // find a package.json file in a parent directory and install to that
287
+ // directory.
288
+ npmArgs.push("--prefix", ".");
289
+ // To debug with a locally built package rather than pulling from npm,
290
+ // specify the full path to the packed .tgz using TYPESPEC_DEBUG_VSIX_TGZ
291
+ // environment variable.
292
+ npmArgs.push((_a = process.env.TYPESPEC_DEBUG_VSIX_TGZ) !== null && _a !== void 0 ? _a : pkg);
293
+ run("npm", npmArgs, { cwd: temp, debug });
294
+ // locate .vsix
295
+ const dir = joinPaths(temp, "node_modules", pkg);
296
+ const files = await readdir(dir);
297
+ const vsixPaths = [];
298
+ for (const file of files) {
299
+ if (file.endsWith(".vsix")) {
300
+ vsixPaths.push(joinPaths(dir, file));
301
+ }
302
+ }
303
+ compilerAssert(vsixPaths.length > 0, `Installed ${pkg} from npm, but didn't find any .vsix files in it.`);
304
+ // install extension
305
+ install(vsixPaths);
306
+ // delete temporary directory
307
+ await rm(temp, { recursive: true });
308
+ }
309
+ function runCode(codeArgs, insiders, debug) {
310
+ try {
311
+ run(insiders ? "code-insiders" : "code", codeArgs, {
312
+ // VS Code's CLI emits node warnings that we can't do anything about. Suppress them.
313
+ extraEnv: { NODE_NO_WARNINGS: "1" },
314
+ debug,
315
+ allowNotFound: true,
316
+ });
317
+ }
318
+ catch (error) {
319
+ if (error.code === "ENOENT") {
320
+ console.error(`error: Couldn't find VS Code 'code' command in PATH. Make sure you have the VS Code executable added to the system PATH.`);
321
+ if (process.platform === "darwin") {
322
+ console.log("See instruction for Mac OS here https://code.visualstudio.com/docs/setup/mac");
323
+ }
324
+ if (debug) {
325
+ console.log(error.stack);
326
+ }
327
+ process.exit(1);
328
+ }
329
+ }
330
+ }
331
+ async function installVSCodeExtension(insiders, debug) {
332
+ await installVsix("typespec-vscode", (vsixPaths) => {
333
+ runCode(["--install-extension", vsixPaths[0]], insiders, debug);
334
+ }, debug);
335
+ }
336
+ async function uninstallVSCodeExtension(insiders, debug) {
337
+ await runCode(["--uninstall-extension", "microsoft.tsp-vscode"], insiders, debug);
338
+ }
339
+ function getVsixInstallerPath() {
340
+ return getVSInstallerPath("resources/app/ServiceHub/Services/Microsoft.VisualStudio.Setup.Service/VSIXInstaller.exe");
341
+ }
342
+ function getVSWherePath() {
343
+ return getVSInstallerPath("vswhere.exe");
344
+ }
345
+ function getVSInstallerPath(relativePath) {
346
+ var _a;
347
+ if (process.platform !== "win32") {
348
+ console.error("error: Visual Studio extension is not supported on non-Windows.");
349
+ process.exit(1);
350
+ }
351
+ return joinPaths((_a = process.env["ProgramFiles(x86)"]) !== null && _a !== void 0 ? _a : "", "Microsoft Visual Studio/Installer", relativePath);
352
+ }
353
+ function isVSInstalled(versionRange) {
354
+ const vswhere = getVSWherePath();
355
+ const proc = run(vswhere, ["-property", "instanceid", "-prerelease", "-version", versionRange], {
356
+ stdio: [null, "pipe", "inherit"],
357
+ allowNotFound: true,
358
+ });
359
+ return proc.status === 0 && proc.stdout;
360
+ }
361
+ const VSIX_ALREADY_INSTALLED = 1001;
362
+ const VSIX_NOT_INSTALLED = 1002;
363
+ const VSIX_USER_CANCELED = 2005;
364
+ const VS_SUPPORTED_VERSION_RANGE = "[17.0,)";
365
+ async function installVSExtension(debug) {
366
+ const vsixInstaller = getVsixInstallerPath();
367
+ if (!isVSInstalled(VS_SUPPORTED_VERSION_RANGE)) {
368
+ console.error("error: No compatible version of Visual Studio found.");
369
+ process.exit(1);
370
+ }
371
+ await installVsix("typespec-vs", (vsixPaths) => {
372
+ for (const vsix of vsixPaths) {
373
+ console.log(`Installing extension for Visual Studio...`);
374
+ run(vsixInstaller, [vsix], {
375
+ allowedExitCodes: [VSIX_ALREADY_INSTALLED, VSIX_USER_CANCELED],
376
+ });
377
+ }
378
+ }, debug);
379
+ }
380
+ async function uninstallVSExtension() {
381
+ const vsixInstaller = getVsixInstallerPath();
382
+ run(vsixInstaller, ["/uninstall:88b9492f-c019-492c-8aeb-f325a7e4cf23"], {
383
+ allowedExitCodes: [VSIX_NOT_INSTALLED, VSIX_USER_CANCELED],
384
+ });
385
+ }
386
+ /**
387
+ * Print the resolved TypeSpec configuration.
388
+ */
389
+ async function printInfo(host) {
390
+ var _a;
391
+ const cwd = process.cwd();
392
+ console.log(`Module: ${fileURLToPath(import.meta.url)}`);
393
+ const config = await loadTypeSpecConfigForPath(host, cwd);
394
+ const jsyaml = await import("js-yaml");
395
+ const excluded = ["diagnostics", "filename"];
396
+ const replacer = (emitter, value) => excluded.includes(emitter) ? undefined : value;
397
+ console.log(`User Config: ${(_a = config.filename) !== null && _a !== void 0 ? _a : "No config file found"}`);
398
+ console.log("-----------");
399
+ console.log(jsyaml.dump(config, { replacer }));
400
+ console.log("-----------");
401
+ logDiagnostics(config.diagnostics, host.logSink);
402
+ logDiagnosticCount(config.diagnostics);
403
+ if (config.diagnostics.some((d) => d.severity === "error")) {
404
+ process.exit(1);
405
+ }
406
+ }
407
+ // NOTE: We could also use { shell: true } to let windows find the .cmd, but that breaks
408
+ // ENOENT checking and handles spaces poorly in some cases.
409
+ const isCmdOnWindows = ["code", "code-insiders", "npm"];
410
+ function run(command, commandArgs, options) {
411
+ var _a, _b, _c;
412
+ if (options === null || options === void 0 ? void 0 : options.debug) {
413
+ if (options) {
414
+ console.log(options);
415
+ }
416
+ console.log(`> ${command} ${commandArgs.join(" ")}\n`);
417
+ }
418
+ if (options === null || options === void 0 ? void 0 : options.extraEnv) {
419
+ options.env = {
420
+ ...((_a = options === null || options === void 0 ? void 0 : options.env) !== null && _a !== void 0 ? _a : process.env),
421
+ ...options.extraEnv,
422
+ };
423
+ }
424
+ const baseCommandName = getBaseFileName(command);
425
+ if (process.platform === "win32" && isCmdOnWindows.includes(command)) {
426
+ command += ".cmd";
427
+ }
428
+ const finalOptions = {
429
+ encoding: "utf-8",
430
+ stdio: "inherit",
431
+ ...(options !== null && options !== void 0 ? options : {}),
432
+ };
433
+ const proc = spawnSync(command, commandArgs, finalOptions);
434
+ if (options === null || options === void 0 ? void 0 : options.debug) {
435
+ console.log(proc);
436
+ }
437
+ if (proc.error) {
438
+ if (proc.error.code === "ENOENT" && !(options === null || options === void 0 ? void 0 : options.allowNotFound)) {
439
+ console.error(`error: Command '${baseCommandName}' not found.`);
440
+ if (options === null || options === void 0 ? void 0 : options.debug) {
441
+ console.log(proc.error.stack);
442
+ }
443
+ process.exit(1);
444
+ }
445
+ else {
446
+ throw proc.error;
447
+ }
448
+ }
449
+ if (proc.status !== 0 && !((_b = options === null || options === void 0 ? void 0 : options.allowedExitCodes) === null || _b === void 0 ? void 0 : _b.includes((_c = proc.status) !== null && _c !== void 0 ? _c : 0))) {
450
+ console.error(`error: Command '${baseCommandName} ${commandArgs.join(" ")}' failed with exit code ${proc.status}.`);
451
+ process.exit(proc.status || 1);
452
+ }
453
+ return proc;
454
+ }
455
+ function internalCompilerError(error) {
456
+ // NOTE: An expected error, like one thrown for bad input, shouldn't reach
457
+ // here, but be handled somewhere else. If we reach here, it should be
458
+ // considered a bug and therefore we should not suppress the stack trace as
459
+ // that risks losing it in the case of a bug that does not repro easily.
460
+ if (error instanceof ExternalError) {
461
+ // ExternalError should already have all the relevant information needed when thrown.
462
+ console.error(error);
463
+ }
464
+ else {
465
+ console.error("Internal compiler error!");
466
+ console.error("File issue at https://github.com/microsoft/typespec");
467
+ console.error();
468
+ console.error(error);
469
+ }
470
+ process.exit(1);
471
+ }
472
+ process.on("unhandledRejection", (error) => {
473
+ console.error("Unhandled promise rejection!");
474
+ internalCompilerError(error);
475
+ });
476
+ main().catch(internalCompilerError);
477
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../core/cli/cli.ts"],"names":[],"mappings":"AAAA,IAAI;IACF,6DAA6D;IAC7D,aAAa;IACb,MAAM,MAAM,CAAC,gCAAgC,CAAC,CAAC;CAChD;AAAC,MAAM;IACN,+BAA+B;CAChC;AAED,+BAA+B;AAC/B,OAAO,EAAE,SAAS,EAAsC,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,4BAA4B,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,2BAA2B,EAAE,MAAM,eAAe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,SAAS,qBAAqB,CAAC,KAAc;IAC3C,0EAA0E;IAC1E,sEAAsE;IACtE,2EAA2E;IAC3E,wEAAwE;IACxE,IAAI,KAAK,YAAY,aAAa,EAAE;QAClC,qFAAqF;QACrF,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KACtB;SAAM;QACL,OAAO,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC1C,OAAO,CAAC,KAAK,CAAC,qDAAqD,CAAC,CAAC;QACrE,OAAO,CAAC,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KACtB;IAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,KAAc,EAAE,EAAE;IAClD,OAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC9C,qBAAqB,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC,CAAC,CAAC;AAEH,IAAI,EAAE,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./args.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../core/cli/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./args.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../core/cli/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
@@ -0,0 +1,108 @@
1
+ import { Program } from "./program.js";
2
+ import { DecoratorContext, DecoratorFunction, Diagnostic, DiagnosticTarget, IntrinsicScalarName, ModelProperty, Scalar, Type } from "./types.js";
3
+ /** @deprecated Use TypeSpecValue */
4
+ export type CadlValue = TypeSpecValue;
5
+ export type TypeSpecValue = Type | string | number | boolean;
6
+ /** @deprecated Use InferredTypeSpecValue */
7
+ export type InferredCadlValue<K extends TypeKind> = InferredTypeSpecValue<K>;
8
+ export type InferredTypeSpecValue<K extends TypeKind> = K extends "Any" ? TypeSpecValue : K extends (infer T extends Type["kind"])[] ? InferredTypeSpecValue<T> : K extends "String" ? string : K extends "Number" ? number : K extends "Boolean" ? boolean : Type & {
9
+ kind: K;
10
+ };
11
+ /**
12
+ * Validate the decorator target is matching the expected value.
13
+ * @param program
14
+ * @param target
15
+ * @param expectedType
16
+ * @param decoratorName
17
+ * @returns
18
+ */
19
+ export declare function validateDecoratorTarget<K extends TypeKind>(context: DecoratorContext, target: Type, decoratorName: string, expectedType: K | readonly K[]): target is K extends "Any" ? Type : Type & {
20
+ kind: K;
21
+ };
22
+ export declare function validateDecoratorTargetIntrinsic(context: DecoratorContext, target: Scalar | ModelProperty, decoratorName: string, expectedType: IntrinsicScalarName | IntrinsicScalarName[]): boolean;
23
+ /** @deprecated use isTypeSpecValueTypeOf */
24
+ export declare const isCadlValueTypeOf: typeof isTypeSpecValueTypeOf;
25
+ /**
26
+ * Check if the given target is of any of the typespec types.
27
+ * @param target Target to validate.
28
+ * @param expectedType One or multiple allowed typespec types.
29
+ * @returns boolean if the target is of one of the allowed types.
30
+ */
31
+ export declare function isTypeSpecValueTypeOf<K extends TypeKind>(target: TypeSpecValue, expectedType: K | readonly K[]): target is InferredTypeSpecValue<K>;
32
+ /**
33
+ * Validate a decorator parameter has the correct type.
34
+ * @param program Program
35
+ * @param target Decorator target
36
+ * @param value Value of the parameter.
37
+ * @param expectedType Expected type or list of expected type
38
+ * @returns true if the value is of one of the type in the list of expected types. If not emit a diagnostic.
39
+ * @deprecated use @see createDecoratorDefinition#validate instead.
40
+ */
41
+ export declare function validateDecoratorParamType<K extends Type["kind"]>(program: Program, target: Type, value: TypeSpecValue, expectedType: K | K[]): value is InferredTypeSpecValue<K>;
42
+ export interface DecoratorDefinition<T extends TypeKind, P extends readonly DecoratorParamDefinition<TypeKind>[], S extends DecoratorParamDefinition<TypeKind> | undefined = undefined> {
43
+ /**
44
+ * Name of the decorator.
45
+ */
46
+ readonly name: string;
47
+ /**
48
+ * Decorator target.
49
+ */
50
+ readonly target: T | readonly T[];
51
+ /**
52
+ * List of positional arguments in the function.
53
+ */
54
+ readonly args: P;
55
+ /**
56
+ * @optional Type of the spread args at the end of the function if applicable.
57
+ */
58
+ readonly spreadArgs?: S;
59
+ }
60
+ export interface DecoratorParamDefinition<K extends TypeKind> {
61
+ /**
62
+ * Kind of the parameter
63
+ */
64
+ readonly kind: K | readonly K[];
65
+ /**
66
+ * Is the parameter optional.
67
+ */
68
+ readonly optional?: boolean;
69
+ }
70
+ type InferParameters<P extends readonly DecoratorParamDefinition<TypeKind>[], S extends DecoratorParamDefinition<TypeKind> | undefined> = S extends undefined ? InferPosParameters<P> : [...InferPosParameters<P>, ...InferSpreadParameter<S>];
71
+ type InferSpreadParameter<S extends DecoratorParamDefinition<TypeKind> | undefined> = S extends DecoratorParamDefinition<Type["kind"]> ? InferParameter<S>[] : never;
72
+ type InferPosParameters<P extends readonly DecoratorParamDefinition<TypeKind>[]> = {
73
+ [K in keyof P]: InferParameter<P[K]>;
74
+ };
75
+ type InferParameter<P extends DecoratorParamDefinition<TypeKind>> = P["optional"] extends true ? InferParameterKind<P["kind"]> | undefined : InferParameterKind<P["kind"]>;
76
+ type InferParameterKind<P extends TypeKind | readonly TypeKind[]> = P extends readonly (infer T extends TypeKind)[] ? InferredTypeSpecValue<T> : P extends TypeKind ? InferredTypeSpecValue<P> : never;
77
+ export interface DecoratorValidator<T extends TypeKind, P extends readonly DecoratorParamDefinition<TypeKind>[], S extends DecoratorParamDefinition<TypeKind> | undefined = undefined> {
78
+ validate(context: DecoratorContext, target: InferredTypeSpecValue<T>, parameters: InferParameters<P, S>): boolean;
79
+ }
80
+ export type TypeKind = Type["kind"] | "Any";
81
+ /**
82
+ * @deprecated use extern dec definition in typespec instead.
83
+ */
84
+ export declare function createDecoratorDefinition<T extends TypeKind, P extends readonly DecoratorParamDefinition<TypeKind>[], S extends DecoratorParamDefinition<TypeKind> | undefined>(definition: DecoratorDefinition<T, P, S>): DecoratorValidator<T, P, S>;
85
+ export declare function validateDecoratorParamCount(context: DecoratorContext, min: number, max: number | undefined, parameters: unknown[]): boolean;
86
+ /** @deprecated use typespecTypeToJson */
87
+ export declare const cadlTypeToJson: typeof typespecTypeToJson;
88
+ /**
89
+ * Convert a typespec type to a serializable Json object.
90
+ * Emits diagnostics if the given type is invalid
91
+ * @param typespecType The type to convert to Json data
92
+ * @param target The diagnostic target in case of errors.
93
+ */
94
+ export declare function typespecTypeToJson<T>(typespecType: TypeSpecValue, target: DiagnosticTarget): [T | undefined, Diagnostic[]];
95
+ export declare function validateDecoratorUniqueOnNode(context: DecoratorContext, type: Type, decorator: DecoratorFunction): boolean;
96
+ /**
97
+ * Validate that a given decorator is not on a type or any of its base types.
98
+ * Useful to check for decorator usage that conflicts with another decorator.
99
+ * @param context Decorator context
100
+ * @param type The type to check
101
+ * @param badDecorator The decorator we don't want present
102
+ * @param givenDecorator The decorator that is the reason why we don't want the bad decorator present
103
+ * @param includeHeritage Whether to check base types for the bad decorator too
104
+ * @returns Whether the decorator application is valid
105
+ */
106
+ export declare function validateDecoratorNotOnType(context: DecoratorContext, type: Type, badDecorator: DecoratorFunction, givenDecorator: DecoratorFunction): boolean;
107
+ export {};
108
+ //# sourceMappingURL=decorator-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorator-utils.d.ts","sourceRoot":"","sources":["../../core/decorator-utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,MAAM,EACN,IAAI,EACL,MAAM,YAAY,CAAC;AAEpB,oCAAoC;AACpC,MAAM,MAAM,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