@alloy-js/typescript 0.10.0 → 0.11.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 (200) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/src/builtins/node.js +1 -2
  3. package/dist/src/components/ArrayExpression.js +2 -5
  4. package/dist/src/components/ArrowFunction.d.ts +40 -0
  5. package/dist/src/components/ArrowFunction.d.ts.map +1 -0
  6. package/dist/src/components/ArrowFunction.js +67 -0
  7. package/dist/src/components/BarrelFile.js +1 -2
  8. package/dist/src/components/BlockScope.js +2 -4
  9. package/dist/src/components/CallSignature.js +2 -4
  10. package/dist/src/components/ClassDeclaration.js +2 -6
  11. package/dist/src/components/CommaList.js +2 -5
  12. package/dist/src/components/Declaration.js +3 -5
  13. package/dist/src/components/EnumDeclaration.js +2 -5
  14. package/dist/src/components/EnumMember.js +2 -4
  15. package/dist/src/components/ExportStatement.js +1 -2
  16. package/dist/src/components/FunctionBase.d.ts +60 -0
  17. package/dist/src/components/FunctionBase.d.ts.map +1 -0
  18. package/dist/src/components/FunctionBase.js +207 -0
  19. package/dist/src/components/FunctionCallExpression.js +2 -5
  20. package/dist/src/components/FunctionDeclaration.d.ts +3 -18
  21. package/dist/src/components/FunctionDeclaration.d.ts.map +1 -1
  22. package/dist/src/components/FunctionDeclaration.js +9 -157
  23. package/dist/src/components/FunctionExpression.d.ts +39 -0
  24. package/dist/src/components/FunctionExpression.d.ts.map +1 -0
  25. package/dist/src/components/FunctionExpression.js +66 -0
  26. package/dist/src/components/FunctionType.d.ts +39 -0
  27. package/dist/src/components/FunctionType.d.ts.map +1 -0
  28. package/dist/src/components/FunctionType.js +73 -0
  29. package/dist/src/components/IfStatement.js +2 -4
  30. package/dist/src/components/ImportStatement.js +1 -2
  31. package/dist/src/components/Interface.d.ts.map +1 -1
  32. package/dist/src/components/Interface.js +32 -11
  33. package/dist/src/components/InterfaceMethod.d.ts +43 -0
  34. package/dist/src/components/InterfaceMethod.d.ts.map +1 -0
  35. package/dist/src/components/InterfaceMethod.js +87 -0
  36. package/dist/src/components/JSDoc.js +1 -2
  37. package/dist/src/components/JSDocComment.js +2 -4
  38. package/dist/src/components/JSDocExample.js +2 -5
  39. package/dist/src/components/JSDocParam.js +2 -5
  40. package/dist/src/components/MemberChainExpression.js +2 -4
  41. package/dist/src/components/MemberDeclaration.d.ts +30 -0
  42. package/dist/src/components/MemberDeclaration.d.ts.map +1 -0
  43. package/dist/src/components/MemberDeclaration.js +29 -0
  44. package/dist/src/components/MemberExpression.js +2 -5
  45. package/dist/src/components/ObjectExpression.js +2 -5
  46. package/dist/src/components/PackageDirectory.js +2 -5
  47. package/dist/src/components/PackageJson.js +1 -2
  48. package/dist/src/components/PropertyName.js +1 -2
  49. package/dist/src/components/Reference.js +1 -2
  50. package/dist/src/components/SingleLineCommentBlock.js +2 -4
  51. package/dist/src/components/SourceFile.js +2 -4
  52. package/dist/src/components/SwitchStatement.js +2 -5
  53. package/dist/src/components/TsConfigJson.js +1 -2
  54. package/dist/src/components/TypeDeclaration.js +2 -6
  55. package/dist/src/components/ValueExpression.js +1 -2
  56. package/dist/src/components/VarDeclaration.js +2 -5
  57. package/dist/src/components/index.d.ts +6 -0
  58. package/dist/src/components/index.d.ts.map +1 -1
  59. package/dist/src/components/index.js +6 -1
  60. package/dist/src/components/stc/index.d.ts +7 -0
  61. package/dist/src/components/stc/index.d.ts.map +1 -1
  62. package/dist/src/components/stc/index.js +8 -2
  63. package/dist/src/context/private-scope.js +1 -2
  64. package/dist/src/create-package.js +1 -2
  65. package/dist/src/index.js +1 -2
  66. package/dist/src/name-conflict-resolver.js +1 -2
  67. package/dist/src/name-policy.js +1 -2
  68. package/dist/src/parameter-descriptor.d.ts +27 -17
  69. package/dist/src/parameter-descriptor.d.ts.map +1 -1
  70. package/dist/src/source-directory-data.js +1 -2
  71. package/dist/src/symbols/index.js +1 -2
  72. package/dist/src/symbols/reference.js +2 -3
  73. package/dist/src/symbols/scopes.js +1 -2
  74. package/dist/src/symbols/ts-member-scope.js +1 -2
  75. package/dist/src/symbols/ts-module-scope.js +1 -2
  76. package/dist/src/symbols/ts-output-symbol.js +1 -2
  77. package/dist/src/symbols/ts-package-scope.js +1 -2
  78. package/dist/src/utils.js +1 -2
  79. package/dist/test/array.test.js +105 -0
  80. package/dist/test/arrow-function.test.d.ts +2 -0
  81. package/dist/test/arrow-function.test.d.ts.map +1 -0
  82. package/dist/test/arrow-function.test.js +194 -0
  83. package/dist/test/barrel.test.js +53 -0
  84. package/dist/test/basic.test.js +91 -0
  85. package/dist/test/block-scope.test.js +30 -0
  86. package/dist/test/class.test.js +438 -0
  87. package/dist/test/enum-jsdoc.test.js +88 -0
  88. package/dist/test/enum.test.js +247 -0
  89. package/dist/test/externals.test.js +145 -0
  90. package/dist/test/function-call-expression.test.js +87 -0
  91. package/dist/test/function-declaration-jsdoc.test.js +91 -0
  92. package/dist/test/function-declaration.test.js +228 -0
  93. package/dist/test/function-expression.test.d.ts +2 -0
  94. package/dist/test/function-expression.test.d.ts.map +1 -0
  95. package/dist/test/function-expression.test.js +194 -0
  96. package/dist/test/function-type.test.d.ts +2 -0
  97. package/dist/test/function-type.test.d.ts.map +1 -0
  98. package/dist/test/function-type.test.js +122 -0
  99. package/dist/test/if-statement.test.js +25 -0
  100. package/dist/test/imports.test.js +434 -0
  101. package/dist/test/interface-jsdoc.test.js +178 -0
  102. package/dist/test/interface.test.d.ts.map +1 -1
  103. package/dist/test/interface.test.js +490 -0
  104. package/dist/test/jscomment.test.js +70 -0
  105. package/dist/test/jsdoc.test.js +134 -0
  106. package/dist/test/jsdocparam.test.js +164 -0
  107. package/dist/test/member-chain.test.js +141 -0
  108. package/dist/test/member-expression.test.js +359 -0
  109. package/dist/test/name-conflict.test.js +108 -0
  110. package/dist/test/name-policy.test.js +122 -0
  111. package/dist/test/package-external.test.js +196 -0
  112. package/dist/test/package-json.test.js +93 -0
  113. package/dist/test/package.test.js +136 -0
  114. package/dist/test/reference.test.js +81 -0
  115. package/dist/test/source-file.test.js +36 -0
  116. package/dist/test/switch-statement.test.js +61 -0
  117. package/dist/test/utils.js +45 -0
  118. package/dist/test/value-expression.test.js +30 -0
  119. package/dist/test/values.test.js +351 -0
  120. package/dist/test/var-declaration-jsdoc.test.js +50 -0
  121. package/dist/test/var-declaration.test.js +63 -0
  122. package/dist/test/vitest.d.js +1 -0
  123. package/dist/tsconfig.tsbuildinfo +1 -1
  124. package/package.json +12 -17
  125. package/src/components/ArrowFunction.tsx +87 -0
  126. package/src/components/Declaration.tsx +1 -1
  127. package/src/components/FunctionBase.tsx +271 -0
  128. package/src/components/FunctionDeclaration.tsx +13 -195
  129. package/src/components/FunctionExpression.tsx +86 -0
  130. package/src/components/FunctionType.tsx +88 -0
  131. package/src/components/Interface.tsx +33 -5
  132. package/src/components/InterfaceMethod.tsx +96 -0
  133. package/src/components/MemberDeclaration.tsx +70 -0
  134. package/src/components/index.ts +10 -0
  135. package/src/components/stc/index.ts +7 -0
  136. package/src/parameter-descriptor.ts +29 -18
  137. package/src/symbols/reference.ts +4 -1
  138. package/temp/api.json +2605 -680
  139. package/test/arrow-function.test.tsx +188 -0
  140. package/test/class.test.tsx +1 -2
  141. package/test/function-call-expression.test.tsx +1 -2
  142. package/test/function-declaration.test.tsx +1 -2
  143. package/test/function-expression.test.tsx +195 -0
  144. package/test/function-type.test.tsx +118 -0
  145. package/test/interface.test.tsx +256 -6
  146. package/tsdoc-metadata.json +1 -1
  147. package/babel.config.cjs +0 -4
  148. package/dist/src/builtins/index.js.map +0 -1
  149. package/dist/src/builtins/node.js.map +0 -1
  150. package/dist/src/components/ArrayExpression.js.map +0 -1
  151. package/dist/src/components/BarrelFile.js.map +0 -1
  152. package/dist/src/components/BlockScope.js.map +0 -1
  153. package/dist/src/components/CallSignature.js.map +0 -1
  154. package/dist/src/components/ClassDeclaration.js.map +0 -1
  155. package/dist/src/components/CommaList.js.map +0 -1
  156. package/dist/src/components/Declaration.js.map +0 -1
  157. package/dist/src/components/EnumDeclaration.js.map +0 -1
  158. package/dist/src/components/EnumMember.js.map +0 -1
  159. package/dist/src/components/ExportStatement.js.map +0 -1
  160. package/dist/src/components/FunctionCallExpression.js.map +0 -1
  161. package/dist/src/components/FunctionDeclaration.js.map +0 -1
  162. package/dist/src/components/IfStatement.js.map +0 -1
  163. package/dist/src/components/ImportStatement.js.map +0 -1
  164. package/dist/src/components/Interface.js.map +0 -1
  165. package/dist/src/components/JSDoc.js.map +0 -1
  166. package/dist/src/components/JSDocComment.js.map +0 -1
  167. package/dist/src/components/JSDocExample.js.map +0 -1
  168. package/dist/src/components/JSDocParam.js.map +0 -1
  169. package/dist/src/components/MemberChainExpression.js.map +0 -1
  170. package/dist/src/components/MemberExpression.js.map +0 -1
  171. package/dist/src/components/ObjectExpression.js.map +0 -1
  172. package/dist/src/components/PackageDirectory.js.map +0 -1
  173. package/dist/src/components/PackageJson.js.map +0 -1
  174. package/dist/src/components/PropertyName.js.map +0 -1
  175. package/dist/src/components/Reference.js.map +0 -1
  176. package/dist/src/components/SingleLineCommentBlock.js.map +0 -1
  177. package/dist/src/components/SourceFile.js.map +0 -1
  178. package/dist/src/components/SwitchStatement.js.map +0 -1
  179. package/dist/src/components/TsConfigJson.js.map +0 -1
  180. package/dist/src/components/TypeDeclaration.js.map +0 -1
  181. package/dist/src/components/ValueExpression.js.map +0 -1
  182. package/dist/src/components/VarDeclaration.js.map +0 -1
  183. package/dist/src/components/index.js.map +0 -1
  184. package/dist/src/components/stc/index.js.map +0 -1
  185. package/dist/src/context/index.js.map +0 -1
  186. package/dist/src/context/private-scope.js.map +0 -1
  187. package/dist/src/create-package.js.map +0 -1
  188. package/dist/src/index.js.map +0 -1
  189. package/dist/src/name-conflict-resolver.js.map +0 -1
  190. package/dist/src/name-policy.js.map +0 -1
  191. package/dist/src/parameter-descriptor.js.map +0 -1
  192. package/dist/src/source-directory-data.js.map +0 -1
  193. package/dist/src/symbols/index.js.map +0 -1
  194. package/dist/src/symbols/reference.js.map +0 -1
  195. package/dist/src/symbols/scopes.js.map +0 -1
  196. package/dist/src/symbols/ts-member-scope.js.map +0 -1
  197. package/dist/src/symbols/ts-module-scope.js.map +0 -1
  198. package/dist/src/symbols/ts-output-symbol.js.map +0 -1
  199. package/dist/src/symbols/ts-package-scope.js.map +0 -1
  200. package/dist/src/utils.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog - @alloy-js/typescript
2
2
 
3
+ ## 0.11.0
4
+
5
+ ### Bug Fixes
6
+
7
+ - [#92](https://github.com/alloy-framework/alloy/pull/92) Missing export of `IfStatement`, `ElseIfClause` and `ElseClause`
8
+ - [#112](https://github.com/alloy-framework/alloy/pull/112) Fix interface member references
9
+
10
+ ### Features
11
+
12
+ - [#112](https://github.com/alloy-framework/alloy/pull/112) Add new `<MemberDeclaration />` component. A wrapper around alloy `<MemberDeclaration />` with TypeScript specific props.
13
+ - [#91](https://github.com/alloy-framework/alloy/pull/91) Add new `<FunctionExpression />` and `<ArrowFunctionExpression />` components supporting the various formm of function expressions
14
+ - [#110](https://github.com/alloy-framework/alloy/pull/110) Add `<InterfaceMethod />` and `<FunctionType />` component
15
+ - [#105](https://github.com/alloy-framework/alloy/pull/105) Updated dependencies
16
+
17
+
3
18
  ## 0.10.0
4
19
 
5
20
  ### Bug Fixes
@@ -35,5 +35,4 @@ export const util = createPackage({
35
35
  named: ["callbackify", "debuglog", "debug", "deprecate", "format", "formatWithOptions", "getSystemErrorName", "getSystemErrorMap", "inherits", "inspect", "isDeepStrictEqual", "MIMEType", "MIMEParams", "parseArgs", "parseEnv", "promisify", "stripVTControlCharacters", "styleText", "TextDecoder", "TextEncoder", "toUSVString", "transferableAbortController", "transferableAbortSignal", "aborted", "types"]
36
36
  }
37
37
  }
38
- });
39
- //# sourceMappingURL=node.js.map
38
+ });
@@ -1,6 +1,4 @@
1
- import { createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
2
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
3
- import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
1
+ import { memo as _$memo, createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
4
2
  import { childrenArray, For, Indent, Show } from "@alloy-js/core";
5
3
  import { ValueExpression } from "./ValueExpression.js";
6
4
  export function ArrayExpression(props) {
@@ -29,5 +27,4 @@ export function ArrayExpression(props) {
29
27
  }), _$createIntrinsic("sbr", {}), "]"];
30
28
  }
31
29
  });
32
- }
33
- //# sourceMappingURL=ArrayExpression.js.map
30
+ }
@@ -0,0 +1,40 @@
1
+ import { Children } from "@alloy-js/core/jsx-runtime";
2
+ import { CallSignatureProps } from "./CallSignature.jsx";
3
+ export interface ArrowFunctionProps extends CallSignatureProps {
4
+ async?: boolean;
5
+ children?: Children;
6
+ }
7
+ /**
8
+ * A TypeScript arrow function expression.
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * <FunctionExpression async parameters={[{ name: "a", type: "number" }, { name: "b", type: "number" }]}>
13
+ * return a + b;
14
+ * <FunctionExpression>
15
+ * ```
16
+ * renders to
17
+ * ```ts
18
+ * async (a, b) => { return a + b; }
19
+ * ```
20
+ *
21
+ * @remarks
22
+ *
23
+ * Providing parameters and type parameters can be accomplished in one of three
24
+ * ways:
25
+ *
26
+ * 1. As an array of {@link ParameterDescriptor}s or
27
+ * {@link TypeParameterDescriptor}s.
28
+ * 2. As raw content via the `parametersChildren` or `typeParametersChildren`
29
+ * props.
30
+ * 3. As a child of this component via the
31
+ * {@link (ArrowFunction:namespace).Parameters} or
32
+ * {@link (ArrowFunction:namespace).TypeParameters} components.
33
+ */
34
+ export declare function ArrowFunction(props: ArrowFunctionProps): Children;
35
+ export declare namespace ArrowFunction {
36
+ var TypeParameters: import("@alloy-js/core").Component<import("./FunctionBase.jsx").TypeParametersProps> & Required<Pick<import("@alloy-js/core").Component<import("./FunctionBase.jsx").TypeParametersProps>, "tag">>;
37
+ var Parameters: import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionParametersProps> & Required<Pick<import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionParametersProps>, "tag">>;
38
+ var Body: import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionBodyProps> & Required<Pick<import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionBodyProps>, "tag">>;
39
+ }
40
+ //# sourceMappingURL=ArrowFunction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArrowFunction.d.ts","sourceRoot":"","sources":["../../../src/components/ArrowFunction.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD,OAAO,EAAiB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AASxE,MAAM,WAAW,kBAAmB,SAAQ,kBAAkB;IAC5D,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,YAiCtD;yBAjCe,aAAa"}
@@ -0,0 +1,67 @@
1
+ import { createComponent as _$createComponent, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
2
+ import { childrenArray, findKeyedChild, findUnkeyedChildren, Scope } from "@alloy-js/core";
3
+ import { getCallSignatureProps } from "../utils.js";
4
+ import { CallSignature } from "./CallSignature.js";
5
+ import { Declaration } from "./Declaration.js";
6
+ import { FunctionBody, FunctionParameters, getReturnType, TypeParameters } from "./FunctionBase.js";
7
+ /**
8
+ * A TypeScript arrow function expression.
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * <FunctionExpression async parameters={[{ name: "a", type: "number" }, { name: "b", type: "number" }]}>
13
+ * return a + b;
14
+ * <FunctionExpression>
15
+ * ```
16
+ * renders to
17
+ * ```ts
18
+ * async (a, b) => { return a + b; }
19
+ * ```
20
+ *
21
+ * @remarks
22
+ *
23
+ * Providing parameters and type parameters can be accomplished in one of three
24
+ * ways:
25
+ *
26
+ * 1. As an array of {@link ParameterDescriptor}s or
27
+ * {@link TypeParameterDescriptor}s.
28
+ * 2. As raw content via the `parametersChildren` or `typeParametersChildren`
29
+ * props.
30
+ * 3. As a child of this component via the
31
+ * {@link (ArrowFunction:namespace).Parameters} or
32
+ * {@link (ArrowFunction:namespace).TypeParameters} components.
33
+ */
34
+ export function ArrowFunction(props) {
35
+ const children = childrenArray(() => props.children);
36
+ const typeParametersChildren = findKeyedChild(children, TypeParameters.tag) ?? undefined;
37
+ const parametersChildren = findKeyedChild(children, FunctionParameters.tag) ?? undefined;
38
+ const bodyChildren = findKeyedChild(children, FunctionBody.tag) ?? undefined;
39
+ const filteredChildren = findUnkeyedChildren(children);
40
+ const returnType = getReturnType(props.returnType, {
41
+ async: props.async
42
+ });
43
+ const sBody = bodyChildren ?? _$createComponent(ArrowFunction.Body, {
44
+ children: filteredChildren
45
+ });
46
+ const asyncKwd = props.async ? "async " : "";
47
+ const callSignatureProps = getCallSignatureProps(props, {
48
+ parametersChildren,
49
+ typeParametersChildren
50
+ });
51
+ return [_$createComponent(Declaration, _$mergeProps(props, {
52
+ nameKind: "function",
53
+ get children() {
54
+ return [asyncKwd, _$createComponent(Scope, {
55
+ kind: "function",
56
+ get children() {
57
+ return [_$createComponent(CallSignature, _$mergeProps(callSignatureProps, {
58
+ returnType: returnType
59
+ })), " => ", sBody];
60
+ }
61
+ })];
62
+ }
63
+ }))];
64
+ }
65
+ ArrowFunction.TypeParameters = TypeParameters;
66
+ ArrowFunction.Parameters = FunctionParameters;
67
+ ArrowFunction.Body = FunctionBody;
@@ -71,5 +71,4 @@ export function BarrelFile(props) {
71
71
  });
72
72
  }
73
73
  });
74
- }
75
- //# sourceMappingURL=BarrelFile.js.map
74
+ }
@@ -1,5 +1,4 @@
1
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
- import { mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
1
+ import { mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
3
2
  import { Block, Scope } from "@alloy-js/core";
4
3
  /**
5
4
  * Create a TypeScript block which includes a scope for any nested declarations.
@@ -16,5 +15,4 @@ export function BlockScope(props) {
16
15
  }));
17
16
  }
18
17
  }));
19
- }
20
- //# sourceMappingURL=BlockScope.js.map
18
+ }
@@ -1,5 +1,4 @@
1
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
- import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
1
+ import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
3
2
  import { FunctionDeclaration } from "./FunctionDeclaration.js";
4
3
  /**
5
4
  * A TypeScript call signature, e.g. the part after the `function` keyword in an
@@ -22,5 +21,4 @@ export function CallSignature(props) {
22
21
  });
23
22
  const sReturnType = props.returnType ? [": ", _$memo(() => props.returnType)] : undefined;
24
23
  return [sTypeParameters, "(", sParams, ")", sReturnType];
25
- }
26
- //# sourceMappingURL=CallSignature.js.map
24
+ }
@@ -1,7 +1,4 @@
1
- import { mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
2
- import { createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
3
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
4
- import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
1
+ import { memo as _$memo, createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
5
2
  import { Block, MemberDeclaration, Name, OutputSymbolFlags, Prose, Scope, Show, splitProps, useMemberScope } from "@alloy-js/core";
6
3
  import { usePrivateScope } from "../context/private-scope.js";
7
4
  import { useTSNamePolicy } from "../name-policy.js";
@@ -175,5 +172,4 @@ export function ClassMethod(props) {
175
172
  })];
176
173
  }
177
174
  }))];
178
- }
179
- //# sourceMappingURL=ClassDeclaration.js.map
175
+ }
@@ -1,6 +1,4 @@
1
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
- import { mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
3
- import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
1
+ import { memo as _$memo, mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
4
2
  import { List, splitProps } from "@alloy-js/core";
5
3
  /**
6
4
  * A comma-separated list of items (e.g. arguments to a function call,
@@ -15,5 +13,4 @@ export function CommaList(props) {
15
13
  return props.children;
16
14
  }
17
15
  }));
18
- }
19
- //# sourceMappingURL=CommaList.js.map
16
+ }
@@ -1,5 +1,4 @@
1
- import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
1
+ import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
3
2
  import { Declaration as CoreDeclaration, MemberScope, OutputSymbolFlags } from "@alloy-js/core";
4
3
  import { useTSNamePolicy } from "../name-policy.js";
5
4
  import { createTSSymbol, TSSymbolFlags } from "../symbols/index.js";
@@ -34,7 +33,7 @@ export function Declaration(props) {
34
33
  const namePolicy = useTSNamePolicy();
35
34
  let tsFlags = TSSymbolFlags.None;
36
35
  if (props.kind && props.kind === "type") {
37
- tsFlags &= TSSymbolFlags.TypeSymbol;
36
+ tsFlags |= TSSymbolFlags.TypeSymbol;
38
37
  }
39
38
  sym = createTSSymbol({
40
39
  name: namePolicy.getName(props.name, props.nameKind),
@@ -75,5 +74,4 @@ export function Declaration(props) {
75
74
  return [_$memo(() => props.export ? "export " : ""), _$memo(() => props.default ? "default " : ""), children];
76
75
  }
77
76
  });
78
- }
79
- //# sourceMappingURL=Declaration.js.map
77
+ }
@@ -1,6 +1,4 @@
1
- import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
- import { createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
3
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
1
+ import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, memo as _$memo } from "@alloy-js/core/jsx-runtime";
4
2
  import { Block, computed, Declaration as CoreDeclaration, For, MemberScope, Name, OutputSymbolFlags, Show, useBinder } from "@alloy-js/core";
5
3
  import { useTSNamePolicy } from "../name-policy.js";
6
4
  import { createTSSymbol, useTSScope } from "../symbols/index.js";
@@ -59,5 +57,4 @@ export function EnumDeclaration(props) {
59
57
  })];
60
58
  }
61
59
  })];
62
- }
63
- //# sourceMappingURL=EnumDeclaration.js.map
60
+ }
@@ -1,5 +1,4 @@
1
- import { createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
2
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
1
+ import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
3
2
  import { OutputSymbolFlags, Show } from "@alloy-js/core";
4
3
  import { useTSNamePolicy } from "../name-policy.js";
5
4
  import { createTSSymbol } from "../symbols/ts-output-symbol.js";
@@ -46,5 +45,4 @@ export function EnumMember(props) {
46
45
  return [" = ", valueCode];
47
46
  }
48
47
  })];
49
- }
50
- //# sourceMappingURL=EnumMember.js.map
48
+ }
@@ -13,5 +13,4 @@ export function ExportStatement(props) {
13
13
  return ["export * from \"", _$memo(() => modulePath(relative(dirname(module.scope.name), props.from.name))), "\";"];
14
14
  }
15
15
  return "";
16
- }
17
- //# sourceMappingURL=ExportStatement.js.map
16
+ }
@@ -0,0 +1,60 @@
1
+ import type { Children } from "@alloy-js/core/jsx-runtime";
2
+ import type { ParameterDescriptor } from "../parameter-descriptor.js";
3
+ import { TypeParameterDescriptor } from "../parameter-descriptor.js";
4
+ export interface FunctionBodyProps {
5
+ readonly children?: Children;
6
+ }
7
+ /** Props for function parameters */
8
+ export interface FunctionParametersProps {
9
+ /** Parameters */
10
+ readonly parameters?: ParameterDescriptor[] | string[];
11
+ /** Jsx Children */
12
+ readonly children?: Children;
13
+ }
14
+ /** Props for a function type(FunctionType or InterfaceMethod) */
15
+ export interface FunctionTypeParametersProps {
16
+ /** Parameters */
17
+ readonly parameters?: ParameterDescriptor[] | string[];
18
+ /** Jsx Children */
19
+ readonly children?: Children;
20
+ }
21
+ /** Props for type parameters */
22
+ export interface TypeParametersProps {
23
+ /** Parameters */
24
+ parameters?: TypeParameterDescriptor[] | string[];
25
+ /** Jsx Children */
26
+ children?: Children;
27
+ }
28
+ export declare const FunctionBody: import("@alloy-js/core").Component<FunctionBodyProps> & Required<Pick<import("@alloy-js/core").Component<FunctionBodyProps>, "tag">>;
29
+ /**
30
+ * Represent function parameters(FunctionDeclaration, FunctionExpression, ArrowFunction, etc.)
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * a: string, b: string = "abc", c?: string,
35
+ * ```
36
+ */
37
+ export declare const FunctionParameters: import("@alloy-js/core").Component<FunctionParametersProps> & Required<Pick<import("@alloy-js/core").Component<FunctionParametersProps>, "tag">>;
38
+ /**
39
+ * Represent parameters for a function type(FunctionType or InterfaceMethod)
40
+ * This differ from {@link FunctionParameters} in that it doesn't allow default values.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * a: string, b?: string
45
+ * ```
46
+ */
47
+ export declare const FunctionTypeParameters: import("@alloy-js/core").Component<FunctionTypeParametersProps> & Required<Pick<import("@alloy-js/core").Component<FunctionTypeParametersProps>, "tag">>;
48
+ /**
49
+ * Represent type parameters
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * <A, B extends string>
54
+ * ```
55
+ */
56
+ export declare const TypeParameters: import("@alloy-js/core").Component<TypeParametersProps> & Required<Pick<import("@alloy-js/core").Component<TypeParametersProps>, "tag">>;
57
+ export declare function getReturnType(returnType: Children | undefined, options?: {
58
+ async?: boolean;
59
+ }): Children;
60
+ //# sourceMappingURL=FunctionBase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FunctionBase.d.ts","sourceRoot":"","sources":["../../../src/components/FunctionBase.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,KAAK,EAEV,mBAAmB,EACpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAWrE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CAC9B;AAED,oCAAoC;AACpC,MAAM,WAAW,uBAAuB;IACtC,iBAAiB;IACjB,QAAQ,CAAC,UAAU,CAAC,EAAE,mBAAmB,EAAE,GAAG,MAAM,EAAE,CAAC;IACvD,mBAAmB;IACnB,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CAC9B;AAED,iEAAiE;AACjE,MAAM,WAAW,2BAA2B;IAC1C,iBAAiB;IACjB,QAAQ,CAAC,UAAU,CAAC,EAAE,mBAAmB,EAAE,GAAG,MAAM,EAAE,CAAC;IACvD,mBAAmB;IACnB,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CAC9B;AAED,gCAAgC;AAChC,MAAM,WAAW,mBAAmB;IAClC,iBAAiB;IACjB,UAAU,CAAC,EAAE,uBAAuB,EAAE,GAAG,MAAM,EAAE,CAAC;IAClD,mBAAmB;IACnB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,eAAO,MAAM,YAAY,sIAKxB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,kJAmB9B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,0JAmBlC,CAAC;AAwFF;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,0IAkC1B,CAAC;AAeF,wBAAgB,aAAa,CAC3B,UAAU,EAAE,QAAQ,GAAG,SAAS,EAChC,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAqB,YAKhD"}
@@ -0,0 +1,207 @@
1
+ import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
+ import { Block, code, For, Indent, onCleanup, Show, taggedComponent } from "@alloy-js/core";
3
+ import { useTSNamePolicy } from "../name-policy.js";
4
+ import { createTSSymbol, TSSymbolFlags } from "../symbols/index.js";
5
+ const functionParametersTag = Symbol();
6
+ const typeParametersTag = Symbol();
7
+ const functionBodyTag = Symbol();
8
+
9
+ /** Props for function parameters */
10
+
11
+ /** Props for a function type(FunctionType or InterfaceMethod) */
12
+
13
+ /** Props for type parameters */
14
+
15
+ export const FunctionBody = taggedComponent(functionBodyTag, function Body(props) {
16
+ return _$createComponent(Block, {
17
+ get children() {
18
+ return props.children;
19
+ }
20
+ });
21
+ });
22
+
23
+ /**
24
+ * Represent function parameters(FunctionDeclaration, FunctionExpression, ArrowFunction, etc.)
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * a: string, b: string = "abc", c?: string,
29
+ * ```
30
+ */
31
+ export const FunctionParameters = taggedComponent(functionParametersTag, function Parameters(props) {
32
+ if (props.children) {
33
+ return props.children;
34
+ }
35
+ const parameters = normalizeAndDeclareParameters(props.parameters ?? []);
36
+ return _$createIntrinsic("group", {
37
+ get children() {
38
+ return _$createComponent(Indent, {
39
+ softline: true,
40
+ trailingBreak: true,
41
+ get children() {
42
+ return [_$createComponent(For, {
43
+ each: parameters,
44
+ comma: true,
45
+ line: true,
46
+ children: param => parameter(param)
47
+ }), _$createIntrinsic("ifBreak", {
48
+ children: ","
49
+ })];
50
+ }
51
+ });
52
+ }
53
+ });
54
+ });
55
+
56
+ /**
57
+ * Represent parameters for a function type(FunctionType or InterfaceMethod)
58
+ * This differ from {@link FunctionParameters} in that it doesn't allow default values.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * a: string, b?: string
63
+ * ```
64
+ */
65
+ export const FunctionTypeParameters = taggedComponent(functionParametersTag, function Parameters(props) {
66
+ if (props.children) {
67
+ return props.children;
68
+ }
69
+ const parameters = normalizeAndDeclareParameters(props.parameters ?? []);
70
+ return _$createIntrinsic("group", {
71
+ get children() {
72
+ return _$createComponent(Indent, {
73
+ softline: true,
74
+ trailingBreak: true,
75
+ get children() {
76
+ return [_$createComponent(For, {
77
+ each: parameters,
78
+ comma: true,
79
+ line: true,
80
+ children: param => parameter(param)
81
+ }), _$createIntrinsic("ifBreak", {
82
+ children: ","
83
+ })];
84
+ }
85
+ });
86
+ }
87
+ });
88
+ });
89
+ function parameter(param) {
90
+ return _$createIntrinsic("group", {
91
+ get children() {
92
+ return [_$memo(() => param.symbol.name), _$createComponent(Show, {
93
+ get when() {
94
+ return !!param.optional;
95
+ },
96
+ children: "?"
97
+ }), _$createComponent(Show, {
98
+ get when() {
99
+ return !!param.type;
100
+ },
101
+ get children() {
102
+ return _$createIntrinsic("indent", {
103
+ get children() {
104
+ return [": ", _$memo(() => param.type)];
105
+ }
106
+ });
107
+ }
108
+ })];
109
+ }
110
+ });
111
+ }
112
+ function normalizeAndDeclareParameters(parameters, flags = TSSymbolFlags.ParameterSymbol) {
113
+ const namePolicy = useTSNamePolicy();
114
+ if (parameters.length === 0) {
115
+ return [];
116
+ }
117
+ if (typeof parameters[0] === "string") {
118
+ return parameters.map(paramName => {
119
+ const symbol = createTSSymbol({
120
+ name: namePolicy.getName(paramName, flags & TSSymbolFlags.TypeSymbol ? "type" : "parameter"),
121
+ tsFlags: flags
122
+ });
123
+ return {
124
+ refkeys: symbol.refkeys,
125
+ symbol
126
+ };
127
+ });
128
+ } else {
129
+ return parameters.map(param => {
130
+ const symbol = createTSSymbol({
131
+ name: namePolicy.getName(param.name, flags & TSSymbolFlags.TypeSymbol ? "type" : "parameter"),
132
+ refkey: param.refkey,
133
+ tsFlags: flags,
134
+ metadata: param.metadata
135
+ });
136
+ return {
137
+ ...param,
138
+ symbol
139
+ };
140
+ });
141
+ }
142
+ }
143
+
144
+ /**
145
+ * Represent type parameters
146
+ *
147
+ * @example
148
+ * ```ts
149
+ * <A, B extends string>
150
+ * ```
151
+ */
152
+ export const TypeParameters = taggedComponent(typeParametersTag, function TypeParameters(props) {
153
+ if (props.children) {
154
+ return props.children;
155
+ }
156
+ if (!props.parameters) {
157
+ return undefined;
158
+ }
159
+ const typeParameters = normalizeAndDeclareParameters(props.parameters);
160
+ onCleanup(() => {
161
+ for (const param of typeParameters) {
162
+ param.symbol.binder.deleteSymbol(param.symbol);
163
+ }
164
+ });
165
+ return ["<", _$createIntrinsic("group", {
166
+ get children() {
167
+ return _$createComponent(Indent, {
168
+ softline: true,
169
+ get children() {
170
+ return [_$createComponent(For, {
171
+ each: typeParameters,
172
+ comma: true,
173
+ line: true,
174
+ children: param => typeParameter(param)
175
+ }), _$createIntrinsic("ifBreak", {
176
+ children: ","
177
+ })];
178
+ }
179
+ });
180
+ }
181
+ }), ">"];
182
+ });
183
+ function typeParameter(param) {
184
+ return _$createIntrinsic("group", {
185
+ get children() {
186
+ return [_$memo(() => param.symbol.name), _$createComponent(Show, {
187
+ get when() {
188
+ return !!param.extends;
189
+ },
190
+ get children() {
191
+ return [" ", "extends", _$createIntrinsic("indent", {
192
+ get children() {
193
+ return [" ", _$memo(() => param.extends)];
194
+ }
195
+ })];
196
+ }
197
+ })];
198
+ }
199
+ });
200
+ }
201
+ export function getReturnType(returnType, options = {
202
+ async: false
203
+ }) {
204
+ if (returnType) {
205
+ return options.async ? code`Promise<${returnType}>` : returnType;
206
+ }
207
+ }
@@ -1,6 +1,4 @@
1
- import { createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
2
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
3
- import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
1
+ import { memo as _$memo, createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
4
2
  import { For, Indent, Wrap } from "@alloy-js/core";
5
3
  export function FunctionCallExpression(props) {
6
4
  return _$createIntrinsic("group", {
@@ -27,5 +25,4 @@ export function FunctionCallExpression(props) {
27
25
  }), ")"];
28
26
  }
29
27
  });
30
- }
31
- //# sourceMappingURL=FunctionCallExpression.js.map
28
+ }
@@ -1,14 +1,10 @@
1
1
  import { Children } from "@alloy-js/core/jsx-runtime";
2
- import { ParameterDescriptor } from "../parameter-descriptor.js";
3
2
  import { CallSignatureProps } from "./CallSignature.jsx";
4
3
  import { BaseDeclarationProps } from "./Declaration.js";
5
4
  export interface FunctionDeclarationProps extends BaseDeclarationProps, CallSignatureProps {
6
5
  async?: boolean;
7
6
  children?: Children;
8
7
  }
9
- export declare const functionParametersTag: unique symbol;
10
- export declare const functionTypeParametersTag: unique symbol;
11
- export declare const functionBodyTag: unique symbol;
12
8
  /**
13
9
  * A TypeScript function declaration.
14
10
  *
@@ -27,19 +23,8 @@ export declare const functionBodyTag: unique symbol;
27
23
  */
28
24
  export declare function FunctionDeclaration(props: FunctionDeclarationProps): Children;
29
25
  export declare namespace FunctionDeclaration {
30
- var TypeParameters: import("@alloy-js/core").Component<FunctionTypeParametersProps>;
31
- var Parameters: import("@alloy-js/core").Component<FunctionParametersProps>;
32
- var Body: import("@alloy-js/core").Component<FunctionBodyProps>;
33
- }
34
- export interface FunctionTypeParametersProps {
35
- parameters?: ParameterDescriptor[] | string[];
36
- children?: Children;
37
- }
38
- export interface FunctionParametersProps {
39
- parameters?: ParameterDescriptor[] | string[];
40
- children?: Children;
41
- }
42
- export interface FunctionBodyProps {
43
- children?: Children;
26
+ var TypeParameters: import("@alloy-js/core").Component<import("./FunctionBase.jsx").TypeParametersProps> & Required<Pick<import("@alloy-js/core").Component<import("./FunctionBase.jsx").TypeParametersProps>, "tag">>;
27
+ var Parameters: import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionParametersProps> & Required<Pick<import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionParametersProps>, "tag">>;
28
+ var Body: import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionBodyProps> & Required<Pick<import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionBodyProps>, "tag">>;
44
29
  }
45
30
  //# sourceMappingURL=FunctionDeclaration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FunctionDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/FunctionDeclaration.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,QAAQ,EAAa,MAAM,4BAA4B,CAAC;AAEjE,OAAO,EACL,mBAAmB,EAEpB,MAAM,4BAA4B,CAAC;AAOpC,OAAO,EAAiB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAe,MAAM,kBAAkB,CAAC;AAIrE,MAAM,WAAW,wBACf,SAAQ,oBAAoB,EAC1B,kBAAkB;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,eAAO,MAAM,qBAAqB,eAAW,CAAC;AAC9C,eAAO,MAAM,yBAAyB,eAAW,CAAC;AAClD,eAAO,MAAM,eAAe,eAAW,CAAC;AAExC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,YAyClE;yBAzCe,mBAAmB;;;;;AAiHnC,MAAM,WAAW,2BAA2B;IAC1C,UAAU,CAAC,EAAE,mBAAmB,EAAE,GAAG,MAAM,EAAE,CAAC;IAC9C,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAmDD,MAAM,WAAW,uBAAuB;IACtC,UAAU,CAAC,EAAE,mBAAmB,EAAE,GAAG,MAAM,EAAE,CAAC;IAC9C,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAmCD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB"}
1
+ {"version":3,"file":"FunctionDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/FunctionDeclaration.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD,OAAO,EAAiB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAe,MAAM,kBAAkB,CAAC;AAUrE,MAAM,WAAW,wBACf,SAAQ,oBAAoB,EAC1B,kBAAkB;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,YAyClE;yBAzCe,mBAAmB"}