@alloy-js/typescript 0.14.0 → 0.16.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 (57) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/src/components/FunctionBase.d.ts.map +1 -1
  3. package/dist/src/components/FunctionBase.js +6 -1
  4. package/dist/src/components/ImportStatement.d.ts.map +1 -1
  5. package/dist/src/components/ImportStatement.js +8 -2
  6. package/dist/src/components/MemberExpression.d.ts +21 -4
  7. package/dist/src/components/MemberExpression.d.ts.map +1 -1
  8. package/dist/src/components/MemberExpression.js +302 -88
  9. package/dist/src/components/ObjectExpression.d.ts +6 -0
  10. package/dist/src/components/ObjectExpression.d.ts.map +1 -1
  11. package/dist/src/components/ObjectExpression.js +17 -1
  12. package/dist/src/components/index.d.ts +0 -1
  13. package/dist/src/components/index.d.ts.map +1 -1
  14. package/dist/src/components/index.js +0 -1
  15. package/dist/src/components/stc/index.d.ts +0 -1
  16. package/dist/src/components/stc/index.d.ts.map +1 -1
  17. package/dist/src/components/stc/index.js +0 -1
  18. package/dist/src/parameter-descriptor.d.ts +9 -0
  19. package/dist/src/parameter-descriptor.d.ts.map +1 -1
  20. package/dist/test/arrow-function.test.js +17 -0
  21. package/dist/test/basic.test.js +1 -1
  22. package/dist/test/externals.test.js +3 -3
  23. package/dist/test/function-declaration.test.js +18 -0
  24. package/dist/test/function-expression.test.js +17 -0
  25. package/dist/test/function-type.test.js +14 -0
  26. package/dist/test/imports.test.js +114 -4
  27. package/dist/test/member-expression.test.js +285 -5
  28. package/dist/test/object.test.d.ts +2 -0
  29. package/dist/test/object.test.d.ts.map +1 -0
  30. package/dist/test/object.test.js +57 -0
  31. package/dist/tsconfig.tsbuildinfo +1 -1
  32. package/package.json +3 -3
  33. package/src/components/FunctionBase.tsx +1 -0
  34. package/src/components/ImportStatement.tsx +12 -2
  35. package/src/components/MemberExpression.tsx +364 -103
  36. package/src/components/ObjectExpression.tsx +21 -1
  37. package/src/components/index.ts +0 -1
  38. package/src/components/stc/index.ts +0 -1
  39. package/src/parameter-descriptor.ts +10 -0
  40. package/temp/api.json +231 -94
  41. package/test/arrow-function.test.tsx +22 -0
  42. package/test/basic.test.tsx +1 -1
  43. package/test/externals.test.tsx +3 -3
  44. package/test/function-declaration.test.tsx +22 -0
  45. package/test/function-expression.test.tsx +22 -0
  46. package/test/function-type.test.tsx +17 -0
  47. package/test/imports.test.tsx +75 -4
  48. package/test/member-expression.test.tsx +221 -8
  49. package/test/object.test.tsx +48 -0
  50. package/dist/src/components/MemberChainExpression.d.ts +0 -11
  51. package/dist/src/components/MemberChainExpression.d.ts.map +0 -1
  52. package/dist/src/components/MemberChainExpression.js +0 -98
  53. package/dist/test/member-chain.test.d.ts +0 -2
  54. package/dist/test/member-chain.test.d.ts.map +0 -1
  55. package/dist/test/member-chain.test.js +0 -141
  56. package/src/components/MemberChainExpression.tsx +0 -91
  57. package/test/member-chain.test.tsx +0 -124
@@ -1,124 +0,0 @@
1
- import { d } from "@alloy-js/core/testing";
2
- import { expect, it } from "vitest";
3
- import { MemberChainExpression } from "../src/components/MemberChainExpression.jsx";
4
- import { FunctionCallExpression, ValueExpression } from "../src/index.js";
5
- import { toSourceText } from "./utils.js";
6
-
7
- it("works", () => {
8
- expect(
9
- toSourceText(
10
- <MemberChainExpression>
11
- <>z</>
12
- <FunctionCallExpression target="string" />
13
- <FunctionCallExpression target="array" />
14
- <FunctionCallExpression target="min" args={[5]} />
15
- <FunctionCallExpression target="max" args={[10]} />
16
- </MemberChainExpression>,
17
- { printWidth: 10 },
18
- ),
19
- ).toBe(d`
20
- z.string()
21
- .array()
22
- .min(5)
23
- .max(10)
24
- `);
25
- });
26
-
27
- it("works with args which break", () => {
28
- expect(
29
- toSourceText(
30
- <MemberChainExpression>
31
- <>z</>
32
- <FunctionCallExpression
33
- target="object"
34
- args={[<ValueExpression jsValue={{ a: 1, b: 2 }} />]}
35
- />
36
- <FunctionCallExpression target="array" />
37
- </MemberChainExpression>,
38
- { printWidth: 10 },
39
- ),
40
- ).toBe(d`
41
- z.object({
42
- a: 1,
43
- b: 2,
44
- })
45
- .array()
46
- `);
47
- });
48
-
49
- it("works with args when it doesn't break", () => {
50
- expect(
51
- toSourceText(
52
- <MemberChainExpression>
53
- <>z</>
54
- <FunctionCallExpression
55
- target="object"
56
- args={[<ValueExpression jsValue={{ a: 1, b: 2 }} />]}
57
- />
58
- </MemberChainExpression>,
59
- ),
60
- ).toBe(d`
61
- z.object({
62
- a: 1,
63
- b: 2,
64
- })
65
- `);
66
-
67
- expect(
68
- toSourceText(
69
- <MemberChainExpression>
70
- <>z</>
71
- <>z2</>
72
- <>z3</>
73
- <FunctionCallExpression
74
- target="object"
75
- args={[<ValueExpression jsValue={{ a: 1, b: 2 }} />]}
76
- />
77
- </MemberChainExpression>,
78
- ),
79
- ).toBe(d`
80
- z.z2.z3.object({
81
- a: 1,
82
- b: 2,
83
- })
84
- `);
85
- });
86
-
87
- it("works with nested call member chains", () => {
88
- expect(
89
- toSourceText(
90
- <MemberChainExpression>
91
- <>z</>
92
- <FunctionCallExpression target="string" />
93
- <FunctionCallExpression target="array" />
94
- <MemberChainExpression>
95
- <FunctionCallExpression target="min" args={[5]} />
96
- <FunctionCallExpression target="max" args={[10]} />
97
- </MemberChainExpression>
98
- <FunctionCallExpression target="array" />
99
- </MemberChainExpression>,
100
- { printWidth: 10 },
101
- ),
102
- ).toBe(d`
103
- z.string()
104
- .array()
105
- .min(5)
106
- .max(10)
107
- .array()
108
- `);
109
- });
110
-
111
- it("works without function call expressions", () => {
112
- expect(
113
- toSourceText(
114
- <MemberChainExpression>
115
- <>z</>
116
- <>string</>
117
- <>min</>
118
- </MemberChainExpression>,
119
- { printWidth: 5 },
120
- ),
121
- ).toBe(d`
122
- z.string.min
123
- `);
124
- });