@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
@@ -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"}
@@ -1,20 +1,11 @@
1
- import { mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
2
- import { createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
3
- import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
4
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
5
- import { Block, childrenArray, code, findKeyedChild, findUnkeyedChildren, For, Indent, Name, Prose, Scope, Show, taggedComponent } from "@alloy-js/core";
6
- import { onCleanup } from "@alloy-js/core/jsx-runtime";
7
- import { useTSNamePolicy } from "../name-policy.js";
8
- import { createTSSymbol, TSSymbolFlags } from "../symbols/index.js";
1
+ import { createComponent as _$createComponent, memo as _$memo, createIntrinsic as _$createIntrinsic, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
2
+ import { childrenArray, findKeyedChild, findUnkeyedChildren, Name, Prose, Scope, Show } from "@alloy-js/core";
9
3
  import { getCallSignatureProps } from "../utils.js";
10
4
  import { CallSignature } from "./CallSignature.js";
11
5
  import { Declaration } from "./Declaration.js";
6
+ import { FunctionBody, FunctionParameters, getReturnType, TypeParameters } from "./FunctionBase.js";
12
7
  import { JSDoc } from "./JSDoc.js";
13
8
  import { JSDocParams } from "./JSDocParam.js";
14
- export const functionParametersTag = Symbol();
15
- export const functionTypeParametersTag = Symbol();
16
- export const functionBodyTag = Symbol();
17
-
18
9
  /**
19
10
  * A TypeScript function declaration.
20
11
  *
@@ -33,9 +24,9 @@ export const functionBodyTag = Symbol();
33
24
  */
34
25
  export function FunctionDeclaration(props) {
35
26
  const children = childrenArray(() => props.children);
36
- const typeParametersChildren = findKeyedChild(children, functionTypeParametersTag) ?? undefined;
37
- const parametersChildren = findKeyedChild(children, functionParametersTag) ?? undefined;
38
- const bodyChildren = findKeyedChild(children, functionBodyTag) ?? undefined;
27
+ const typeParametersChildren = findKeyedChild(children, TypeParameters.tag) ?? undefined;
28
+ const parametersChildren = findKeyedChild(children, FunctionParameters.tag) ?? undefined;
29
+ const bodyChildren = findKeyedChild(children, FunctionBody.tag) ?? undefined;
39
30
  const filteredChildren = findUnkeyedChildren(children);
40
31
  const returnType = getReturnType(props.returnType, {
41
32
  async: props.async
@@ -84,145 +75,6 @@ export function FunctionDeclaration(props) {
84
75
  }
85
76
  }))];
86
77
  }
87
- function getReturnType(returnType, options = {
88
- async: false
89
- }) {
90
- if (returnType) {
91
- return options.async ? code`Promise<${returnType}>` : returnType;
92
- }
93
- }
94
- function normalizeAndDeclareParameters(parameters, flags = TSSymbolFlags.ParameterSymbol) {
95
- const namePolicy = useTSNamePolicy();
96
- if (parameters.length === 0) {
97
- return [];
98
- }
99
- if (typeof parameters[0] === "string") {
100
- return parameters.map(paramName => {
101
- const symbol = createTSSymbol({
102
- name: namePolicy.getName(paramName, flags & TSSymbolFlags.TypeSymbol ? "type" : "parameter"),
103
- tsFlags: flags
104
- });
105
- return {
106
- refkeys: symbol.refkeys,
107
- symbol
108
- };
109
- });
110
- } else {
111
- return parameters.map(param => {
112
- const symbol = createTSSymbol({
113
- name: namePolicy.getName(param.name, flags & TSSymbolFlags.TypeSymbol ? "type" : "parameter"),
114
- refkey: param.refkey,
115
- tsFlags: flags,
116
- metadata: param.metadata
117
- });
118
- return {
119
- ...param,
120
- symbol
121
- };
122
- });
123
- }
124
- }
125
- FunctionDeclaration.TypeParameters = taggedComponent(functionTypeParametersTag, function TypeParameters(props) {
126
- if (props.children) {
127
- return props.children;
128
- }
129
- if (!props.parameters) {
130
- return undefined;
131
- }
132
- const typeParameters = normalizeAndDeclareParameters(props.parameters);
133
- onCleanup(() => {
134
- for (const param of typeParameters) {
135
- param.symbol.binder.deleteSymbol(param.symbol);
136
- }
137
- });
138
- return ["<", _$createIntrinsic("group", {
139
- get children() {
140
- return _$createComponent(Indent, {
141
- softline: true,
142
- get children() {
143
- return [_$createComponent(For, {
144
- each: typeParameters,
145
- comma: true,
146
- line: true,
147
- children: param => typeParameter(param)
148
- }), _$createIntrinsic("ifBreak", {
149
- children: ","
150
- })];
151
- }
152
- });
153
- }
154
- }), ">"];
155
- });
156
- function typeParameter(param) {
157
- return _$createIntrinsic("group", {
158
- get children() {
159
- return [_$memo(() => param.symbol.name), _$createComponent(Show, {
160
- get when() {
161
- return !!param.extends;
162
- },
163
- get children() {
164
- return [" ", "extends", _$createIntrinsic("indent", {
165
- get children() {
166
- return [" ", _$memo(() => param.extends)];
167
- }
168
- })];
169
- }
170
- })];
171
- }
172
- });
173
- }
174
- FunctionDeclaration.Parameters = taggedComponent(functionParametersTag, function Parameters(props) {
175
- if (props.children) {
176
- return props.children;
177
- }
178
- const parameters = normalizeAndDeclareParameters(props.parameters ?? []);
179
- return _$createIntrinsic("group", {
180
- get children() {
181
- return _$createComponent(Indent, {
182
- softline: true,
183
- trailingBreak: true,
184
- get children() {
185
- return [_$createComponent(For, {
186
- each: parameters,
187
- comma: true,
188
- line: true,
189
- children: param => parameter(param)
190
- }), _$createIntrinsic("ifBreak", {
191
- children: ","
192
- })];
193
- }
194
- });
195
- }
196
- });
197
- });
198
- function parameter(param) {
199
- return _$createIntrinsic("group", {
200
- get children() {
201
- return [_$memo(() => param.symbol.name), _$createComponent(Show, {
202
- get when() {
203
- return !!param.optional;
204
- },
205
- children: "?"
206
- }), _$createComponent(Show, {
207
- get when() {
208
- return !!param.type;
209
- },
210
- get children() {
211
- return _$createIntrinsic("indent", {
212
- get children() {
213
- return [": ", _$memo(() => param.type)];
214
- }
215
- });
216
- }
217
- })];
218
- }
219
- });
220
- }
221
- FunctionDeclaration.Body = taggedComponent(functionBodyTag, function Body(props) {
222
- return _$createComponent(Block, {
223
- get children() {
224
- return props.children;
225
- }
226
- });
227
- });
228
- //# sourceMappingURL=FunctionDeclaration.js.map
78
+ FunctionDeclaration.TypeParameters = TypeParameters;
79
+ FunctionDeclaration.Parameters = FunctionParameters;
80
+ FunctionDeclaration.Body = FunctionBody;
@@ -0,0 +1,39 @@
1
+ import { Children } from "@alloy-js/core/jsx-runtime";
2
+ import { CallSignatureProps } from "./CallSignature.jsx";
3
+ export interface FunctionExpressionProps extends CallSignatureProps {
4
+ async?: boolean;
5
+ children?: Children;
6
+ }
7
+ /**
8
+ * A TypeScript 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 function (a, b) { return a + b; }
19
+ * ```
20
+ * @remarks
21
+ *
22
+ * Providing parameters and type parameters can be accomplished in one of three
23
+ * ways:
24
+ *
25
+ * 1. As an array of {@link ParameterDescriptor}s or
26
+ * {@link TypeParameterDescriptor}s.
27
+ * 2. As raw content via the `parametersChildren` or `typeParametersChildren`
28
+ * props.
29
+ * 3. As a child of this component via the
30
+ * {@link (FunctionExpression:namespace).Parameters} or
31
+ * {@link (FunctionExpression:namespace).TypeParameters} components.
32
+ */
33
+ export declare function FunctionExpression(props: FunctionExpressionProps): Children;
34
+ export declare namespace FunctionExpression {
35
+ var TypeParameters: import("@alloy-js/core").Component<import("./FunctionBase.jsx").TypeParametersProps> & Required<Pick<import("@alloy-js/core").Component<import("./FunctionBase.jsx").TypeParametersProps>, "tag">>;
36
+ var Parameters: import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionParametersProps> & Required<Pick<import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionParametersProps>, "tag">>;
37
+ var Body: import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionBodyProps> & Required<Pick<import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionBodyProps>, "tag">>;
38
+ }
39
+ //# sourceMappingURL=FunctionExpression.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FunctionExpression.d.ts","sourceRoot":"","sources":["../../../src/components/FunctionExpression.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD,OAAO,EAAiB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AASxE,MAAM,WAAW,uBAAwB,SAAQ,kBAAkB;IACjE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,YAiChE;yBAjCe,kBAAkB"}
@@ -0,0 +1,66 @@
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 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 function (a, b) { return a + b; }
19
+ * ```
20
+ * @remarks
21
+ *
22
+ * Providing parameters and type parameters can be accomplished in one of three
23
+ * ways:
24
+ *
25
+ * 1. As an array of {@link ParameterDescriptor}s or
26
+ * {@link TypeParameterDescriptor}s.
27
+ * 2. As raw content via the `parametersChildren` or `typeParametersChildren`
28
+ * props.
29
+ * 3. As a child of this component via the
30
+ * {@link (FunctionExpression:namespace).Parameters} or
31
+ * {@link (FunctionExpression:namespace).TypeParameters} components.
32
+ */
33
+ export function FunctionExpression(props) {
34
+ const children = childrenArray(() => props.children);
35
+ const typeParametersChildren = findKeyedChild(children, TypeParameters.tag) ?? undefined;
36
+ const parametersChildren = findKeyedChild(children, FunctionParameters.tag) ?? undefined;
37
+ const bodyChildren = findKeyedChild(children, FunctionBody.tag) ?? undefined;
38
+ const filteredChildren = findUnkeyedChildren(children);
39
+ const returnType = getReturnType(props.returnType, {
40
+ async: props.async
41
+ });
42
+ const sBody = bodyChildren ?? _$createComponent(FunctionExpression.Body, {
43
+ children: filteredChildren
44
+ });
45
+ const asyncKwd = props.async ? "async " : "";
46
+ const callSignatureProps = getCallSignatureProps(props, {
47
+ parametersChildren,
48
+ typeParametersChildren
49
+ });
50
+ return [_$createComponent(Declaration, _$mergeProps(props, {
51
+ nameKind: "function",
52
+ get children() {
53
+ return [asyncKwd, "function ", _$createComponent(Scope, {
54
+ kind: "function",
55
+ get children() {
56
+ return [_$createComponent(CallSignature, _$mergeProps(callSignatureProps, {
57
+ returnType: returnType
58
+ })), " ", sBody];
59
+ }
60
+ })];
61
+ }
62
+ }))];
63
+ }
64
+ FunctionExpression.TypeParameters = TypeParameters;
65
+ FunctionExpression.Parameters = FunctionParameters;
66
+ FunctionExpression.Body = FunctionBody;
@@ -0,0 +1,38 @@
1
+ import { Children } from "@alloy-js/core/jsx-runtime";
2
+ import { CallSignatureProps } from "./CallSignature.jsx";
3
+ /**
4
+ * Options for {@link FunctionType} component.
5
+ */
6
+ export interface FunctionTypeProps extends CallSignatureProps {
7
+ /** If the method is async */
8
+ readonly async?: boolean;
9
+ /** Documentation for this method. */
10
+ readonly doc?: Children;
11
+ /** Jsx content */
12
+ readonly children?: Children;
13
+ }
14
+ /**
15
+ * A TypeScript function declaration.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * (foo: string, bar: number) => void
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 TypeParameterDescriptor}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 FunctionType.Parameters} or
32
+ * {@link FunctionType.TypeParameters} components.
33
+ */
34
+ export declare const FunctionType: ((props: FunctionTypeProps) => Children) & {
35
+ TypeParameters: import("@alloy-js/core").Component<import("./FunctionBase.jsx").TypeParametersProps> & Required<Pick<import("@alloy-js/core").Component<import("./FunctionBase.jsx").TypeParametersProps>, "tag">>;
36
+ Parameters: import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionTypeParametersProps> & Required<Pick<import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionTypeParametersProps>, "tag">>;
37
+ };
38
+ //# sourceMappingURL=FunctionType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FunctionType.d.ts","sourceRoot":"","sources":["../../../src/components/FunctionType.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD,OAAO,EAAiB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAWxE;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,kBAAkB;IAC3D,6BAA6B;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,qCAAqC;IACrC,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC;IACxB,kBAAkB;IAClB,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CAC9B;AAuCD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,YAAY;;;CAGvB,CAAC"}
@@ -0,0 +1,77 @@
1
+ import { memo as _$memo, createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
2
+ import { childrenArray, findKeyedChild, Prose, Scope, Show } from "@alloy-js/core";
3
+ import { getCallSignatureProps } from "../utils.js";
4
+ import { CallSignature } from "./CallSignature.js";
5
+ import { FunctionParameters, FunctionTypeParameters, getReturnType, TypeParameters } from "./FunctionBase.js";
6
+ import { JSDoc } from "./JSDoc.js";
7
+ import { JSDocParams } from "./JSDocParam.js";
8
+ import { ensureTypeRefContext } from "./TypeRefContext.js";
9
+
10
+ /**
11
+ * Options for {@link FunctionType} component.
12
+ */
13
+
14
+ const FunctionTypeComponent = ensureTypeRefContext(props => {
15
+ const children = childrenArray(() => props.children);
16
+ const typeParametersChildren = findKeyedChild(children, TypeParameters.tag) ?? undefined;
17
+ const parametersChildren = findKeyedChild(children, FunctionParameters.tag) ?? undefined;
18
+ const returnType = getReturnType(props.returnType ?? "void", {
19
+ async: props.async
20
+ });
21
+ const callSignatureProps = getCallSignatureProps(props, {
22
+ parametersChildren,
23
+ typeParametersChildren
24
+ });
25
+ return [_$createComponent(Show, {
26
+ get when() {
27
+ return Boolean(props.doc);
28
+ },
29
+ get children() {
30
+ return [_$createComponent(JSDoc, {
31
+ get children() {
32
+ return [_$memo(() => _$memo(() => !!props.doc)() && _$createComponent(Prose, {
33
+ get children() {
34
+ return props.doc;
35
+ }
36
+ })), _$memo(() => _$memo(() => !!Array.isArray(props.parameters))() && _$createComponent(JSDocParams, {
37
+ get parameters() {
38
+ return props.parameters;
39
+ }
40
+ }))];
41
+ }
42
+ }), _$createIntrinsic("hbr", {})];
43
+ }
44
+ }), _$createComponent(Scope, {
45
+ kind: "function",
46
+ get children() {
47
+ return [_$createComponent(CallSignature, _$mergeProps(callSignatureProps, {
48
+ returnType: null
49
+ })), " => ", returnType];
50
+ }
51
+ })];
52
+ });
53
+
54
+ /**
55
+ * A TypeScript function declaration.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * (foo: string, bar: number) => void
60
+ * ```
61
+ * @remarks
62
+ *
63
+ * Providing parameters and type parameters can be accomplished in one of three
64
+ * ways:
65
+ *
66
+ * 1. As an array of {@link TypeParameterDescriptor}s or
67
+ * {@link TypeParameterDescriptor}s.
68
+ * 2. As raw content via the `parametersChildren` or `typeParametersChildren`
69
+ * props.
70
+ * 3. As a child of this component via the
71
+ * {@link FunctionType.Parameters} or
72
+ * {@link FunctionType.TypeParameters} components.
73
+ */
74
+ export const FunctionType = Object.assign(FunctionTypeComponent, {
75
+ TypeParameters,
76
+ Parameters: FunctionTypeParameters
77
+ });
@@ -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 { Block } from "@alloy-js/core";
4
3
  /**
5
4
  * An if statement.
@@ -30,5 +29,4 @@ export function ElseClause(props) {
30
29
  return props.children;
31
30
  }
32
31
  })];
33
- }
34
- //# sourceMappingURL=IfStatement.js.map
32
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"ImportStatement.d.ts","sourceRoot":"","sources":["../../../src/components/ImportStatement.tsx"],"names":[],"mappings":"AAOA,OAAO,EACL,cAAc,EACd,aAAa,EAEd,MAAM,qBAAqB,CAAC;AAI7B,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,6CA0C5D;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC9B;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eAsC1D"}
1
+ {"version":3,"file":"ImportStatement.d.ts","sourceRoot":"","sources":["../../../src/components/ImportStatement.tsx"],"names":[],"mappings":"AAOA,OAAO,EACL,cAAc,EACd,aAAa,EAGd,MAAM,qBAAqB,CAAC;AAI7B,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,6CA0C5D;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC9B;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eAkD1D"}
@@ -1,6 +1,7 @@
1
1
  import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
2
  import { mapJoin, memo, SourceDirectoryContext, useContext } from "@alloy-js/core";
3
3
  import { relative } from "pathe";
4
+ import { TSSymbolFlags } from "../symbols/index.js";
4
5
  import { modulePath } from "../utils.js";
5
6
  import { usePackage } from "./PackageDirectory.js";
6
7
  export function ImportStatements(props) {
@@ -57,9 +58,14 @@ export function ImportStatement(props) {
57
58
  }
58
59
  }
59
60
  if (namedImportSymbols.length > 0) {
61
+ const allNamedImportsAreTypes = namedImportSymbols.every(nis => nis.local.tsFlags & TSSymbolFlags.TypeSymbol);
62
+ if (allNamedImportsAreTypes) {
63
+ parts.push("type ");
64
+ }
60
65
  parts.push("{ ");
61
66
  parts.push(mapJoin(() => namedImportSymbols, nis => _$createComponent(ImportBinding, {
62
- importedSymbol: nis
67
+ importedSymbol: nis,
68
+ inTypeImport: allNamedImportsAreTypes
63
69
  }), {
64
70
  joiner: ", "
65
71
  }));
@@ -81,6 +87,6 @@ function ImportBinding(props) {
81
87
  return `${targetName} as ${localName}`;
82
88
  }
83
89
  });
84
- return text;
85
- }
86
- //# sourceMappingURL=ImportStatement.js.map
90
+ const prefix = memo(() => !props.inTypeImport && props.importedSymbol.local.tsFlags & TSSymbolFlags.TypeSymbol ? "type " : "");
91
+ return [prefix, text];
92
+ }
@@ -12,17 +12,18 @@ export interface InterfaceDeclarationProps extends BaseDeclarationProps {
12
12
  * `default` boolean props determine whether and how this symbol is exported
13
13
  * from the package.
14
14
  */
15
- export declare function InterfaceDeclaration(props: InterfaceDeclarationProps): Children;
15
+ export declare const InterfaceDeclaration: (props: InterfaceDeclarationProps) => Children;
16
16
  export interface InterfaceExpressionProps {
17
17
  children?: Children;
18
18
  }
19
- export declare function InterfaceExpression(props: InterfaceExpressionProps): Children;
19
+ export declare const InterfaceExpression: (props: InterfaceExpressionProps) => Children;
20
20
  export interface InterfaceMemberProps {
21
21
  name?: string;
22
22
  indexer?: Children;
23
23
  type?: Children;
24
24
  children?: Children;
25
25
  optional?: boolean;
26
+ nullish?: boolean;
26
27
  readonly?: boolean;
27
28
  doc?: Children;
28
29
  refkey?: Refkey | Refkey[];
@@ -1 +1 @@
1
- {"version":3,"file":"Interface.d.ts","sourceRoot":"","sources":["../../../src/components/Interface.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAIR,MAAM,EAEP,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAe,MAAM,kBAAkB,CAAC;AAKrE,MAAM,WAAW,yBAA0B,SAAQ,oBAAoB;IACrE,OAAO,CAAC,EAAE,QAAQ,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,YAiBpE;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,YAElE;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC5B;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,YAwC1D"}
1
+ {"version":3,"file":"Interface.d.ts","sourceRoot":"","sources":["../../../src/components/Interface.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAIR,MAAM,EAKP,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAe,MAAM,kBAAkB,CAAC;AAOrE,MAAM,WAAW,yBAA0B,SAAQ,oBAAoB;IACrE,OAAO,CAAC,EAAE,QAAQ,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,gDAmBhC,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,eAAO,MAAM,mBAAmB,+CAmB/B,CAAC;AAEF,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC5B;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,YAkD1D"}
@@ -1,12 +1,11 @@
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";
5
- import { Block, MemberDeclaration, Name, OutputSymbolFlags, Show } from "@alloy-js/core";
1
+ import { memo as _$memo, createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
2
+ import { Block, MemberScope, Name, OutputSymbolFlags, Show, useMemberDeclaration, useMemberScope, Wrap } from "@alloy-js/core";
6
3
  import { useTSNamePolicy } from "../name-policy.js";
7
4
  import { Declaration } from "./Declaration.js";
8
5
  import { JSDoc } from "./JSDoc.js";
6
+ import { MemberDeclaration } from "./MemberDeclaration.js";
9
7
  import { PropertyName } from "./PropertyName.js";
8
+ import { ensureTypeRefContext } from "./TypeRefContext.js";
10
9
  /**
11
10
  * Create a TypeScript interface declaration.
12
11
  *
@@ -16,7 +15,7 @@ import { PropertyName } from "./PropertyName.js";
16
15
  * `default` boolean props determine whether and how this symbol is exported
17
16
  * from the package.
18
17
  */
19
- export function InterfaceDeclaration(props) {
18
+ export const InterfaceDeclaration = ensureTypeRefContext(props => {
20
19
  const extendsPart = props.extends ? [" extends ", _$memo(() => props.extends)] : "";
21
20
  const flags = OutputSymbolFlags.StaticMemberContainer;
22
21
  return [_$createComponent(Show, {
@@ -33,6 +32,7 @@ export function InterfaceDeclaration(props) {
33
32
  }), _$createComponent(Declaration, _$mergeProps(props, {
34
33
  nameKind: "interface",
35
34
  flags: flags,
35
+ kind: "type",
36
36
  get children() {
37
37
  return ["interface ", _$createComponent(Name, {}), extendsPart, " ", _$createComponent(InterfaceExpression, {
38
38
  get children() {
@@ -41,14 +41,31 @@ export function InterfaceDeclaration(props) {
41
41
  })];
42
42
  }
43
43
  }))];
44
- }
45
- export function InterfaceExpression(props) {
46
- return _$createComponent(Block, {
44
+ });
45
+ export const InterfaceExpression = ensureTypeRefContext(props => {
46
+ const parentMemberSym = useMemberDeclaration();
47
+ if (parentMemberSym) {
48
+ parentMemberSym.binder.addStaticMembersToSymbol(parentMemberSym);
49
+ }
50
+ return _$createIntrinsic("group", {
47
51
  get children() {
48
- return props.children;
52
+ return _$createComponent(Wrap, {
53
+ when: !!parentMemberSym,
54
+ "with": MemberScope,
55
+ props: {
56
+ owner: parentMemberSym
57
+ },
58
+ get children() {
59
+ return _$createComponent(Block, {
60
+ get children() {
61
+ return props.children;
62
+ }
63
+ });
64
+ }
65
+ });
49
66
  }
50
67
  });
51
- }
68
+ });
52
69
  /**
53
70
  * Create a TypeScript interface member.
54
71
  *
@@ -67,10 +84,19 @@ export function InterfaceMember(props) {
67
84
  } else {
68
85
  const namer = useTSNamePolicy();
69
86
  const name = namer.getName(props.name, "interface-member");
70
- if (props.refkey) {
87
+ const memberScope = useMemberScope();
88
+ if (memberScope) {
71
89
  return _$createComponent(MemberDeclaration, {
72
90
  "static": true,
73
- name: name,
91
+ exactName: name,
92
+ kind: "type",
93
+ nameKind: "interface-member",
94
+ get flags() {
95
+ return OutputSymbolFlags.StaticMember;
96
+ },
97
+ get nullish() {
98
+ return props.nullish ?? props.optional;
99
+ },
74
100
  get refkey() {
75
101
  return props.refkey;
76
102
  },
@@ -106,5 +132,4 @@ export function InterfaceMember(props) {
106
132
  }), optionality, ": ", type];
107
133
  }
108
134
  }
109
- }
110
- //# sourceMappingURL=Interface.js.map
135
+ }