@alloy-js/typescript 0.20.0-dev.0 → 0.20.0-dev.2

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 (318) hide show
  1. package/dist/src/builtins/index.js +2 -1
  2. package/dist/src/builtins/index.js.map +1 -0
  3. package/dist/src/builtins/node.d.ts +1 -1
  4. package/dist/src/builtins/node.js +2 -1
  5. package/dist/src/builtins/node.js.map +1 -0
  6. package/dist/src/components/ArrayExpression.js +2 -1
  7. package/dist/src/components/ArrayExpression.js.map +1 -0
  8. package/dist/src/components/ArrowFunction.d.ts.map +1 -1
  9. package/dist/src/components/ArrowFunction.js +9 -14
  10. package/dist/src/components/ArrowFunction.js.map +1 -0
  11. package/dist/src/components/BarrelFile.js +2 -1
  12. package/dist/src/components/BarrelFile.js.map +1 -0
  13. package/dist/src/components/BlockScope.d.ts.map +1 -1
  14. package/dist/src/components/BlockScope.js +5 -3
  15. package/dist/src/components/BlockScope.js.map +1 -0
  16. package/dist/src/components/CallSignature.js +2 -1
  17. package/dist/src/components/CallSignature.js.map +1 -0
  18. package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
  19. package/dist/src/components/ClassDeclaration.js +22 -31
  20. package/dist/src/components/ClassDeclaration.js.map +1 -0
  21. package/dist/src/components/CommaList.js +2 -1
  22. package/dist/src/components/CommaList.js.map +1 -0
  23. package/dist/src/components/Declaration.d.ts +2 -9
  24. package/dist/src/components/Declaration.d.ts.map +1 -1
  25. package/dist/src/components/Declaration.js +22 -44
  26. package/dist/src/components/Declaration.js.map +1 -0
  27. package/dist/src/components/EnumDeclaration.d.ts.map +1 -1
  28. package/dist/src/components/EnumDeclaration.js +7 -10
  29. package/dist/src/components/EnumDeclaration.js.map +1 -0
  30. package/dist/src/components/EnumMember.d.ts.map +1 -1
  31. package/dist/src/components/EnumMember.js +5 -5
  32. package/dist/src/components/EnumMember.js.map +1 -0
  33. package/dist/src/components/ExportStatement.d.ts.map +1 -1
  34. package/dist/src/components/ExportStatement.js +4 -2
  35. package/dist/src/components/ExportStatement.js.map +1 -0
  36. package/dist/src/components/FunctionBase.d.ts.map +1 -1
  37. package/dist/src/components/FunctionBase.js +17 -13
  38. package/dist/src/components/FunctionBase.js.map +1 -0
  39. package/dist/src/components/FunctionCallExpression.js +2 -1
  40. package/dist/src/components/FunctionCallExpression.js.map +1 -0
  41. package/dist/src/components/FunctionDeclaration.d.ts.map +1 -1
  42. package/dist/src/components/FunctionDeclaration.js +5 -4
  43. package/dist/src/components/FunctionDeclaration.js.map +1 -0
  44. package/dist/src/components/FunctionExpression.d.ts.map +1 -1
  45. package/dist/src/components/FunctionExpression.js +9 -14
  46. package/dist/src/components/FunctionExpression.js.map +1 -0
  47. package/dist/src/components/FunctionType.d.ts.map +1 -1
  48. package/dist/src/components/FunctionType.js +5 -4
  49. package/dist/src/components/FunctionType.js.map +1 -0
  50. package/dist/src/components/IfStatement.d.ts.map +1 -1
  51. package/dist/src/components/IfStatement.js +4 -2
  52. package/dist/src/components/IfStatement.js.map +1 -0
  53. package/dist/src/components/ImportStatement.d.ts.map +1 -1
  54. package/dist/src/components/ImportStatement.js +5 -5
  55. package/dist/src/components/ImportStatement.js.map +1 -0
  56. package/dist/src/components/Interface.d.ts.map +1 -1
  57. package/dist/src/components/Interface.js +16 -14
  58. package/dist/src/components/Interface.js.map +1 -0
  59. package/dist/src/components/InterfaceMethod.d.ts.map +1 -1
  60. package/dist/src/components/InterfaceMethod.js +6 -4
  61. package/dist/src/components/InterfaceMethod.js.map +1 -0
  62. package/dist/src/components/JSDoc.js +2 -1
  63. package/dist/src/components/JSDoc.js.map +1 -0
  64. package/dist/src/components/JSDocComment.js +2 -1
  65. package/dist/src/components/JSDocComment.js.map +1 -0
  66. package/dist/src/components/JSDocExample.js +2 -1
  67. package/dist/src/components/JSDocExample.js.map +1 -0
  68. package/dist/src/components/JSDocParam.js +2 -1
  69. package/dist/src/components/JSDocParam.js.map +1 -0
  70. package/dist/src/components/LexicalScope.d.ts +12 -0
  71. package/dist/src/components/LexicalScope.d.ts.map +1 -0
  72. package/dist/src/components/LexicalScope.js +25 -0
  73. package/dist/src/components/LexicalScope.js.map +1 -0
  74. package/dist/src/components/MemberDeclaration.d.ts +1 -10
  75. package/dist/src/components/MemberDeclaration.d.ts.map +1 -1
  76. package/dist/src/components/MemberDeclaration.js +5 -8
  77. package/dist/src/components/MemberDeclaration.js.map +1 -0
  78. package/dist/src/components/MemberExpression.d.ts.map +1 -1
  79. package/dist/src/components/MemberExpression.js +15 -6
  80. package/dist/src/components/MemberExpression.js.map +1 -0
  81. package/dist/src/components/MemberScope.d.ts +15 -0
  82. package/dist/src/components/MemberScope.d.ts.map +1 -0
  83. package/dist/src/components/MemberScope.js +18 -0
  84. package/dist/src/components/MemberScope.js.map +1 -0
  85. package/dist/src/components/NewExpression.d.ts.map +1 -1
  86. package/dist/src/components/NewExpression.js +7 -6
  87. package/dist/src/components/NewExpression.js.map +1 -0
  88. package/dist/src/components/ObjectExpression.d.ts.map +1 -1
  89. package/dist/src/components/ObjectExpression.js +12 -15
  90. package/dist/src/components/ObjectExpression.js.map +1 -0
  91. package/dist/src/components/PackageDirectory.js +2 -1
  92. package/dist/src/components/PackageDirectory.js.map +1 -0
  93. package/dist/src/components/PackageJson.js +2 -1
  94. package/dist/src/components/PackageJson.js.map +1 -0
  95. package/dist/src/components/PropertyName.js +3 -3
  96. package/dist/src/components/PropertyName.js.map +1 -0
  97. package/dist/src/components/Reference.js +2 -1
  98. package/dist/src/components/Reference.js.map +1 -0
  99. package/dist/src/components/SingleLineCommentBlock.js +2 -1
  100. package/dist/src/components/SingleLineCommentBlock.js.map +1 -0
  101. package/dist/src/components/SourceFile.d.ts.map +1 -1
  102. package/dist/src/components/SourceFile.js +5 -3
  103. package/dist/src/components/SourceFile.js.map +1 -0
  104. package/dist/src/components/SwitchStatement.js +2 -1
  105. package/dist/src/components/SwitchStatement.js.map +1 -0
  106. package/dist/src/components/TsConfigJson.js +2 -1
  107. package/dist/src/components/TsConfigJson.js.map +1 -0
  108. package/dist/src/components/TypeDeclaration.js +2 -1
  109. package/dist/src/components/TypeDeclaration.js.map +1 -0
  110. package/dist/src/components/TypeRefContext.js +2 -1
  111. package/dist/src/components/TypeRefContext.js.map +1 -0
  112. package/dist/src/components/ValueExpression.js +2 -1
  113. package/dist/src/components/ValueExpression.js.map +1 -0
  114. package/dist/src/components/VarDeclaration.d.ts.map +1 -1
  115. package/dist/src/components/VarDeclaration.js +16 -27
  116. package/dist/src/components/VarDeclaration.js.map +1 -0
  117. package/dist/src/components/index.js +2 -1
  118. package/dist/src/components/index.js.map +1 -0
  119. package/dist/src/components/interface/expression.test.js +2 -1
  120. package/dist/src/components/interface/expression.test.js.map +1 -0
  121. package/dist/src/components/stc/index.js +2 -1
  122. package/dist/src/components/stc/index.js.map +1 -0
  123. package/dist/src/context/index.d.ts +1 -1
  124. package/dist/src/context/index.d.ts.map +1 -1
  125. package/dist/src/context/index.js +2 -1
  126. package/dist/src/context/index.js.map +1 -0
  127. package/dist/src/context/type-ref-context.js +2 -1
  128. package/dist/src/context/type-ref-context.js.map +1 -0
  129. package/dist/src/create-package.d.ts.map +1 -1
  130. package/dist/src/create-package.js +13 -34
  131. package/dist/src/create-package.js.map +1 -0
  132. package/dist/src/index.js +2 -1
  133. package/dist/src/index.js.map +1 -0
  134. package/dist/src/name-conflict-resolver.js +2 -1
  135. package/dist/src/name-conflict-resolver.js.map +1 -0
  136. package/dist/src/name-policy.js +2 -1
  137. package/dist/src/name-policy.js.map +1 -0
  138. package/dist/src/parameter-descriptor.js +2 -1
  139. package/dist/src/parameter-descriptor.js.map +1 -0
  140. package/dist/src/source-directory-data.js +2 -1
  141. package/dist/src/source-directory-data.js.map +1 -0
  142. package/dist/src/symbols/index.d.ts +19 -0
  143. package/dist/src/symbols/index.d.ts.map +1 -1
  144. package/dist/src/symbols/index.js +73 -1
  145. package/dist/src/symbols/index.js.map +1 -0
  146. package/dist/src/symbols/reference.d.ts +2 -2
  147. package/dist/src/symbols/reference.d.ts.map +1 -1
  148. package/dist/src/symbols/reference.js +69 -70
  149. package/dist/src/symbols/reference.js.map +1 -0
  150. package/dist/src/symbols/scopes.d.ts +5 -8
  151. package/dist/src/symbols/scopes.d.ts.map +1 -1
  152. package/dist/src/symbols/scopes.js +28 -1
  153. package/dist/src/symbols/scopes.js.map +1 -0
  154. package/dist/src/symbols/ts-lexical-scope.d.ts +12 -0
  155. package/dist/src/symbols/ts-lexical-scope.d.ts.map +1 -0
  156. package/dist/src/symbols/ts-lexical-scope.js +17 -0
  157. package/dist/src/symbols/ts-lexical-scope.js.map +1 -0
  158. package/dist/src/symbols/ts-member-scope.d.ts +12 -4
  159. package/dist/src/symbols/ts-member-scope.d.ts.map +1 -1
  160. package/dist/src/symbols/ts-member-scope.js +17 -7
  161. package/dist/src/symbols/ts-member-scope.js.map +1 -0
  162. package/dist/src/symbols/ts-module-scope.d.ts +8 -3
  163. package/dist/src/symbols/ts-module-scope.d.ts.map +1 -1
  164. package/dist/src/symbols/ts-module-scope.js +31 -19
  165. package/dist/src/symbols/ts-module-scope.js.map +1 -0
  166. package/dist/src/symbols/ts-output-symbol.d.ts +19 -18
  167. package/dist/src/symbols/ts-output-symbol.d.ts.map +1 -1
  168. package/dist/src/symbols/ts-output-symbol.js +62 -38
  169. package/dist/src/symbols/ts-output-symbol.js.map +1 -0
  170. package/dist/src/symbols/ts-package-scope.d.ts +1 -1
  171. package/dist/src/symbols/ts-package-scope.d.ts.map +1 -1
  172. package/dist/src/symbols/ts-package-scope.js +6 -6
  173. package/dist/src/symbols/ts-package-scope.js.map +1 -0
  174. package/dist/src/utils.d.ts +4 -0
  175. package/dist/src/utils.d.ts.map +1 -1
  176. package/dist/src/utils.js +25 -2
  177. package/dist/src/utils.js.map +1 -0
  178. package/dist/test/array.test.js +2 -1
  179. package/dist/test/array.test.js.map +1 -0
  180. package/dist/test/arrow-function.test.js +2 -1
  181. package/dist/test/arrow-function.test.js.map +1 -0
  182. package/dist/test/barrel.test.js +26 -17
  183. package/dist/test/barrel.test.js.map +1 -0
  184. package/dist/test/basic.test.js +22 -26
  185. package/dist/test/basic.test.js.map +1 -0
  186. package/dist/test/block-scope.test.js +2 -1
  187. package/dist/test/block-scope.test.js.map +1 -0
  188. package/dist/test/class.test.js +24 -18
  189. package/dist/test/class.test.js.map +1 -0
  190. package/dist/test/enum-jsdoc.test.js +2 -1
  191. package/dist/test/enum-jsdoc.test.js.map +1 -0
  192. package/dist/test/enum.test.js +2 -1
  193. package/dist/test/enum.test.js.map +1 -0
  194. package/dist/test/externals.test.js +12 -51
  195. package/dist/test/externals.test.js.map +1 -0
  196. package/dist/test/function-call-expression.test.js +9 -8
  197. package/dist/test/function-call-expression.test.js.map +1 -0
  198. package/dist/test/function-declaration-jsdoc.test.js +2 -1
  199. package/dist/test/function-declaration-jsdoc.test.js.map +1 -0
  200. package/dist/test/function-declaration.test.js +2 -1
  201. package/dist/test/function-declaration.test.js.map +1 -0
  202. package/dist/test/function-expression.test.js +2 -1
  203. package/dist/test/function-expression.test.js.map +1 -0
  204. package/dist/test/function-type.test.js +2 -1
  205. package/dist/test/function-type.test.js.map +1 -0
  206. package/dist/test/if-statement.test.js +2 -1
  207. package/dist/test/if-statement.test.js.map +1 -0
  208. package/dist/test/imports.test.d.ts.map +1 -1
  209. package/dist/test/imports.test.js +62 -60
  210. package/dist/test/imports.test.js.map +1 -0
  211. package/dist/test/interface-jsdoc.test.js +2 -1
  212. package/dist/test/interface-jsdoc.test.js.map +1 -0
  213. package/dist/test/interface.test.js +2 -1
  214. package/dist/test/interface.test.js.map +1 -0
  215. package/dist/test/jscomment.test.js +2 -1
  216. package/dist/test/jscomment.test.js.map +1 -0
  217. package/dist/test/jsdoc.test.js +2 -1
  218. package/dist/test/jsdoc.test.js.map +1 -0
  219. package/dist/test/jsdocparam.test.js +2 -1
  220. package/dist/test/jsdocparam.test.js.map +1 -0
  221. package/dist/test/member-expression.test.js +8 -7
  222. package/dist/test/member-expression.test.js.map +1 -0
  223. package/dist/test/name-conflict.test.js +5 -7
  224. package/dist/test/name-conflict.test.js.map +1 -0
  225. package/dist/test/name-policy.test.js +9 -13
  226. package/dist/test/name-policy.test.js.map +1 -0
  227. package/dist/test/new-expression.test.js +6 -7
  228. package/dist/test/new-expression.test.js.map +1 -0
  229. package/dist/test/object.test.js +2 -1
  230. package/dist/test/object.test.js.map +1 -0
  231. package/dist/test/package-external.test.js +71 -66
  232. package/dist/test/package-external.test.js.map +1 -0
  233. package/dist/test/package-json.test.js +8 -10
  234. package/dist/test/package-json.test.js.map +1 -0
  235. package/dist/test/package.test.js +12 -12
  236. package/dist/test/package.test.js.map +1 -0
  237. package/dist/test/reference.test.js +10 -12
  238. package/dist/test/reference.test.js.map +1 -0
  239. package/dist/test/source-file.test.js +7 -10
  240. package/dist/test/source-file.test.js.map +1 -0
  241. package/dist/test/switch-statement.test.js +2 -1
  242. package/dist/test/switch-statement.test.js.map +1 -0
  243. package/dist/test/utils.js +6 -2
  244. package/dist/test/utils.js.map +1 -0
  245. package/dist/test/value-expression.test.js +2 -1
  246. package/dist/test/value-expression.test.js.map +1 -0
  247. package/dist/test/values.test.d.ts.map +1 -1
  248. package/dist/test/values.test.js +11 -8
  249. package/dist/test/values.test.js.map +1 -0
  250. package/dist/test/var-declaration-jsdoc.test.js +2 -1
  251. package/dist/test/var-declaration-jsdoc.test.js.map +1 -0
  252. package/dist/test/var-declaration.test.d.ts.map +1 -1
  253. package/dist/test/var-declaration.test.js +21 -12
  254. package/dist/test/var-declaration.test.js.map +1 -0
  255. package/dist/test/vitest.setup.js +2 -1
  256. package/dist/test/vitest.setup.js.map +1 -0
  257. package/dist/tsconfig.tsbuildinfo +1 -1
  258. package/package.json +4 -4
  259. package/src/components/ArrowFunction.tsx +7 -10
  260. package/src/components/BlockScope.tsx +3 -3
  261. package/src/components/ClassDeclaration.tsx +19 -44
  262. package/src/components/Declaration.tsx +22 -53
  263. package/src/components/EnumDeclaration.tsx +4 -11
  264. package/src/components/EnumMember.tsx +3 -3
  265. package/src/components/ExportStatement.tsx +2 -1
  266. package/src/components/FunctionBase.tsx +33 -28
  267. package/src/components/FunctionDeclaration.tsx +3 -3
  268. package/src/components/FunctionExpression.tsx +7 -10
  269. package/src/components/FunctionType.tsx +3 -3
  270. package/src/components/IfStatement.tsx +2 -1
  271. package/src/components/ImportStatement.tsx +4 -8
  272. package/src/components/Interface.tsx +15 -22
  273. package/src/components/InterfaceMethod.tsx +4 -4
  274. package/src/components/LexicalScope.tsx +27 -0
  275. package/src/components/MemberDeclaration.tsx +8 -20
  276. package/src/components/MemberExpression.tsx +25 -5
  277. package/src/components/MemberScope.tsx +29 -0
  278. package/src/components/NewExpression.tsx +4 -5
  279. package/src/components/ObjectExpression.tsx +11 -18
  280. package/src/components/PropertyName.tsx +2 -2
  281. package/src/components/SourceFile.tsx +3 -1
  282. package/src/components/VarDeclaration.tsx +14 -28
  283. package/src/context/index.ts +1 -1
  284. package/src/create-package.ts +10 -39
  285. package/src/symbols/index.ts +118 -0
  286. package/src/symbols/reference.tsx +163 -0
  287. package/src/symbols/scopes.ts +38 -13
  288. package/src/symbols/ts-lexical-scope.ts +18 -0
  289. package/src/symbols/ts-member-scope.ts +23 -6
  290. package/src/symbols/ts-module-scope.ts +31 -21
  291. package/src/symbols/ts-output-symbol.ts +111 -49
  292. package/src/symbols/ts-package-scope.ts +5 -5
  293. package/src/utils.ts +38 -1
  294. package/temp/api.json +1641 -713
  295. package/test/barrel.test.tsx +24 -18
  296. package/test/basic.test.tsx +20 -29
  297. package/test/class.test.tsx +28 -18
  298. package/test/externals.test.tsx +10 -57
  299. package/test/function-call-expression.test.tsx +6 -7
  300. package/test/imports.test.tsx +57 -74
  301. package/test/member-expression.test.tsx +5 -13
  302. package/test/name-conflict.test.tsx +4 -7
  303. package/test/name-policy.test.tsx +7 -15
  304. package/test/new-expression.test.tsx +4 -7
  305. package/test/package-external.test.tsx +69 -73
  306. package/test/package-json.test.tsx +6 -11
  307. package/test/package.test.tsx +8 -11
  308. package/test/reference.test.tsx +10 -15
  309. package/test/source-file.test.tsx +5 -11
  310. package/test/utils.tsx +1 -1
  311. package/test/values.test.tsx +8 -8
  312. package/test/var-declaration.test.tsx +19 -20
  313. package/tsdoc-metadata.json +1 -1
  314. package/dist/src/context/private-scope.d.ts +0 -18
  315. package/dist/src/context/private-scope.d.ts.map +0 -1
  316. package/dist/src/context/private-scope.js +0 -8
  317. package/src/context/private-scope.ts +0 -23
  318. package/src/symbols/reference.ts +0 -197
@@ -1,12 +1,11 @@
1
- import { Output, render, SourceDirectory, SourceFile } from "@alloy-js/core";
1
+ import { Output, SourceDirectory, SourceFile } from "@alloy-js/core";
2
2
  import "@alloy-js/core/testing";
3
3
  import { d } from "@alloy-js/core/testing";
4
4
  import { expect, it } from "vitest";
5
5
  import * as ts from "../src/components/index.js";
6
- import { findFile } from "./utils.jsx";
7
6
 
8
7
  it("exports everything from source files within it", () => {
9
- const res = render(
8
+ expect(
10
9
  <Output>
11
10
  <ts.SourceFile path="test1.ts" />
12
11
  <ts.SourceFile path="test2.ts" />
@@ -17,31 +16,38 @@ it("exports everything from source files within it", () => {
17
16
  </SourceDirectory>
18
17
  <ts.BarrelFile />
19
18
  </Output>,
20
- );
21
- expect(findFile(res, "components/index.ts").contents).toBe(d`
22
- export * from "./c1.js";
23
- export * from "./c2.js";
24
- `);
25
-
26
- expect(findFile(res, "index.ts").contents).toBe(d`
19
+ ).toRenderTo({
20
+ "components/index.ts": d`
21
+ export * from "./c1.js";
22
+ export * from "./c2.js";
23
+ `,
24
+ "index.ts": d`
27
25
  export * from "./test1.js";
28
26
  export * from "./test2.js";
29
27
  export * from "./components/index.js";
30
- `);
28
+ `,
29
+ "components/c2.ts": "",
30
+ "components/c1.ts": "",
31
+ "test1.ts": "",
32
+ "test2.ts": "",
33
+ });
31
34
  });
32
35
 
33
36
  it("ignores non-TS files", () => {
34
- const res = render(
37
+ expect(
35
38
  <Output>
36
39
  <SourceFile path="test.txt" filetype="text" />
37
40
  <ts.SourceFile path="test1.ts" />
38
41
  <ts.SourceFile path="test2.ts" />
39
42
  <ts.BarrelFile />
40
43
  </Output>,
41
- );
42
-
43
- expect(findFile(res, "index.ts").contents).toBe(d`
44
- export * from "./test1.js";
45
- export * from "./test2.js";
46
- `);
44
+ ).toRenderTo({
45
+ "index.ts": d`
46
+ export * from "./test1.js";
47
+ export * from "./test2.js";
48
+ `,
49
+ "test.txt": "",
50
+ "test1.ts": "",
51
+ "test2.ts": "",
52
+ });
47
53
  });
@@ -1,10 +1,8 @@
1
- import { List, Output, refkey, render, SourceFile } from "@alloy-js/core";
1
+ import { List, Output, refkey, SourceFile } from "@alloy-js/core";
2
2
  import "@alloy-js/core/testing";
3
- import { d } from "@alloy-js/core/testing";
4
3
  import { expect, it } from "vitest";
5
4
  import * as ts from "../src/components/index.js";
6
5
  import { Reference } from "../src/components/Reference.js";
7
- import { findFile } from "./utils.js";
8
6
 
9
7
  it("works", () => {
10
8
  const fnSpec = {
@@ -15,7 +13,7 @@ it("works", () => {
15
13
  const greetKey = refkey(fnSpec, "greet");
16
14
  const farewellKey = refkey(fnSpec, "farewell");
17
15
 
18
- const res = render(
16
+ expect(
19
17
  <Output>
20
18
  <SourceFile path="readme.md" filetype="markdown">
21
19
  This is a sample output project.
@@ -55,29 +53,22 @@ it("works", () => {
55
53
  </List>
56
54
  </ts.SourceFile>
57
55
  </Output>,
58
- );
59
-
60
- expect(findFile(res, "readme.md").contents).toEqual(d`
61
- This is a sample output project.
62
- `);
63
-
64
- expect(findFile(res, "index.ts").contents).toEqual(d`
65
- console.log("Hello world!");
66
- `);
67
-
68
- expect(findFile(res, "test1.ts").contents).toEqual(d`
69
- function sayHello(str: string) {
70
- return "Hello " + str;
71
- }
72
- function sayGoodbye(str: string) {
73
- return "Goodbye " + str;
74
- }
75
- `);
76
-
77
- expect(findFile(res, "test2.ts").contents).toEqual(d`
78
- import { sayGoodbye, sayHello } from "./test1.js";
79
-
80
- console.log(sayHello("world"));
81
- console.log(sayGoodbye("world"));
82
- `);
56
+ ).toRenderTo({
57
+ "readme.md": `This is a sample output project.`,
58
+ "index.ts": `console.log("Hello world!");`,
59
+ "test1.ts": `
60
+ function sayHello(str: string) {
61
+ return "Hello " + str;
62
+ }
63
+ function sayGoodbye(str: string) {
64
+ return "Goodbye " + str;
65
+ }
66
+ `,
67
+ "test2.ts": `
68
+ import { sayGoodbye, sayHello } from "./test1.js";
69
+
70
+ console.log(sayHello("world"));
71
+ console.log(sayGoodbye("world"));
72
+ `,
73
+ });
83
74
  });
@@ -1,9 +1,9 @@
1
- import { List, Output, refkey, render, StatementList } from "@alloy-js/core";
1
+ import { List, Output, refkey, StatementList } from "@alloy-js/core";
2
2
  import "@alloy-js/core/testing";
3
3
  import { d } from "@alloy-js/core/testing";
4
4
  import { describe, expect, it } from "vitest";
5
5
  import * as ts from "../src/components/index.js";
6
- import { findFile, toSourceText } from "./utils.js";
6
+ import { toSourceText } from "./utils.js";
7
7
 
8
8
  it("declares classes", () => {
9
9
  const res = toSourceText(<ts.ClassDeclaration name="Foo" />);
@@ -102,7 +102,9 @@ describe("instance members", () => {
102
102
  {one}
103
103
  </>,
104
104
  );
105
- }).toThrow(/Cannot resolve member symbols/);
105
+ }).toThrow(
106
+ /Cannot reference instance member 'one' without an instance of 'Foo'/,
107
+ );
106
108
  });
107
109
 
108
110
  it("cannot be referenced outside the class when protected", () => {
@@ -120,7 +122,9 @@ describe("instance members", () => {
120
122
  {one}
121
123
  </>,
122
124
  );
123
- }).toThrow(/Cannot resolve member symbols/);
125
+ }).toThrow(
126
+ /Cannot reference instance member 'one' without an instance of 'Foo'/,
127
+ );
124
128
  });
125
129
 
126
130
  it("cannot be referenced outside the class when private", () => {
@@ -138,7 +142,9 @@ describe("instance members", () => {
138
142
  {one}
139
143
  </>,
140
144
  );
141
- }).toThrow(/Cannot resolve private member symbols/);
145
+ }).toThrow(
146
+ /Cannot reference instance member 'one' without an instance of 'Foo'/,
147
+ );
142
148
  });
143
149
 
144
150
  it("works with invalid identifier names", () => {
@@ -194,7 +200,7 @@ describe("instance members", () => {
194
200
  it("doesn't conflict with imports from other files", () => {
195
201
  const rk1 = refkey();
196
202
  const rk2 = refkey();
197
- const tree = render(
203
+ expect(
198
204
  <Output
199
205
  nameConflictResolver={() => {
200
206
  // do nothing
@@ -220,18 +226,22 @@ describe("instance members", () => {
220
226
  </ts.ClassDeclaration>
221
227
  </ts.SourceFile>
222
228
  </Output>,
223
- );
224
-
225
- expect(findFile(tree, "ref.ts").contents).toEqual(d`
226
- import { one, two } from "./decl.js";
229
+ ).toRenderTo({
230
+ "decl.ts": `
231
+ export const one = 1;
232
+ export const two = 2;
233
+ `,
234
+ "ref.ts": `
235
+ import { one, two } from "./decl.js";
227
236
 
228
- class Foo {
229
- one = one;
230
- two() {
231
- two
232
- };
233
- }
234
- `);
237
+ class Foo {
238
+ one = one;
239
+ two() {
240
+ two
241
+ };
242
+ }
243
+ `,
244
+ });
235
245
  });
236
246
  });
237
247
 
@@ -310,7 +320,7 @@ describe("static members", () => {
310
320
  {two};
311
321
  </>,
312
322
  ),
313
- ).toThrow(/Cannot resolve/);
323
+ ).toThrow(/Cannot reference/);
314
324
  });
315
325
  });
316
326
 
@@ -1,4 +1,4 @@
1
- import { Output, render } from "@alloy-js/core";
1
+ import { Output } from "@alloy-js/core";
2
2
  import { expect, it } from "vitest";
3
3
  import { fs } from "../src/builtins/node.js";
4
4
  import {
@@ -6,9 +6,7 @@ import {
6
6
  FunctionDeclaration,
7
7
  PackageDirectory,
8
8
  SourceFile,
9
- TSOutputSymbol,
10
9
  } from "../src/index.js";
11
- import { assertFileContents } from "./utils.js";
12
10
 
13
11
  it("can import builtins", () => {
14
12
  const testLib = createPackage({
@@ -25,7 +23,7 @@ it("can import builtins", () => {
25
23
  },
26
24
  });
27
25
 
28
- const res = render(
26
+ expect(
29
27
  <Output externals={[testLib, fs]}>
30
28
  <PackageDirectory path="." name="test" version="1.0.0">
31
29
  <SourceFile path="index.ts">
@@ -34,9 +32,7 @@ it("can import builtins", () => {
34
32
  </SourceFile>
35
33
  </PackageDirectory>
36
34
  </Output>,
37
- );
38
-
39
- assertFileContents(res, {
35
+ ).toRenderTo({
40
36
  "package.json": `
41
37
  {
42
38
  "name": "test",
@@ -50,6 +46,7 @@ it("can import builtins", () => {
50
46
  }
51
47
  }
52
48
  `,
49
+ "tsconfig.json": expect.anything(),
53
50
  "index.ts": `
54
51
  import { readFile } from "node:fs/promises";
55
52
  import { nice } from "testLib/subpath";
@@ -75,16 +72,14 @@ it("can import builtins without a package", () => {
75
72
  },
76
73
  });
77
74
 
78
- const res = render(
75
+ expect(
79
76
  <Output externals={[testLib, fs]}>
80
77
  <SourceFile path="index.ts">
81
78
  {testLib["./subpath"].nice};<hbr />
82
79
  await {fs["./promises"].readFile}();
83
80
  </SourceFile>
84
81
  </Output>,
85
- );
86
-
87
- assertFileContents(res, {
82
+ ).toRenderTo({
88
83
  "index.ts": `
89
84
  import { readFile } from "node:fs/promises";
90
85
  import { nice } from "testLib/subpath";
@@ -110,7 +105,7 @@ it("can import builtins without a package", () => {
110
105
  },
111
106
  });
112
107
 
113
- const res = render(
108
+ expect(
114
109
  <Output externals={[testLib, fs]}>
115
110
  <SourceFile path="index.ts">
116
111
  <FunctionDeclaration name="foo">
@@ -121,9 +116,7 @@ it("can import builtins without a package", () => {
121
116
  </FunctionDeclaration>
122
117
  </SourceFile>
123
118
  </Output>,
124
- );
125
-
126
- assertFileContents(res, {
119
+ ).toRenderTo({
127
120
  "index.ts": `
128
121
  import { readFile } from "node:fs/promises";
129
122
  import { nice } from "testLib/subpath";
@@ -160,7 +153,7 @@ it("can import static members", () => {
160
153
  },
161
154
  });
162
155
 
163
- const res = render(
156
+ expect(
164
157
  <Output externals={[mcpSdk]}>
165
158
  <SourceFile path="index.ts">
166
159
  <FunctionDeclaration name="foo">
@@ -180,9 +173,7 @@ it("can import static members", () => {
180
173
  </FunctionDeclaration>
181
174
  </SourceFile>
182
175
  </Output>,
183
- );
184
-
185
- assertFileContents(res, {
176
+ ).toRenderTo({
186
177
  "index.ts": `
187
178
  import { noMembers, server, simpleName } from "@modelcontextprotocol/sdk/server/index.js";
188
179
 
@@ -196,41 +187,3 @@ it("can import static members", () => {
196
187
  `,
197
188
  });
198
189
  });
199
-
200
- it("can import instance members", () => {
201
- const mcpSdk = createPackage({
202
- name: "@modelcontextprotocol/sdk",
203
- version: "^3.23.0",
204
- descriptor: {
205
- "./server/index.js": {
206
- named: [{ name: "Server", instanceMembers: ["instanceHandler"] }],
207
- },
208
- },
209
- });
210
-
211
- function RunTest() {
212
- const sym = new TSOutputSymbol("foo");
213
- const binder = sym.binder!;
214
-
215
- expect(binder).toBeDefined();
216
-
217
- const source = binder.getSymbolForRefkey(
218
- mcpSdk["./server/index.js"].Server,
219
- ).value!;
220
- expect(source).toBeDefined();
221
- expect(source.instanceMemberScope?.symbols.size).toBe(1);
222
-
223
- source.instantiateTo(sym);
224
-
225
- expect(sym.staticMemberScope?.symbols.size).toBe(1);
226
- expect([...sym.staticMemberScope!.symbols][0].name).toBe("instanceHandler");
227
- }
228
-
229
- render(
230
- <Output externals={[mcpSdk]}>
231
- <SourceFile path="index.ts">
232
- <RunTest />
233
- </SourceFile>
234
- </Output>,
235
- );
236
- });
@@ -1,5 +1,5 @@
1
- import { Output, refkey, render, StatementList } from "@alloy-js/core";
2
- import { it } from "vitest";
1
+ import { Output, refkey, StatementList } from "@alloy-js/core";
2
+ import { expect, it } from "vitest";
3
3
  import {
4
4
  FunctionCallExpression,
5
5
  FunctionDeclaration,
@@ -7,11 +7,10 @@ import {
7
7
  SourceFile,
8
8
  VarDeclaration,
9
9
  } from "../../typescript/src/index.js";
10
- import { assertFileContents } from "./utils.js";
11
10
 
12
11
  it("can declare and call a function with parameters", () => {
13
12
  const functionRefkey = refkey();
14
- const res = render(
13
+ expect(
15
14
  <Output>
16
15
  <PackageDirectory path="." name="test" version="1.0.0">
17
16
  <SourceFile path="index.ts">
@@ -53,9 +52,7 @@ it("can declare and call a function with parameters", () => {
53
52
  </SourceFile>
54
53
  </PackageDirectory>
55
54
  </Output>,
56
- );
57
-
58
- assertFileContents(res, {
55
+ ).toRenderTo({
59
56
  "index.ts": `
60
57
  const foo = "Foo";
61
58
  function bar(foo?: string, baz?: number) {
@@ -69,5 +66,7 @@ it("can declare and call a function with parameters", () => {
69
66
  bar("Hey there!");
70
67
  bar("Hello World", 12345);
71
68
  `,
69
+ "package.json": expect.anything(),
70
+ "tsconfig.json": expect.anything(),
72
71
  });
73
72
  });