@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
@@ -0,0 +1,88 @@
1
+ import {
2
+ childrenArray,
3
+ findKeyedChild,
4
+ Prose,
5
+ Scope,
6
+ Show,
7
+ } from "@alloy-js/core";
8
+ import { Children } from "@alloy-js/core/jsx-runtime";
9
+ import { getCallSignatureProps } from "../utils.js";
10
+ import { CallSignature, CallSignatureProps } from "./CallSignature.jsx";
11
+ import {
12
+ FunctionParameters,
13
+ FunctionTypeParameters,
14
+ getReturnType,
15
+ TypeParameters,
16
+ } from "./FunctionBase.jsx";
17
+ import { JSDoc } from "./JSDoc.jsx";
18
+ import { JSDocParams } from "./JSDocParam.jsx";
19
+
20
+ /**
21
+ * Options for {@link (FunctionType:namespace)} component.
22
+ */
23
+ export interface FunctionTypeProps extends CallSignatureProps {
24
+ /** If the method is async */
25
+ readonly async?: boolean;
26
+ /** Documentation for this method. */
27
+ readonly doc?: Children;
28
+ /** Jsx content */
29
+ readonly children?: Children;
30
+ }
31
+
32
+ /**
33
+ * A TypeScript function declaration.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * (foo: string, bar: number) => void
38
+ * ```
39
+ * @remarks
40
+ *
41
+ * Providing parameters and type parameters can be accomplished in one of three
42
+ * ways:
43
+ *
44
+ * 1. As an array of {@link TypeParameterDescriptor}s or
45
+ * {@link TypeParameterDescriptor}s.
46
+ * 2. As raw content via the `parametersChildren` or `typeParametersChildren`
47
+ * props.
48
+ * 3. As a child of this component via the
49
+ * {@link (FunctionType:namespace).Parameters} or
50
+ * {@link (FunctionType:namespace).TypeParameters} components.
51
+ */
52
+ export function FunctionType(props: FunctionTypeProps) {
53
+ const children = childrenArray(() => props.children);
54
+ const typeParametersChildren =
55
+ findKeyedChild(children, TypeParameters.tag) ?? undefined;
56
+ const parametersChildren =
57
+ findKeyedChild(children, FunctionParameters.tag) ?? undefined;
58
+ const returnType = getReturnType(props.returnType ?? "void", {
59
+ async: props.async,
60
+ });
61
+
62
+ const callSignatureProps = getCallSignatureProps(props, {
63
+ parametersChildren,
64
+ typeParametersChildren,
65
+ });
66
+
67
+ return (
68
+ <>
69
+ <Show when={Boolean(props.doc)}>
70
+ <JSDoc>
71
+ {props.doc && <Prose children={props.doc} />}
72
+ {Array.isArray(props.parameters) && (
73
+ <JSDocParams parameters={props.parameters} />
74
+ )}
75
+ </JSDoc>
76
+ <hbr />
77
+ </Show>
78
+ <Scope kind="function">
79
+ <CallSignature {...callSignatureProps} returnType={null} />
80
+ {" => "}
81
+ {returnType}
82
+ </Scope>
83
+ </>
84
+ );
85
+ }
86
+
87
+ FunctionType.TypeParameters = TypeParameters;
88
+ FunctionType.Parameters = FunctionTypeParameters;
@@ -1,16 +1,20 @@
1
1
  import {
2
2
  Block,
3
3
  Children,
4
- MemberDeclaration,
4
+ MemberScope,
5
5
  Name,
6
6
  OutputSymbolFlags,
7
7
  Refkey,
8
8
  Show,
9
+ useMemberDeclaration,
10
+ useMemberScope,
11
+ Wrap,
9
12
  } from "@alloy-js/core";
10
13
  import { useTSNamePolicy } from "../name-policy.js";
11
14
  import { BaseDeclarationProps, Declaration } from "./Declaration.js";
12
15
  import { JSDoc } from "./JSDoc.jsx";
13
16
 
17
+ import { MemberDeclaration } from "./MemberDeclaration.jsx";
14
18
  import { PropertyName } from "./PropertyName.jsx";
15
19
 
16
20
  export interface InterfaceDeclarationProps extends BaseDeclarationProps {
@@ -36,7 +40,7 @@ export function InterfaceDeclaration(props: InterfaceDeclarationProps) {
36
40
  <JSDoc children={props.doc} />
37
41
  <hbr />
38
42
  </Show>
39
- <Declaration {...props} nameKind="interface" flags={flags}>
43
+ <Declaration {...props} nameKind="interface" flags={flags} kind="type">
40
44
  interface <Name />
41
45
  {extendsPart}{" "}
42
46
  <InterfaceExpression>{props.children}</InterfaceExpression>
@@ -50,7 +54,22 @@ export interface InterfaceExpressionProps {
50
54
  }
51
55
 
52
56
  export function InterfaceExpression(props: InterfaceExpressionProps) {
53
- return <Block>{props.children}</Block>;
57
+ const parentMemberSym = useMemberDeclaration();
58
+
59
+ if (parentMemberSym) {
60
+ parentMemberSym.binder.addStaticMembersToSymbol(parentMemberSym);
61
+ }
62
+ return (
63
+ <group>
64
+ <Wrap
65
+ when={!!parentMemberSym}
66
+ with={MemberScope}
67
+ props={{ owner: parentMemberSym! }}
68
+ >
69
+ <Block>{props.children}</Block>
70
+ </Wrap>
71
+ </group>
72
+ );
54
73
  }
55
74
 
56
75
  export interface InterfaceMemberProps {
@@ -87,9 +106,18 @@ export function InterfaceMember(props: InterfaceMemberProps) {
87
106
  } else {
88
107
  const namer = useTSNamePolicy();
89
108
  const name = namer.getName(props.name!, "interface-member");
90
- if (props.refkey) {
109
+ const memberScope = useMemberScope();
110
+
111
+ if (memberScope) {
91
112
  return (
92
- <MemberDeclaration static name={name} refkey={props.refkey}>
113
+ <MemberDeclaration
114
+ static
115
+ exactName={name}
116
+ kind="type"
117
+ nameKind="interface-member"
118
+ flags={OutputSymbolFlags.StaticMember}
119
+ refkey={props.refkey}
120
+ >
93
121
  <Show when={Boolean(props.doc)}>
94
122
  <JSDoc children={props.doc} />
95
123
  <hbr />
@@ -0,0 +1,96 @@
1
+ import {
2
+ childrenArray,
3
+ findKeyedChild,
4
+ MemberDeclaration,
5
+ Prose,
6
+ Refkey,
7
+ Scope,
8
+ Show,
9
+ } from "@alloy-js/core";
10
+ import { Children } from "@alloy-js/core/jsx-runtime";
11
+ import { useTSNamePolicy } from "../name-policy.js";
12
+ import { getCallSignatureProps } from "../utils.js";
13
+ import { CallSignature, CallSignatureProps } from "./CallSignature.jsx";
14
+ import {
15
+ FunctionParameters,
16
+ FunctionTypeParameters,
17
+ getReturnType,
18
+ TypeParameters,
19
+ } from "./FunctionBase.jsx";
20
+ import { JSDoc } from "./JSDoc.jsx";
21
+ import { JSDocParams } from "./JSDocParam.jsx";
22
+
23
+ /** Props for {@link (InterfaceMethod:namespace)} component */
24
+ export interface InterfaceMethodProps extends CallSignatureProps {
25
+ /** Interface member name */
26
+ readonly name: string;
27
+ /** If the method is async. It will change the returnType from `T` to `Promise<T>` */
28
+ readonly async?: boolean;
29
+ /** Documentation for this method. */
30
+ readonly doc?: Children;
31
+ /** Jsx content */
32
+ readonly children?: Children;
33
+ /** Ref key for the member declaration */
34
+ readonly refkey?: Refkey | Refkey[];
35
+ }
36
+
37
+ /**
38
+ * An interface method declaration.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * (foo: string, bar: number) => void
43
+ * ```
44
+ *
45
+ * @remarks
46
+ *
47
+ * Providing parameters and type parameters can be accomplished in one of three
48
+ * ways:
49
+ *
50
+ * 1. As an array of {@link TypeParameterDescriptor}s or
51
+ * {@link TypeParameterDescriptor}s.
52
+ * 2. As raw content via the `parametersChildren` or `typeParametersChildren`
53
+ * props.
54
+ * 3. As a child of this component via the
55
+ * {@link (InterfaceMethod:namespace).Parameters} or
56
+ * {@link (InterfaceMethod:namespace).TypeParameters} components.
57
+ */
58
+ export function InterfaceMethod(props: InterfaceMethodProps) {
59
+ const children = childrenArray(() => props.children);
60
+ const typeParametersChildren =
61
+ findKeyedChild(children, TypeParameters.tag) ?? undefined;
62
+ const parametersChildren =
63
+ findKeyedChild(children, FunctionParameters.tag) ?? undefined;
64
+ const returnType = getReturnType(props.returnType ?? "void", {
65
+ async: props.async,
66
+ });
67
+
68
+ const callSignatureProps = getCallSignatureProps(props, {
69
+ parametersChildren,
70
+ typeParametersChildren,
71
+ });
72
+ const namer = useTSNamePolicy();
73
+ const name = namer.getName(props.name!, "interface-member");
74
+ return (
75
+ <>
76
+ <Show when={Boolean(props.doc)}>
77
+ <JSDoc>
78
+ {props.doc && <Prose children={props.doc} />}
79
+ {Array.isArray(props.parameters) && (
80
+ <JSDocParams parameters={props.parameters} />
81
+ )}
82
+ </JSDoc>
83
+ <hbr />
84
+ </Show>
85
+ <MemberDeclaration static {...props} refkey={props.refkey}>
86
+ {name}
87
+ <Scope name={props.name} kind="function">
88
+ <CallSignature {...callSignatureProps} returnType={returnType} />
89
+ </Scope>
90
+ </MemberDeclaration>
91
+ </>
92
+ );
93
+ }
94
+
95
+ InterfaceMethod.TypeParameters = TypeParameters;
96
+ InterfaceMethod.Parameters = FunctionTypeParameters;
@@ -0,0 +1,70 @@
1
+ import {
2
+ MemberDeclaration as CoreMemberDeclaration,
3
+ MemberDeclarationPropsWithInfo,
4
+ OutputSymbolFlags,
5
+ } from "@alloy-js/core";
6
+ import { TypeScriptElements, useTSNamePolicy } from "../name-policy.js";
7
+ import {
8
+ createTSSymbol,
9
+ TSOutputSymbol,
10
+ TSSymbolFlags,
11
+ } from "../symbols/index.js";
12
+
13
+ export interface MemberDeclarationProps
14
+ extends Omit<MemberDeclarationPropsWithInfo, "name"> {
15
+ /**
16
+ * The name of this member declaration.
17
+ */
18
+ name?: string;
19
+
20
+ /** Name that shouldn't go through the name policy resolver again. */
21
+ exactName?: string;
22
+
23
+ /**
24
+ * Whether this is a memberdeclaration of a type (e.g. interface, type alias) or a
25
+ * value (e.g. var, const, let).
26
+ */
27
+ kind?: "type" | "value";
28
+
29
+ /**
30
+ * The name policy kind to apply to the memberdeclaration.
31
+ */
32
+ nameKind?: TypeScriptElements;
33
+
34
+ /**
35
+ * Flags for the symbol created by this component.
36
+ */
37
+ flags?: OutputSymbolFlags;
38
+
39
+ /**
40
+ * The symbol to use for this memberdeclaration.
41
+ */
42
+ symbol?: TSOutputSymbol;
43
+ }
44
+
45
+ export function MemberDeclaration(props: Readonly<MemberDeclarationProps>) {
46
+ let sym: TSOutputSymbol;
47
+
48
+ if (props.symbol) {
49
+ sym = props.symbol;
50
+ } else {
51
+ const namePolicy = useTSNamePolicy();
52
+
53
+ let tsFlags: TSSymbolFlags = TSSymbolFlags.None;
54
+ if (props.kind === "type") {
55
+ tsFlags |= TSSymbolFlags.TypeSymbol;
56
+ }
57
+
58
+ sym = createTSSymbol({
59
+ name: props.exactName ?? namePolicy.getName(props.name!, props.nameKind!),
60
+ refkey: props.refkey,
61
+ flags: props.flags,
62
+ tsFlags,
63
+ metadata: props.metadata,
64
+ });
65
+ }
66
+
67
+ return (
68
+ <CoreMemberDeclaration symbol={sym}>{props.children}</CoreMemberDeclaration>
69
+ );
70
+ }
@@ -1,5 +1,6 @@
1
1
  export * from "../parameter-descriptor.js";
2
2
  export * from "./ArrayExpression.js";
3
+ export * from "./ArrowFunction.jsx";
3
4
  export * from "./BarrelFile.js";
4
5
  export * from "./BlockScope.js";
5
6
  export * from "./CallSignature.jsx";
@@ -9,10 +10,19 @@ export * from "./Declaration.js";
9
10
  export * from "./EnumDeclaration.js";
10
11
  export * from "./EnumMember.js";
11
12
  export * from "./ExportStatement.js";
13
+ export {
14
+ type FunctionBodyProps,
15
+ type FunctionParametersProps,
16
+ type FunctionTypeParametersProps,
17
+ } from "./FunctionBase.js";
12
18
  export * from "./FunctionCallExpression.js";
13
19
  export * from "./FunctionDeclaration.js";
20
+ export * from "./FunctionExpression.js";
21
+ export * from "./FunctionType.jsx";
22
+ export * from "./IfStatement.jsx";
14
23
  export * from "./ImportStatement.js";
15
24
  export * from "./Interface.js";
25
+ export * from "./InterfaceMethod.jsx";
16
26
  export * from "./JSDoc.jsx";
17
27
  export * from "./JSDocComment.jsx";
18
28
  export * from "./JSDocExample.jsx";
@@ -2,6 +2,7 @@ import { stc } from "@alloy-js/core";
2
2
  import * as base from "../index.js";
3
3
 
4
4
  export const ArrayExpression = stc(base.ArrayExpression);
5
+ export const ArrowFunction = stc(base.ArrowFunction);
5
6
  export const BarrelFile = stc(base.BarrelFile);
6
7
  export const CallSignature = stc(base.CallSignature);
7
8
  export const ClassDeclaration = stc(base.ClassDeclaration);
@@ -15,11 +16,16 @@ export const EnumMember = stc(base.EnumMember);
15
16
  export const ExportStatement = stc(base.ExportStatement);
16
17
  export const FunctionCallExpression = stc(base.FunctionCallExpression);
17
18
  export const FunctionDeclaration = stc(base.FunctionDeclaration);
19
+ export const FunctionExpression = stc(base.FunctionExpression);
20
+ export const IfStatement = stc(base.IfStatement);
21
+ export const ElseClause = stc(base.ElseClause);
22
+ export const ElseIfClause = stc(base.ElseIfClause);
18
23
  export const ImportStatement = stc(base.ImportStatement);
19
24
  export const ImportStatements = stc(base.ImportStatements);
20
25
  export const InterfaceDeclaration = stc(base.InterfaceDeclaration);
21
26
  export const InterfaceExpression = stc(base.InterfaceExpression);
22
27
  export const InterfaceMember = stc(base.InterfaceMember);
28
+ export const InterfaceMethod = stc(base.InterfaceMethod);
23
29
  export const JSDoc = stc(base.JSDoc);
24
30
  export const JSDocExample = stc(base.JSDocExample);
25
31
  export const JSDocComment = stc(base.JSDocComment);
@@ -34,6 +40,7 @@ export const SourceFile = stc(base.SourceFile);
34
40
  export const SwitchStatement = stc(base.SwitchStatement);
35
41
  export const CaseClause = stc(base.CaseClause);
36
42
  export const TSConfigJson = stc(base.TSConfigJson);
43
+ export const FunctionType = stc(base.FunctionType);
37
44
  export const TypeDeclaration = stc(base.TypeDeclaration);
38
45
  export const ValueExpression = stc(base.ValueExpression);
39
46
  export const VarDeclaration = stc(base.VarDeclaration);
@@ -1,45 +1,56 @@
1
1
  import { Children, Refkey } from "@alloy-js/core";
2
2
 
3
3
  /**
4
- * Information for a TypeScript function parameter.
4
+ * Common properties for ParameterDescriptor and FunctionTypeParameterDescriptor.
5
5
  */
6
- export interface ParameterDescriptor {
6
+ export interface ParameterDescriptorBase {
7
7
  /**
8
8
  * The name of the parameter.
9
9
  */
10
- name: string;
10
+ readonly name: string;
11
11
 
12
12
  /**
13
13
  * The type of the parameter.
14
14
  */
15
- type?: Children;
16
-
17
- /**
18
- * The default value of the parameter.
19
- */
20
- default?: Children;
15
+ readonly type?: Children;
21
16
 
22
17
  /**
23
18
  * The refkey for this parameter.
24
19
  */
25
- refkey?: Refkey | Refkey[];
20
+ readonly refkey?: Refkey | Refkey[];
26
21
 
27
22
  /**
28
23
  * Whether the parameter is optional.
29
24
  */
30
- optional?: boolean;
25
+ readonly optional?: boolean;
31
26
 
32
27
  /**
33
28
  * Arbitrary metadata for the parameter symbol.
34
29
  */
35
- metadata?: Record<string, unknown>;
30
+ readonly metadata?: Record<string, unknown>;
36
31
 
37
32
  /**
38
33
  * Documentation for the parameter.
39
34
  */
40
- doc?: Children;
35
+ readonly doc?: Children;
36
+ }
37
+
38
+ /**
39
+ * Information for a TypeScript function parameter.
40
+ */
41
+ export interface ParameterDescriptor extends ParameterDescriptorBase {
42
+ /**
43
+ * The default value of the parameter.
44
+ */
45
+ readonly default?: Children;
41
46
  }
42
47
 
48
+ /**
49
+ * Information for a TypeScript type function parameter.
50
+ */
51
+ export interface FunctionTypeParameterDescriptor
52
+ extends ParameterDescriptorBase {}
53
+
43
54
  /**
44
55
  * Information for a TypeScript generic type parameter.
45
56
  */
@@ -47,25 +58,25 @@ export interface TypeParameterDescriptor {
47
58
  /**
48
59
  * The name of the type parameter.
49
60
  */
50
- name: string;
61
+ readonly name: string;
51
62
 
52
63
  /**
53
64
  * The extends constraint for the type parameter.
54
65
  */
55
- extends?: Children;
66
+ readonly extends?: Children;
56
67
 
57
68
  /**
58
69
  * The default type of the type parameter.
59
70
  */
60
- default?: Children;
71
+ readonly default?: Children;
61
72
 
62
73
  /**
63
74
  * A refkey or array of refkeys for this type parameter.
64
75
  */
65
- refkey?: Refkey | Refkey[];
76
+ readonly refkey?: Refkey | Refkey[];
66
77
 
67
78
  /**
68
79
  * Arbitrary metadata for the type parameter symbol.
69
80
  */
70
- metadata?: Record<string, unknown>;
81
+ readonly metadata?: Record<string, unknown>;
71
82
  }
@@ -134,7 +134,10 @@ function buildMemberExpression(path: TSOutputSymbol[]) {
134
134
  for (const sym of path) {
135
135
  if (sym.tsFlags & TSSymbolFlags.PrivateMember) {
136
136
  memberExpr += `.#${sym.name}`;
137
- } else if (isValidJSIdentifier(sym.name)) {
137
+ } else if (
138
+ isValidJSIdentifier(sym.name) &&
139
+ !(sym.tsFlags & TSSymbolFlags.TypeSymbol)
140
+ ) {
138
141
  memberExpr += `.${sym.name}`;
139
142
  } else {
140
143
  memberExpr += `[${JSON.stringify(sym.name)}]`;