@alloy-js/typescript 0.10.0 → 0.12.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 (244) hide show
  1. package/CHANGELOG.md +28 -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.d.ts +2 -0
  11. package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
  12. package/dist/src/components/ClassDeclaration.js +16 -8
  13. package/dist/src/components/CommaList.js +2 -5
  14. package/dist/src/components/Declaration.js +3 -5
  15. package/dist/src/components/EnumDeclaration.js +2 -5
  16. package/dist/src/components/EnumMember.js +2 -4
  17. package/dist/src/components/ExportStatement.js +1 -2
  18. package/dist/src/components/FunctionBase.d.ts +60 -0
  19. package/dist/src/components/FunctionBase.d.ts.map +1 -0
  20. package/dist/src/components/FunctionBase.js +217 -0
  21. package/dist/src/components/FunctionCallExpression.js +2 -5
  22. package/dist/src/components/FunctionDeclaration.d.ts +3 -18
  23. package/dist/src/components/FunctionDeclaration.d.ts.map +1 -1
  24. package/dist/src/components/FunctionDeclaration.js +9 -157
  25. package/dist/src/components/FunctionExpression.d.ts +39 -0
  26. package/dist/src/components/FunctionExpression.d.ts.map +1 -0
  27. package/dist/src/components/FunctionExpression.js +66 -0
  28. package/dist/src/components/FunctionType.d.ts +38 -0
  29. package/dist/src/components/FunctionType.d.ts.map +1 -0
  30. package/dist/src/components/FunctionType.js +77 -0
  31. package/dist/src/components/IfStatement.js +2 -4
  32. package/dist/src/components/ImportStatement.d.ts.map +1 -1
  33. package/dist/src/components/ImportStatement.js +10 -4
  34. package/dist/src/components/Interface.d.ts +3 -2
  35. package/dist/src/components/Interface.d.ts.map +1 -1
  36. package/dist/src/components/Interface.js +40 -15
  37. package/dist/src/components/InterfaceMethod.d.ts +43 -0
  38. package/dist/src/components/InterfaceMethod.d.ts.map +1 -0
  39. package/dist/src/components/InterfaceMethod.js +87 -0
  40. package/dist/src/components/JSDoc.js +1 -2
  41. package/dist/src/components/JSDocComment.js +3 -5
  42. package/dist/src/components/JSDocExample.js +2 -5
  43. package/dist/src/components/JSDocParam.js +2 -5
  44. package/dist/src/components/MemberChainExpression.js +2 -4
  45. package/dist/src/components/MemberDeclaration.d.ts +34 -0
  46. package/dist/src/components/MemberDeclaration.d.ts.map +1 -0
  47. package/dist/src/components/MemberDeclaration.js +29 -0
  48. package/dist/src/components/MemberExpression.d.ts.map +1 -1
  49. package/dist/src/components/MemberExpression.js +5 -7
  50. package/dist/src/components/ObjectExpression.js +2 -5
  51. package/dist/src/components/PackageDirectory.js +2 -5
  52. package/dist/src/components/PackageJson.js +1 -2
  53. package/dist/src/components/PropertyName.js +1 -2
  54. package/dist/src/components/Reference.d.ts +8 -1
  55. package/dist/src/components/Reference.d.ts.map +1 -1
  56. package/dist/src/components/Reference.js +8 -4
  57. package/dist/src/components/SingleLineCommentBlock.js +2 -4
  58. package/dist/src/components/SourceFile.js +2 -4
  59. package/dist/src/components/SwitchStatement.js +2 -5
  60. package/dist/src/components/TsConfigJson.js +1 -2
  61. package/dist/src/components/TypeDeclaration.d.ts +1 -1
  62. package/dist/src/components/TypeDeclaration.d.ts.map +1 -1
  63. package/dist/src/components/TypeDeclaration.js +4 -7
  64. package/dist/src/components/TypeRefContext.d.ts +22 -0
  65. package/dist/src/components/TypeRefContext.d.ts.map +1 -0
  66. package/dist/src/components/TypeRefContext.js +41 -0
  67. package/dist/src/components/ValueExpression.js +1 -2
  68. package/dist/src/components/VarDeclaration.d.ts +1 -0
  69. package/dist/src/components/VarDeclaration.d.ts.map +1 -1
  70. package/dist/src/components/VarDeclaration.js +11 -8
  71. package/dist/src/components/index.d.ts +7 -0
  72. package/dist/src/components/index.d.ts.map +1 -1
  73. package/dist/src/components/index.js +7 -1
  74. package/dist/src/components/stc/index.d.ts +8 -0
  75. package/dist/src/components/stc/index.d.ts.map +1 -1
  76. package/dist/src/components/stc/index.js +9 -2
  77. package/dist/src/context/private-scope.js +1 -2
  78. package/dist/src/context/type-ref-context.d.ts +15 -0
  79. package/dist/src/context/type-ref-context.d.ts.map +1 -0
  80. package/dist/src/context/type-ref-context.js +12 -0
  81. package/dist/src/create-package.js +1 -2
  82. package/dist/src/index.js +1 -2
  83. package/dist/src/name-conflict-resolver.js +1 -2
  84. package/dist/src/name-policy.js +1 -2
  85. package/dist/src/parameter-descriptor.d.ts +33 -17
  86. package/dist/src/parameter-descriptor.d.ts.map +1 -1
  87. package/dist/src/source-directory-data.js +1 -2
  88. package/dist/src/symbols/index.js +1 -2
  89. package/dist/src/symbols/reference.d.ts +4 -1
  90. package/dist/src/symbols/reference.d.ts.map +1 -1
  91. package/dist/src/symbols/reference.js +13 -8
  92. package/dist/src/symbols/scopes.js +1 -2
  93. package/dist/src/symbols/ts-member-scope.js +1 -2
  94. package/dist/src/symbols/ts-module-scope.d.ts +4 -1
  95. package/dist/src/symbols/ts-module-scope.d.ts.map +1 -1
  96. package/dist/src/symbols/ts-module-scope.js +11 -5
  97. package/dist/src/symbols/ts-output-symbol.d.ts +2 -1
  98. package/dist/src/symbols/ts-output-symbol.d.ts.map +1 -1
  99. package/dist/src/symbols/ts-output-symbol.js +2 -2
  100. package/dist/src/symbols/ts-package-scope.js +1 -2
  101. package/dist/src/utils.js +1 -2
  102. package/dist/test/array.test.js +105 -0
  103. package/dist/test/arrow-function.test.d.ts +2 -0
  104. package/dist/test/arrow-function.test.d.ts.map +1 -0
  105. package/dist/test/arrow-function.test.js +194 -0
  106. package/dist/test/barrel.test.js +53 -0
  107. package/dist/test/basic.test.js +91 -0
  108. package/dist/test/block-scope.test.js +30 -0
  109. package/dist/test/class.test.js +438 -0
  110. package/dist/test/enum-jsdoc.test.js +88 -0
  111. package/dist/test/enum.test.js +247 -0
  112. package/dist/test/externals.test.js +145 -0
  113. package/dist/test/function-call-expression.test.js +87 -0
  114. package/dist/test/function-declaration-jsdoc.test.js +91 -0
  115. package/dist/test/function-declaration.test.js +228 -0
  116. package/dist/test/function-expression.test.d.ts +2 -0
  117. package/dist/test/function-expression.test.d.ts.map +1 -0
  118. package/dist/test/function-expression.test.js +194 -0
  119. package/dist/test/function-type.test.d.ts +2 -0
  120. package/dist/test/function-type.test.d.ts.map +1 -0
  121. package/dist/test/function-type.test.js +122 -0
  122. package/dist/test/if-statement.test.js +25 -0
  123. package/dist/test/imports.test.d.ts.map +1 -1
  124. package/dist/test/imports.test.js +640 -0
  125. package/dist/test/interface-jsdoc.test.js +178 -0
  126. package/dist/test/interface.test.d.ts.map +1 -1
  127. package/dist/test/interface.test.js +490 -0
  128. package/dist/test/jscomment.test.js +70 -0
  129. package/dist/test/jsdoc.test.js +134 -0
  130. package/dist/test/jsdocparam.test.js +164 -0
  131. package/dist/test/member-chain.test.js +141 -0
  132. package/dist/test/member-expression.test.js +575 -0
  133. package/dist/test/name-conflict.test.js +108 -0
  134. package/dist/test/name-policy.test.js +122 -0
  135. package/dist/test/package-external.test.js +196 -0
  136. package/dist/test/package-json.test.js +93 -0
  137. package/dist/test/package.test.js +136 -0
  138. package/dist/test/reference.test.js +81 -0
  139. package/dist/test/source-file.test.js +36 -0
  140. package/dist/test/switch-statement.test.js +61 -0
  141. package/dist/test/utils.js +45 -0
  142. package/dist/test/value-expression.test.js +30 -0
  143. package/dist/test/values.test.js +351 -0
  144. package/dist/test/var-declaration-jsdoc.test.js +50 -0
  145. package/dist/test/var-declaration.test.js +63 -0
  146. package/dist/test/vitest.d.js +1 -0
  147. package/dist/tsconfig.tsbuildinfo +1 -1
  148. package/package.json +13 -18
  149. package/src/components/ArrowFunction.tsx +87 -0
  150. package/src/components/ClassDeclaration.tsx +19 -3
  151. package/src/components/Declaration.tsx +1 -1
  152. package/src/components/FunctionBase.tsx +282 -0
  153. package/src/components/FunctionDeclaration.tsx +13 -195
  154. package/src/components/FunctionExpression.tsx +86 -0
  155. package/src/components/FunctionType.tsx +93 -0
  156. package/src/components/ImportStatement.tsx +30 -3
  157. package/src/components/Interface.tsx +58 -23
  158. package/src/components/InterfaceMethod.tsx +96 -0
  159. package/src/components/JSDocComment.tsx +1 -1
  160. package/src/components/MemberDeclaration.tsx +76 -0
  161. package/src/components/MemberExpression.tsx +7 -2
  162. package/src/components/Reference.tsx +12 -2
  163. package/src/components/TypeDeclaration.tsx +16 -13
  164. package/src/components/TypeRefContext.tsx +49 -0
  165. package/src/components/VarDeclaration.tsx +6 -2
  166. package/src/components/index.ts +11 -0
  167. package/src/components/stc/index.ts +8 -0
  168. package/src/context/type-ref-context.tsx +19 -0
  169. package/src/parameter-descriptor.ts +35 -17
  170. package/src/symbols/reference.ts +21 -6
  171. package/src/symbols/ts-module-scope.ts +19 -4
  172. package/src/symbols/ts-output-symbol.ts +1 -0
  173. package/temp/api.json +4999 -2681
  174. package/test/arrow-function.test.tsx +188 -0
  175. package/test/class.test.tsx +5 -6
  176. package/test/enum-jsdoc.test.tsx +6 -6
  177. package/test/function-call-expression.test.tsx +1 -2
  178. package/test/function-declaration-jsdoc.test.tsx +3 -3
  179. package/test/function-declaration.test.tsx +1 -2
  180. package/test/function-expression.test.tsx +195 -0
  181. package/test/function-type.test.tsx +118 -0
  182. package/test/imports.test.tsx +165 -1
  183. package/test/interface-jsdoc.test.tsx +9 -9
  184. package/test/interface.test.tsx +256 -6
  185. package/test/jsdoc.test.tsx +5 -5
  186. package/test/jsdocparam.test.tsx +8 -8
  187. package/test/member-expression.test.tsx +171 -2
  188. package/test/var-declaration-jsdoc.test.tsx +3 -3
  189. package/test/var-declaration.test.tsx +1 -1
  190. package/tsdoc-metadata.json +1 -1
  191. package/babel.config.cjs +0 -4
  192. package/dist/src/builtins/index.js.map +0 -1
  193. package/dist/src/builtins/node.js.map +0 -1
  194. package/dist/src/components/ArrayExpression.js.map +0 -1
  195. package/dist/src/components/BarrelFile.js.map +0 -1
  196. package/dist/src/components/BlockScope.js.map +0 -1
  197. package/dist/src/components/CallSignature.js.map +0 -1
  198. package/dist/src/components/ClassDeclaration.js.map +0 -1
  199. package/dist/src/components/CommaList.js.map +0 -1
  200. package/dist/src/components/Declaration.js.map +0 -1
  201. package/dist/src/components/EnumDeclaration.js.map +0 -1
  202. package/dist/src/components/EnumMember.js.map +0 -1
  203. package/dist/src/components/ExportStatement.js.map +0 -1
  204. package/dist/src/components/FunctionCallExpression.js.map +0 -1
  205. package/dist/src/components/FunctionDeclaration.js.map +0 -1
  206. package/dist/src/components/IfStatement.js.map +0 -1
  207. package/dist/src/components/ImportStatement.js.map +0 -1
  208. package/dist/src/components/Interface.js.map +0 -1
  209. package/dist/src/components/JSDoc.js.map +0 -1
  210. package/dist/src/components/JSDocComment.js.map +0 -1
  211. package/dist/src/components/JSDocExample.js.map +0 -1
  212. package/dist/src/components/JSDocParam.js.map +0 -1
  213. package/dist/src/components/MemberChainExpression.js.map +0 -1
  214. package/dist/src/components/MemberExpression.js.map +0 -1
  215. package/dist/src/components/ObjectExpression.js.map +0 -1
  216. package/dist/src/components/PackageDirectory.js.map +0 -1
  217. package/dist/src/components/PackageJson.js.map +0 -1
  218. package/dist/src/components/PropertyName.js.map +0 -1
  219. package/dist/src/components/Reference.js.map +0 -1
  220. package/dist/src/components/SingleLineCommentBlock.js.map +0 -1
  221. package/dist/src/components/SourceFile.js.map +0 -1
  222. package/dist/src/components/SwitchStatement.js.map +0 -1
  223. package/dist/src/components/TsConfigJson.js.map +0 -1
  224. package/dist/src/components/TypeDeclaration.js.map +0 -1
  225. package/dist/src/components/ValueExpression.js.map +0 -1
  226. package/dist/src/components/VarDeclaration.js.map +0 -1
  227. package/dist/src/components/index.js.map +0 -1
  228. package/dist/src/components/stc/index.js.map +0 -1
  229. package/dist/src/context/index.js.map +0 -1
  230. package/dist/src/context/private-scope.js.map +0 -1
  231. package/dist/src/create-package.js.map +0 -1
  232. package/dist/src/index.js.map +0 -1
  233. package/dist/src/name-conflict-resolver.js.map +0 -1
  234. package/dist/src/name-policy.js.map +0 -1
  235. package/dist/src/parameter-descriptor.js.map +0 -1
  236. package/dist/src/source-directory-data.js.map +0 -1
  237. package/dist/src/symbols/index.js.map +0 -1
  238. package/dist/src/symbols/reference.js.map +0 -1
  239. package/dist/src/symbols/scopes.js.map +0 -1
  240. package/dist/src/symbols/ts-member-scope.js.map +0 -1
  241. package/dist/src/symbols/ts-module-scope.js.map +0 -1
  242. package/dist/src/symbols/ts-output-symbol.js.map +0 -1
  243. package/dist/src/symbols/ts-package-scope.js.map +0 -1
  244. package/dist/src/utils.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog - @alloy-js/typescript
2
2
 
3
+ ## 0.12.0
4
+
5
+ ### Bug Fixes
6
+
7
+ - [#121](https://github.com/alloy-framework/alloy/pull/121) JS Doc comment close with `*/` instead of `**/`
8
+
9
+ ### Features
10
+
11
+ - [#117](https://github.com/alloy-framework/alloy/pull/117) Add nullish to TS Symbol flags
12
+ - [#125](https://github.com/alloy-framework/alloy/pull/125) Automatically enter a type context when inside of interface, function type, type declaration, etc. This allow referenced used in there to automatically add the `type` keyword in the import
13
+ - [#124](https://github.com/alloy-framework/alloy/pull/124) Add `type` prop on `Reference` component to mark this reference as a type only reference allowing imports to be specialized in type import
14
+
15
+
16
+ ## 0.11.0
17
+
18
+ ### Bug Fixes
19
+
20
+ - [#92](https://github.com/alloy-framework/alloy/pull/92) Missing export of `IfStatement`, `ElseIfClause` and `ElseClause`
21
+ - [#112](https://github.com/alloy-framework/alloy/pull/112) Fix interface member references
22
+
23
+ ### Features
24
+
25
+ - [#112](https://github.com/alloy-framework/alloy/pull/112) Add new `<MemberDeclaration />` component. A wrapper around alloy `<MemberDeclaration />` with TypeScript specific props.
26
+ - [#91](https://github.com/alloy-framework/alloy/pull/91) Add new `<FunctionExpression />` and `<ArrowFunctionExpression />` components supporting the various formm of function expressions
27
+ - [#110](https://github.com/alloy-framework/alloy/pull/110) Add `<InterfaceMethod />` and `<FunctionType />` component
28
+ - [#105](https://github.com/alloy-framework/alloy/pull/105) Updated dependencies
29
+
30
+
3
31
  ## 0.10.0
4
32
 
5
33
  ### 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
+ }
@@ -48,10 +48,12 @@ export interface ClassMemberProps {
48
48
  static?: boolean;
49
49
  children?: Children;
50
50
  doc?: Children;
51
+ nullish?: boolean;
51
52
  }
52
53
  export declare function ClassMember(props: ClassMemberProps): Children;
53
54
  export interface ClassFieldProps extends ClassMemberProps {
54
55
  type?: Children;
56
+ optional?: boolean;
55
57
  children?: Children;
56
58
  }
57
59
  export declare function ClassField(props: ClassFieldProps): Children;
@@ -1 +1 @@
1
- {"version":3,"file":"ClassDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/ClassDeclaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAKR,MAAM,EAKP,MAAM,gBAAgB,CAAC;AAOxB,OAAO,EAAiB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAe,MAAM,mBAAmB,CAAC;AAKtE,MAAM,WAAW,qBAAsB,SAAQ,oBAAoB;IACjE,OAAO,CAAC,EAAE,QAAQ,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,YA6B5D;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,GAAG,CAAC,EAAE,QAAQ,CAAC;CAChB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,YAgDlD;AAED,MAAM,WAAW,eAAgB,SAAQ,gBAAgB;IACvD,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,YAWhD;AAED,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB,EAAE,kBAAkB;IAC5E,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,YAwBlD"}
1
+ {"version":3,"file":"ClassDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/ClassDeclaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAKR,MAAM,EAKP,MAAM,gBAAgB,CAAC;AAOxB,OAAO,EAAiB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAe,MAAM,mBAAmB,CAAC;AAMtE,MAAM,WAAW,qBAAsB,SAAQ,oBAAoB;IACjE,OAAO,CAAC,EAAE,QAAQ,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,YA6B5D;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,YAuDlD;AAED,MAAM,WAAW,eAAgB,SAAQ,gBAAgB;IACvD,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,YAiBhD;AAED,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB,EAAE,kBAAkB;IAC5E,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,YAwBlD"}
@@ -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";
@@ -12,6 +9,7 @@ import { Declaration } from "./Declaration.js";
12
9
  import { JSDoc } from "./JSDoc.js";
13
10
  import { JSDocParams } from "./JSDocParam.js";
14
11
  import { PropertyName } from "./PropertyName.js";
12
+ import { TypeRefContext } from "./TypeRefContext.js";
15
13
  /**
16
14
  * Create a TypeScript class declaration.
17
15
  *
@@ -102,12 +100,16 @@ export function ClassMember(props) {
102
100
  const memberScope = useMemberScope();
103
101
  scope = props.static ? memberScope.staticMembers : memberScope.instanceMembers;
104
102
  }
103
+ let tsFlags = props.jsPrivate ? TSSymbolFlags.PrivateMember : TSSymbolFlags.None;
104
+ if (props.nullish) {
105
+ tsFlags |= TSSymbolFlags.Nullish;
106
+ }
105
107
  const sym = createTSSymbol({
106
108
  name,
107
109
  scope,
108
110
  refkey: props.refkey,
109
111
  flags,
110
- tsFlags: props.jsPrivate ? TSSymbolFlags.PrivateMember : TSSymbolFlags.None
112
+ tsFlags
111
113
  });
112
114
  return [_$createComponent(Show, {
113
115
  get when() {
@@ -128,9 +130,16 @@ export function ClassMember(props) {
128
130
  })];
129
131
  }
130
132
  export function ClassField(props) {
131
- const typeSection = props.type && [": ", _$memo(() => props.type)];
133
+ const optionality = props.optional ? "?" : "";
134
+ const typeSection = props.type && [optionality, ": ", _$createComponent(TypeRefContext, {
135
+ get children() {
136
+ return props.type;
137
+ }
138
+ })];
132
139
  const initializerSection = props.children && [" = ", _$memo(() => props.children)];
140
+ const nullish = props.nullish ?? props.optional;
133
141
  return _$createComponent(ClassMember, _$mergeProps(props, {
142
+ nullish: nullish,
134
143
  get children() {
135
144
  return [_$createComponent(PropertyName, {}), typeSection, initializerSection];
136
145
  }
@@ -175,5 +184,4 @@ export function ClassMethod(props) {
175
184
  })];
176
185
  }
177
186
  }))];
178
- }
179
- //# sourceMappingURL=ClassDeclaration.js.map
187
+ }
@@ -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;AAYrE,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;AA+FF;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,0IAkC1B,CAAC;AAkBF,wBAAgB,aAAa,CAC3B,UAAU,EAAE,QAAQ,GAAG,SAAS,EAChC,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAqB,YAKhD"}
@@ -0,0 +1,217 @@
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
+ import { TypeRefContext } from "./TypeRefContext.js";
6
+ const functionParametersTag = Symbol();
7
+ const typeParametersTag = Symbol();
8
+ const functionBodyTag = Symbol();
9
+
10
+ /** Props for function parameters */
11
+
12
+ /** Props for a function type(FunctionType or InterfaceMethod) */
13
+
14
+ /** Props for type parameters */
15
+
16
+ export const FunctionBody = taggedComponent(functionBodyTag, function Body(props) {
17
+ return _$createComponent(Block, {
18
+ get children() {
19
+ return props.children;
20
+ }
21
+ });
22
+ });
23
+
24
+ /**
25
+ * Represent function parameters(FunctionDeclaration, FunctionExpression, ArrowFunction, etc.)
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * a: string, b: string = "abc", c?: string,
30
+ * ```
31
+ */
32
+ export const FunctionParameters = taggedComponent(functionParametersTag, function Parameters(props) {
33
+ if (props.children) {
34
+ return props.children;
35
+ }
36
+ const parameters = normalizeAndDeclareParameters(props.parameters ?? []);
37
+ return _$createIntrinsic("group", {
38
+ get children() {
39
+ return _$createComponent(Indent, {
40
+ softline: true,
41
+ trailingBreak: true,
42
+ get children() {
43
+ return [_$createComponent(For, {
44
+ each: parameters,
45
+ comma: true,
46
+ line: true,
47
+ children: param => parameter(param)
48
+ }), _$createIntrinsic("ifBreak", {
49
+ children: ","
50
+ })];
51
+ }
52
+ });
53
+ }
54
+ });
55
+ });
56
+
57
+ /**
58
+ * Represent parameters for a function type(FunctionType or InterfaceMethod)
59
+ * This differ from {@link FunctionParameters} in that it doesn't allow default values.
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * a: string, b?: string
64
+ * ```
65
+ */
66
+ export const FunctionTypeParameters = taggedComponent(functionParametersTag, function Parameters(props) {
67
+ if (props.children) {
68
+ return props.children;
69
+ }
70
+ const parameters = normalizeAndDeclareParameters(props.parameters ?? []);
71
+ return _$createIntrinsic("group", {
72
+ get children() {
73
+ return _$createComponent(Indent, {
74
+ softline: true,
75
+ trailingBreak: true,
76
+ get children() {
77
+ return [_$createComponent(For, {
78
+ each: parameters,
79
+ comma: true,
80
+ line: true,
81
+ children: param => parameter(param)
82
+ }), _$createIntrinsic("ifBreak", {
83
+ children: ","
84
+ })];
85
+ }
86
+ });
87
+ }
88
+ });
89
+ });
90
+ function parameter(param) {
91
+ return _$createIntrinsic("group", {
92
+ get children() {
93
+ return [_$memo(() => param.symbol.name), _$createComponent(Show, {
94
+ get when() {
95
+ return !!param.optional;
96
+ },
97
+ children: "?"
98
+ }), _$createComponent(Show, {
99
+ get when() {
100
+ return !!param.type;
101
+ },
102
+ get children() {
103
+ return _$createIntrinsic("indent", {
104
+ get children() {
105
+ return [": ", _$createComponent(TypeRefContext, {
106
+ get children() {
107
+ return param.type;
108
+ }
109
+ })];
110
+ }
111
+ });
112
+ }
113
+ })];
114
+ }
115
+ });
116
+ }
117
+ function normalizeAndDeclareParameters(parameters, flags = TSSymbolFlags.ParameterSymbol) {
118
+ const namePolicy = useTSNamePolicy();
119
+ if (parameters.length === 0) {
120
+ return [];
121
+ }
122
+ if (typeof parameters[0] === "string") {
123
+ return parameters.map(paramName => {
124
+ const symbol = createTSSymbol({
125
+ name: namePolicy.getName(paramName, flags & TSSymbolFlags.TypeSymbol ? "type" : "parameter"),
126
+ tsFlags: flags
127
+ });
128
+ return {
129
+ refkeys: symbol.refkeys,
130
+ symbol
131
+ };
132
+ });
133
+ } else {
134
+ return parameters.map(param => {
135
+ const nullishFlag = param.nullish ?? param.optional ? TSSymbolFlags.Nullish : TSSymbolFlags.None;
136
+ const symbol = createTSSymbol({
137
+ name: namePolicy.getName(param.name, flags & TSSymbolFlags.TypeSymbol ? "type" : "parameter"),
138
+ refkey: param.refkey,
139
+ tsFlags: flags | nullishFlag,
140
+ metadata: param.metadata
141
+ });
142
+ return {
143
+ ...param,
144
+ symbol
145
+ };
146
+ });
147
+ }
148
+ }
149
+
150
+ /**
151
+ * Represent type parameters
152
+ *
153
+ * @example
154
+ * ```ts
155
+ * <A, B extends string>
156
+ * ```
157
+ */
158
+ export const TypeParameters = taggedComponent(typeParametersTag, function TypeParameters(props) {
159
+ if (props.children) {
160
+ return props.children;
161
+ }
162
+ if (!props.parameters) {
163
+ return undefined;
164
+ }
165
+ const typeParameters = normalizeAndDeclareParameters(props.parameters);
166
+ onCleanup(() => {
167
+ for (const param of typeParameters) {
168
+ param.symbol.binder.deleteSymbol(param.symbol);
169
+ }
170
+ });
171
+ return ["<", _$createIntrinsic("group", {
172
+ get children() {
173
+ return _$createComponent(Indent, {
174
+ softline: true,
175
+ get children() {
176
+ return [_$createComponent(For, {
177
+ each: typeParameters,
178
+ comma: true,
179
+ line: true,
180
+ children: param => typeParameter(param)
181
+ }), _$createIntrinsic("ifBreak", {
182
+ children: ","
183
+ })];
184
+ }
185
+ });
186
+ }
187
+ }), ">"];
188
+ });
189
+ function typeParameter(param) {
190
+ return _$createIntrinsic("group", {
191
+ get children() {
192
+ return [_$memo(() => param.symbol.name), _$createComponent(Show, {
193
+ get when() {
194
+ return !!param.extends;
195
+ },
196
+ get children() {
197
+ return [" ", "extends", _$createIntrinsic("indent", {
198
+ get children() {
199
+ return [" ", _$createComponent(TypeRefContext, {
200
+ get children() {
201
+ return param.extends;
202
+ }
203
+ })];
204
+ }
205
+ })];
206
+ }
207
+ })];
208
+ }
209
+ });
210
+ }
211
+ export function getReturnType(returnType, options = {
212
+ async: false
213
+ }) {
214
+ if (returnType) {
215
+ return options.async ? code`Promise<${returnType}>` : returnType;
216
+ }
217
+ }
@@ -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
+ }