@alloy-js/typescript 0.4.0 → 0.6.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 (170) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/src/components/ArrayExpression.d.ts +1 -1
  3. package/dist/src/components/ArrayExpression.d.ts.map +1 -1
  4. package/dist/src/components/ArrayExpression.js +18 -28
  5. package/dist/src/components/ArrayExpression.js.map +1 -1
  6. package/dist/src/components/BarrelFile.d.ts +1 -1
  7. package/dist/src/components/BarrelFile.d.ts.map +1 -1
  8. package/dist/src/components/BarrelFile.js +11 -9
  9. package/dist/src/components/BarrelFile.js.map +1 -1
  10. package/dist/src/components/ClassDeclaration.d.ts +4 -4
  11. package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
  12. package/dist/src/components/ClassDeclaration.js +8 -9
  13. package/dist/src/components/ClassDeclaration.js.map +1 -1
  14. package/dist/src/components/CommaList.d.ts +12 -0
  15. package/dist/src/components/CommaList.d.ts.map +1 -0
  16. package/dist/src/components/CommaList.js +19 -0
  17. package/dist/src/components/CommaList.js.map +1 -0
  18. package/dist/src/components/Declaration.d.ts +1 -1
  19. package/dist/src/components/Declaration.d.ts.map +1 -1
  20. package/dist/src/components/Declaration.js.map +1 -1
  21. package/dist/src/components/EnumDeclaration.d.ts +1 -1
  22. package/dist/src/components/EnumDeclaration.d.ts.map +1 -1
  23. package/dist/src/components/EnumDeclaration.js +19 -17
  24. package/dist/src/components/EnumDeclaration.js.map +1 -1
  25. package/dist/src/components/EnumMember.d.ts +1 -1
  26. package/dist/src/components/EnumMember.d.ts.map +1 -1
  27. package/dist/src/components/EnumMember.js.map +1 -1
  28. package/dist/src/components/ExportStatement.d.ts +1 -1
  29. package/dist/src/components/ExportStatement.d.ts.map +1 -1
  30. package/dist/src/components/ExportStatement.js.map +1 -1
  31. package/dist/src/components/FunctionCallExpression.d.ts +3 -3
  32. package/dist/src/components/FunctionCallExpression.d.ts.map +1 -1
  33. package/dist/src/components/FunctionCallExpression.js +26 -9
  34. package/dist/src/components/FunctionCallExpression.js.map +1 -1
  35. package/dist/src/components/FunctionDeclaration.d.ts +9 -2
  36. package/dist/src/components/FunctionDeclaration.d.ts.map +1 -1
  37. package/dist/src/components/FunctionDeclaration.js +135 -33
  38. package/dist/src/components/FunctionDeclaration.js.map +1 -1
  39. package/dist/src/components/ImportStatement.d.ts +1 -1
  40. package/dist/src/components/ImportStatement.d.ts.map +1 -1
  41. package/dist/src/components/ImportStatement.js +25 -31
  42. package/dist/src/components/ImportStatement.js.map +1 -1
  43. package/dist/src/components/Interface.d.ts +3 -3
  44. package/dist/src/components/Interface.d.ts.map +1 -1
  45. package/dist/src/components/Interface.js +5 -5
  46. package/dist/src/components/Interface.js.map +1 -1
  47. package/dist/src/components/JSDoc.d.ts +10 -0
  48. package/dist/src/components/JSDoc.d.ts.map +1 -0
  49. package/dist/src/components/JSDoc.js +24 -0
  50. package/dist/src/components/JSDoc.js.map +1 -0
  51. package/dist/src/components/JSDocComment.d.ts +11 -0
  52. package/dist/src/components/JSDocComment.d.ts.map +1 -0
  53. package/dist/src/components/JSDocComment.js +16 -0
  54. package/dist/src/components/JSDocComment.js.map +1 -0
  55. package/dist/src/components/JSDocExample.d.ts +12 -0
  56. package/dist/src/components/JSDocExample.d.ts.map +1 -0
  57. package/dist/src/components/JSDocExample.js +26 -0
  58. package/dist/src/components/JSDocExample.js.map +1 -0
  59. package/dist/src/components/JSDocParagraph.d.ts +10 -0
  60. package/dist/src/components/JSDocParagraph.d.ts.map +1 -0
  61. package/dist/src/components/JSDocParagraph.js +23 -0
  62. package/dist/src/components/JSDocParagraph.js.map +1 -0
  63. package/dist/src/components/MemberChainExpression.d.ts +11 -0
  64. package/dist/src/components/MemberChainExpression.d.ts.map +1 -0
  65. package/dist/src/components/MemberChainExpression.js +64 -0
  66. package/dist/src/components/MemberChainExpression.js.map +1 -0
  67. package/dist/src/components/ObjectExpression.d.ts +2 -2
  68. package/dist/src/components/ObjectExpression.d.ts.map +1 -1
  69. package/dist/src/components/ObjectExpression.js +45 -42
  70. package/dist/src/components/ObjectExpression.js.map +1 -1
  71. package/dist/src/components/PackageDirectory.d.ts +1 -1
  72. package/dist/src/components/PackageDirectory.d.ts.map +1 -1
  73. package/dist/src/components/PackageDirectory.js +1 -1
  74. package/dist/src/components/PackageDirectory.js.map +1 -1
  75. package/dist/src/components/PackageJson.d.ts +1 -1
  76. package/dist/src/components/PackageJson.d.ts.map +1 -1
  77. package/dist/src/components/PackageJson.js.map +1 -1
  78. package/dist/src/components/Reference.d.ts +1 -1
  79. package/dist/src/components/Reference.d.ts.map +1 -1
  80. package/dist/src/components/Reference.js +1 -1
  81. package/dist/src/components/Reference.js.map +1 -1
  82. package/dist/src/components/SourceFile.d.ts +1 -1
  83. package/dist/src/components/SourceFile.d.ts.map +1 -1
  84. package/dist/src/components/SourceFile.js +13 -6
  85. package/dist/src/components/SourceFile.js.map +1 -1
  86. package/dist/src/components/TsConfigJson.d.ts +1 -1
  87. package/dist/src/components/TsConfigJson.d.ts.map +1 -1
  88. package/dist/src/components/TsConfigJson.js.map +1 -1
  89. package/dist/src/components/TypeDeclaration.d.ts +1 -1
  90. package/dist/src/components/TypeDeclaration.d.ts.map +1 -1
  91. package/dist/src/components/TypeDeclaration.js.map +1 -1
  92. package/dist/src/components/ValueExpression.d.ts +2 -1
  93. package/dist/src/components/ValueExpression.d.ts.map +1 -1
  94. package/dist/src/components/ValueExpression.js.map +1 -1
  95. package/dist/src/components/VarDeclaration.d.ts +1 -1
  96. package/dist/src/components/VarDeclaration.d.ts.map +1 -1
  97. package/dist/src/components/VarDeclaration.js +2 -2
  98. package/dist/src/components/VarDeclaration.js.map +1 -1
  99. package/dist/src/components/index.d.ts +2 -1
  100. package/dist/src/components/index.d.ts.map +1 -1
  101. package/dist/src/components/index.js +2 -1
  102. package/dist/src/components/index.js.map +1 -1
  103. package/dist/src/components/stc/index.d.ts +21 -21
  104. package/dist/src/components/stc/index.d.ts.map +1 -1
  105. package/dist/src/components/stc/index.js +1 -1
  106. package/dist/src/components/stc/index.js.map +1 -1
  107. package/dist/test/imports.test.d.ts.map +1 -1
  108. package/dist/test/jsdoc.test.d.ts +2 -0
  109. package/dist/test/jsdoc.test.d.ts.map +1 -0
  110. package/dist/test/member-chain.test.d.ts +2 -0
  111. package/dist/test/member-chain.test.d.ts.map +1 -0
  112. package/dist/test/utils.d.ts +2 -2
  113. package/dist/test/utils.d.ts.map +1 -1
  114. package/dist/test/values.test.d.ts.map +1 -1
  115. package/dist/tsconfig.tsbuildinfo +1 -1
  116. package/package.json +4 -6
  117. package/src/components/ArrayExpression.tsx +18 -32
  118. package/src/components/BarrelFile.tsx +7 -13
  119. package/src/components/ClassDeclaration.tsx +33 -28
  120. package/src/components/CommaList.tsx +23 -0
  121. package/src/components/Declaration.tsx +7 -3
  122. package/src/components/EnumDeclaration.tsx +21 -14
  123. package/src/components/EnumMember.tsx +7 -4
  124. package/src/components/ExportStatement.tsx +6 -1
  125. package/src/components/FunctionCallExpression.tsx +18 -9
  126. package/src/components/FunctionDeclaration.tsx +170 -55
  127. package/src/components/ImportStatement.tsx +6 -9
  128. package/src/components/Interface.tsx +20 -13
  129. package/src/components/JSDoc.tsx +28 -0
  130. package/src/components/JSDocComment.tsx +23 -0
  131. package/src/components/JSDocExample.tsx +30 -0
  132. package/src/components/JSDocParagraph.tsx +35 -0
  133. package/src/components/MemberChainExpression.tsx +59 -0
  134. package/src/components/ObjectExpression.tsx +53 -48
  135. package/src/components/PackageDirectory.tsx +11 -9
  136. package/src/components/PackageJson.tsx +9 -6
  137. package/src/components/SourceFile.tsx +15 -8
  138. package/src/components/TsConfigJson.tsx +5 -3
  139. package/src/components/TypeDeclaration.tsx +5 -3
  140. package/src/components/ValueExpression.tsx +7 -5
  141. package/src/components/VarDeclaration.tsx +11 -5
  142. package/src/components/index.ts +2 -1
  143. package/src/components/stc/index.ts +1 -1
  144. package/temp/api.json +618 -208
  145. package/test/array.test.tsx +28 -7
  146. package/test/basic.test.tsx +26 -21
  147. package/test/class.test.tsx +65 -53
  148. package/test/enum.test.tsx +18 -13
  149. package/test/externals.test.tsx +6 -7
  150. package/test/function-call-expression.test.tsx +39 -17
  151. package/test/function-declaration.test.tsx +96 -78
  152. package/test/imports.test.tsx +90 -65
  153. package/test/interface.test.tsx +29 -19
  154. package/test/jsdoc.test.tsx +154 -0
  155. package/test/member-chain.test.tsx +47 -0
  156. package/test/name-policy.test.tsx +33 -26
  157. package/test/package-external.test.tsx +8 -4
  158. package/test/package.test.tsx +1 -2
  159. package/test/reference.test.tsx +2 -6
  160. package/test/utils.tsx +3 -1
  161. package/test/value-expression.test.tsx +2 -6
  162. package/test/values.test.tsx +67 -73
  163. package/test/var-declaration.test.tsx +11 -5
  164. package/test/vitest.d.ts +6 -1
  165. package/tsconfig.json +8 -1
  166. package/dist/src/components/Block.d.ts +0 -6
  167. package/dist/src/components/Block.d.ts.map +0 -1
  168. package/dist/src/components/Block.js +0 -11
  169. package/dist/src/components/Block.js.map +0 -1
  170. package/src/components/Block.tsx +0 -12
@@ -4,11 +4,32 @@ import { ArrayExpression } from "../src/index.js";
4
4
  import { toSourceText } from "./utils.js";
5
5
 
6
6
  it("works", () => {
7
- expect(toSourceText(<ArrayExpression jsValue={[1,2,3]} />)).toBe(d`
8
- [
9
- 1,
10
- 2,
11
- 3
12
- ]
13
- `);
7
+ expect(toSourceText(<ArrayExpression jsValue={[1, 2, 3]} />)).toBe(d`
8
+ [1, 2, 3]
9
+ `);
10
+
11
+ expect(
12
+ toSourceText(<ArrayExpression jsValue={[1, 2, 3, "foo".repeat(10)]} />, {
13
+ printWidth: 20,
14
+ }),
15
+ ).toBe(d`
16
+ [
17
+ 1,
18
+ 2,
19
+ 3,
20
+ "foofoofoofoofoofoofoofoofoofoo"
21
+ ]
22
+ `);
23
+ });
24
+
25
+ it("accepts children", () => {
26
+ expect(
27
+ toSourceText(
28
+ <ArrayExpression jsValue={[1, 2, 3]}>
29
+ <ArrayExpression jsValue={[4, 5, 6]} />
30
+ </ArrayExpression>,
31
+ ),
32
+ ).toBe(d`
33
+ [1, 2, 3, [4, 5, 6]]
34
+ `);
14
35
  });
@@ -1,4 +1,4 @@
1
- import { Output, refkey, render, SourceFile } from "@alloy-js/core";
1
+ import { List, Output, refkey, render, 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";
@@ -24,30 +24,36 @@ it("works", () => {
24
24
  <ts.SourceFile path="index.ts">
25
25
  console.log("Hello world!");
26
26
  </ts.SourceFile>
27
-
27
+
28
28
  <ts.SourceFile path="test2.ts">
29
- console.log(<Reference refkey={greetKey} />("world"));
30
- console.log(<Reference refkey={farewellKey} />("world"));
29
+ console.log(
30
+ <Reference refkey={greetKey} />
31
+ ("world"));
32
+ <hbr />
33
+ console.log(
34
+ <Reference refkey={farewellKey} />
35
+ ("world"));
31
36
  </ts.SourceFile>
32
37
 
33
38
  <ts.SourceFile path="test1.ts">
34
- <ts.FunctionDeclaration
35
- name={"say" + fnSpec.greeting}
36
- refkey={greetKey}
37
- parameters={{str: "string"}}
38
- >
39
- return "{fnSpec.greeting} " + str;
40
- </ts.FunctionDeclaration>
39
+ <List hardline>
40
+ <ts.FunctionDeclaration
41
+ name={"say" + fnSpec.greeting}
42
+ refkey={greetKey}
43
+ parameters={{ str: "string" }}
44
+ >
45
+ return "{fnSpec.greeting} " + str;
46
+ </ts.FunctionDeclaration>
41
47
 
42
- <ts.FunctionDeclaration
43
- name={"say" + fnSpec.farewell}
44
- refkey={farewellKey}
45
- parameters={{str: "string"}}
46
- >
47
- return "{fnSpec.farewell} " + str;
48
- </ts.FunctionDeclaration>
48
+ <ts.FunctionDeclaration
49
+ name={"say" + fnSpec.farewell}
50
+ refkey={farewellKey}
51
+ parameters={{ str: "string" }}
52
+ >
53
+ return "{fnSpec.farewell} " + str;
54
+ </ts.FunctionDeclaration>
55
+ </List>
49
56
  </ts.SourceFile>
50
-
51
57
  </Output>,
52
58
  );
53
59
 
@@ -63,7 +69,6 @@ it("works", () => {
63
69
  function sayHello(str: string) {
64
70
  return "Hello " + str;
65
71
  }
66
-
67
72
  function sayGoodbye(str: string) {
68
73
  return "Goodbye " + str;
69
74
  }
@@ -71,7 +76,7 @@ it("works", () => {
71
76
 
72
77
  expect(findFile(res, "test2.ts").contents).toEqual(d`
73
78
  import { sayHello, sayGoodbye } from "./test1.js";
74
-
79
+
75
80
  console.log(sayHello("world"));
76
81
  console.log(sayGoodbye("world"));
77
82
  `);
@@ -1,25 +1,22 @@
1
- import { refkey } from "@alloy-js/core";
1
+ import { List, refkey } 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
+ import { StatementList } from "../../core/src/components/StatementList.jsx";
5
6
  import * as ts from "../src/components/index.js";
6
7
  import { toSourceText } from "./utils.js";
7
8
 
8
9
  it("declares classes", () => {
9
10
  const res = toSourceText(<ts.ClassDeclaration name="Foo" />);
10
11
  expect(res).toEqual(d`
11
- class Foo {
12
-
13
- }
12
+ class Foo {}
14
13
  `);
15
14
  });
16
15
 
17
16
  it("accepts export and default", () => {
18
17
  const res = toSourceText(<ts.ClassDeclaration name="Foo" export default />);
19
18
  expect(res).toEqual(d`
20
- export default class Foo {
21
-
22
- }
19
+ export default class Foo {}
23
20
  `);
24
21
  });
25
22
 
@@ -27,9 +24,7 @@ it("creates extends", () => {
27
24
  const res = toSourceText(<ts.ClassDeclaration name="Foo" extends="string" />);
28
25
 
29
26
  expect(res).toEqual(d`
30
- class Foo extends string {
31
-
32
- }
27
+ class Foo extends string {}
33
28
  `);
34
29
  });
35
30
 
@@ -37,13 +32,17 @@ describe("instance members", () => {
37
32
  it("can be created", () => {
38
33
  const res = toSourceText(
39
34
  <ts.ClassDeclaration name="Foo">
40
- <ts.ClassField name="one" />
41
- <ts.ClassField name="two" public />
42
- <ts.ClassField name="three" private />
43
- <ts.ClassField name="four" protected />
44
- <ts.ClassField name="five" type="number" />
45
- <ts.ClassField name="six" type="number">12</ts.ClassField>
46
- <ts.ClassField name="seven" jsPrivate />
35
+ <StatementList>
36
+ <ts.ClassField name="one" />
37
+ <ts.ClassField name="two" public />
38
+ <ts.ClassField name="three" private />
39
+ <ts.ClassField name="four" protected />
40
+ <ts.ClassField name="five" type="number" />
41
+ <ts.ClassField name="six" type="number">
42
+ 12
43
+ </ts.ClassField>
44
+ <ts.ClassField name="seven" jsPrivate />
45
+ </StatementList>
47
46
  </ts.ClassDeclaration>,
48
47
  );
49
48
 
@@ -64,8 +63,12 @@ describe("instance members", () => {
64
63
  const one = refkey();
65
64
  const res = toSourceText(
66
65
  <ts.ClassDeclaration name="Foo">
67
- <ts.ClassField name="one" refkey={one}>1</ts.ClassField>
68
- <ts.ClassField name="two">{one} + 1</ts.ClassField>
66
+ <StatementList>
67
+ <ts.ClassField name="one" refkey={one}>
68
+ 1
69
+ </ts.ClassField>
70
+ <ts.ClassField name="two">{one} + 1</ts.ClassField>
71
+ </StatementList>
69
72
  </ts.ClassDeclaration>,
70
73
  );
71
74
 
@@ -83,7 +86,11 @@ describe("instance members", () => {
83
86
  toSourceText(
84
87
  <>
85
88
  <ts.ClassDeclaration name="Foo">
86
- <ts.ClassField name="one" refkey={one}>1</ts.ClassField>
89
+ <StatementList>
90
+ <ts.ClassField name="one" refkey={one}>
91
+ 1
92
+ </ts.ClassField>
93
+ </StatementList>
87
94
  </ts.ClassDeclaration>
88
95
  {one}
89
96
  </>,
@@ -97,7 +104,11 @@ describe("static members", () => {
97
104
  const one = refkey();
98
105
  const res = toSourceText(
99
106
  <ts.ClassDeclaration name="Foo">
100
- <ts.ClassField static name="one" refkey={one}>1</ts.ClassField>
107
+ <StatementList>
108
+ <ts.ClassField static name="one" refkey={one}>
109
+ 1
110
+ </ts.ClassField>
111
+ </StatementList>
101
112
  </ts.ClassDeclaration>,
102
113
  );
103
114
 
@@ -113,8 +124,13 @@ describe("static members", () => {
113
124
  const res = toSourceText(
114
125
  <>
115
126
  <ts.ClassDeclaration name="Foo">
116
- <ts.ClassField static name="one" refkey={one}>1</ts.ClassField>
127
+ <StatementList>
128
+ <ts.ClassField static name="one" refkey={one}>
129
+ 1
130
+ </ts.ClassField>
131
+ </StatementList>
117
132
  </ts.ClassDeclaration>
133
+ <hbr />
118
134
  {one};
119
135
  </>,
120
136
  );
@@ -136,45 +152,41 @@ describe("instance methods", () => {
136
152
 
137
153
  const res = toSourceText(
138
154
  <ts.ClassDeclaration name="Foo">
139
- <ts.ClassMethod name="one" refkey={one} />
140
- <ts.ClassMethod name="two" public />
141
- <ts.ClassMethod name="three" private />
142
- <ts.ClassMethod name="four" protected />
143
- <ts.ClassMethod name="five" parameters={{a: "string", b: "string"}} />
144
- <ts.ClassMethod
145
- name="six"
146
- parameters={{a: {type: "number", refkey: a }, b: {type: "number", refkey: b }}}
147
- returnType="number"
148
- >
149
- {one} = {a} + {b};
150
- </ts.ClassMethod>
151
- <ts.ClassMethod name="seven" jsPrivate />
155
+ <List hardline>
156
+ <ts.ClassMethod name="one" refkey={one} />
157
+ <ts.ClassMethod name="two" public />
158
+ <ts.ClassMethod name="three" private />
159
+ <ts.ClassMethod name="four" protected />
160
+ <ts.ClassMethod
161
+ name="five"
162
+ parameters={{ a: "string", b: "string" }}
163
+ />
164
+ <ts.ClassMethod
165
+ name="six"
166
+ parameters={{
167
+ a: { type: "number", refkey: a },
168
+ b: { type: "number", refkey: b },
169
+ }}
170
+ returnType="number"
171
+ >
172
+ {one} = {a} + {b};
173
+ </ts.ClassMethod>
174
+ <ts.ClassMethod name="seven" jsPrivate />
175
+ </List>
152
176
  </ts.ClassDeclaration>,
153
177
  );
154
178
 
155
179
  expect(res).toEqual(d`
156
180
  class Foo {
157
- one() {
158
-
159
- }
160
- public two() {
161
-
162
- }
163
- private three() {
164
-
165
- }
166
- protected four() {
167
-
168
- }
169
- five(a: string, b: string) {
170
-
171
- }
181
+ one() {}
182
+ public two() {}
183
+ private three() {}
184
+ protected four() {}
185
+ five(a: string, b: string) {}
172
186
  six(a: number, b: number): number {
173
187
  this.one = a + b;
174
188
  }
175
- #seven() {
176
-
177
- }
189
+ #seven() {}
178
190
  }
179
191
  `);
180
192
  });
@@ -9,15 +9,17 @@ it("renders an enum with enum children", () => {
9
9
  <Output>
10
10
  <ts.SourceFile path="foo.ts">
11
11
  <ts.EnumDeclaration name="MyEnum">
12
- <ts.EnumMember name="foo" value="1" />,
13
- <ts.EnumMember name="bar" value="2" />
12
+ <ts.CommaList>
13
+ <ts.EnumMember name="foo" value="1" />
14
+ <ts.EnumMember name="bar" value="2" />
15
+ </ts.CommaList>
14
16
  </ts.EnumDeclaration>
15
17
  </ts.SourceFile>
16
18
  </Output>,
17
19
  ).toRenderTo(`
18
20
  enum MyEnum {
19
21
  foo = 1,
20
- bar = 2
22
+ bar = 2,
21
23
  }
22
24
  `);
23
25
  });
@@ -27,15 +29,17 @@ it("renders an enum with enum children specifying JS Value", () => {
27
29
  <Output>
28
30
  <ts.SourceFile path="foo.ts">
29
31
  <ts.EnumDeclaration name="MyEnum">
30
- <ts.EnumMember name="foo" jsValue="1" />,
31
- <ts.EnumMember name="bar" jsValue={2} />
32
+ <ts.CommaList>
33
+ <ts.EnumMember name="foo" jsValue="1" />
34
+ <ts.EnumMember name="bar" jsValue={2} />
35
+ </ts.CommaList>
32
36
  </ts.EnumDeclaration>
33
37
  </ts.SourceFile>
34
38
  </Output>,
35
39
  ).toRenderTo(`
36
40
  enum MyEnum {
37
41
  foo = "1",
38
- bar = 2
42
+ bar = 2,
39
43
  }
40
44
  `);
41
45
  });
@@ -55,7 +59,7 @@ it("renders an enum given a JS value", () => {
55
59
  ).toRenderTo(`
56
60
  enum MyEnum {
57
61
  foo = 1,
58
- bar = 2
62
+ bar = 2,
59
63
  }
60
64
  `);
61
65
  });
@@ -100,7 +104,7 @@ it("uses the naming policy", () => {
100
104
  ).toRenderTo(`
101
105
  enum MyEnum {
102
106
  FooProp = 1,
103
- BarProp = 2
107
+ BarProp = 2,
104
108
  }
105
109
  `);
106
110
  });
@@ -113,19 +117,20 @@ describe("symbols", () => {
113
117
  <Output>
114
118
  <ts.SourceFile path="foo.ts">
115
119
  <ts.EnumDeclaration name="MyEnum">
116
- <ts.EnumMember name="foo" jsValue="1" refkey={memberOne} />,
117
- <ts.EnumMember name="bar" jsValue={2} />
120
+ <ts.CommaList>
121
+ <ts.EnumMember name="foo" jsValue="1" refkey={memberOne} />
122
+ <ts.EnumMember name="bar" jsValue={2} />
123
+ </ts.CommaList>
118
124
  </ts.EnumDeclaration>
119
-
125
+ <hbr />
120
126
  {memberOne};
121
127
  </ts.SourceFile>
122
128
  </Output>,
123
129
  ).toRenderTo(`
124
130
  enum MyEnum {
125
131
  foo = "1",
126
- bar = 2
132
+ bar = 2,
127
133
  }
128
-
129
134
  MyEnum.foo;
130
135
  `);
131
136
  });
@@ -5,7 +5,6 @@ import {
5
5
  createPackage,
6
6
  FunctionDeclaration,
7
7
  PackageDirectory,
8
- Reference,
9
8
  SourceFile,
10
9
  } from "../src/index.js";
11
10
  import { assertFileContents } from "./utils.js";
@@ -29,8 +28,8 @@ it("can import builtins", () => {
29
28
  <Output externals={[testLib, fs]}>
30
29
  <PackageDirectory path="." name="test" version="1.0.0">
31
30
  <SourceFile path="index.ts">
32
- <Reference refkey={testLib["./subpath"].nice} />;
33
- await <Reference refkey={fs["./promises"].readFile} />();
31
+ {testLib["./subpath"].nice};<hbr />
32
+ await {fs["./promises"].readFile}();
34
33
  </SourceFile>
35
34
  </PackageDirectory>
36
35
  </Output>,
@@ -78,8 +77,8 @@ it("can import builtins without a package", () => {
78
77
  const res = render(
79
78
  <Output externals={[testLib, fs]}>
80
79
  <SourceFile path="index.ts">
81
- <Reference refkey={testLib["./subpath"].nice} />;
82
- await <Reference refkey={fs["./promises"].readFile} />();
80
+ {testLib["./subpath"].nice};<hbr />
81
+ await {fs["./promises"].readFile}();
83
82
  </SourceFile>
84
83
  </Output>,
85
84
  );
@@ -115,8 +114,8 @@ it("can import builtins without a package", () => {
115
114
  <SourceFile path="index.ts">
116
115
  <FunctionDeclaration name="foo">
117
116
  <FunctionDeclaration name="bar">
118
- <Reference refkey={testLib["./subpath"].nice} />;
119
- await <Reference refkey={fs["./promises"].readFile} />();
117
+ {testLib["./subpath"].nice};<hbr />
118
+ await {fs["./promises"].readFile}();
120
119
  </FunctionDeclaration>
121
120
  </FunctionDeclaration>
122
121
  </SourceFile>
@@ -1,5 +1,6 @@
1
1
  import { Output, refkey, render } from "@alloy-js/core";
2
2
  import { it } from "vitest";
3
+ import { StatementList } from "../../core/src/components/StatementList.jsx";
3
4
  import {
4
5
  FunctionCallExpression,
5
6
  FunctionDeclaration,
@@ -13,22 +14,43 @@ it("can declare and call a function with parameters", () => {
13
14
  const functionRefkey = refkey();
14
15
  const res = render(
15
16
  <Output>
16
- <PackageDirectory path="." name="test" version="1.0.0">
17
- <SourceFile path="index.ts">
18
- <VarDeclaration name="foo" value={`"Foo"`} const />
19
- <FunctionDeclaration refkey={functionRefkey} name="bar" parameters={{"foo?": "string", "baz?": "number"}} >
20
- const message = foo ? foo : "Hello, World!";
21
- console.log(message);
22
- if(baz) console.log(baz)
23
- </FunctionDeclaration>
24
- <FunctionCallExpression refkey={functionRefkey} args={[`"Hello!"`]} />;
25
- <FunctionCallExpression refkey={functionRefkey} />;
26
- <FunctionCallExpression refkey={functionRefkey} args={[<>"Hello {<>World</>}!"</>]} />;
27
- <FunctionCallExpression refkey={functionRefkey} args={[<>"Hey there!"</>]} />;
28
- <FunctionCallExpression refkey={functionRefkey} args={[<>"Hello World"</>, <>12345</>]} />;
29
- </SourceFile>
30
- </PackageDirectory>
31
- </Output>,
17
+ <PackageDirectory path="." name="test" version="1.0.0">
18
+ <SourceFile path="index.ts">
19
+ <VarDeclaration name="foo" value={`"Foo"`} const />;<hbr />
20
+ <FunctionDeclaration
21
+ refkey={functionRefkey}
22
+ name="bar"
23
+ parameters={{ "foo?": "string", "baz?": "number" }}
24
+ >
25
+ <StatementList>
26
+ <>const message = foo ? foo : "Hello, World!"</>
27
+ <>console.log(message)</>
28
+ <>if(baz) console.log(baz)</>
29
+ </StatementList>
30
+ </FunctionDeclaration>
31
+ <hbr />
32
+ <StatementList>
33
+ <FunctionCallExpression
34
+ target={functionRefkey}
35
+ args={[`"Hello!"`]}
36
+ />
37
+ <FunctionCallExpression target={functionRefkey} />
38
+ <FunctionCallExpression
39
+ target={functionRefkey}
40
+ args={[<>"Hello {<>World</>}!"</>]}
41
+ />
42
+ <FunctionCallExpression
43
+ target={functionRefkey}
44
+ args={[<>"Hey there!"</>]}
45
+ />
46
+ <FunctionCallExpression
47
+ target={functionRefkey}
48
+ args={[<>"Hello World"</>, <>12345</>]}
49
+ />
50
+ </StatementList>
51
+ </SourceFile>
52
+ </PackageDirectory>
53
+ </Output>,
32
54
  );
33
55
 
34
56
  assertFileContents(res, {
@@ -37,7 +59,7 @@ it("can declare and call a function with parameters", () => {
37
59
  function bar(foo?: string, baz?: number) {
38
60
  const message = foo ? foo : "Hello, World!";
39
61
  console.log(message);
40
- if(baz) console.log(baz)
62
+ if(baz) console.log(baz);
41
63
  }
42
64
  bar("Hello!");
43
65
  bar();