@alloy-js/typescript 0.20.0-dev.0 → 0.20.0-dev.2

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 (318) hide show
  1. package/dist/src/builtins/index.js +2 -1
  2. package/dist/src/builtins/index.js.map +1 -0
  3. package/dist/src/builtins/node.d.ts +1 -1
  4. package/dist/src/builtins/node.js +2 -1
  5. package/dist/src/builtins/node.js.map +1 -0
  6. package/dist/src/components/ArrayExpression.js +2 -1
  7. package/dist/src/components/ArrayExpression.js.map +1 -0
  8. package/dist/src/components/ArrowFunction.d.ts.map +1 -1
  9. package/dist/src/components/ArrowFunction.js +9 -14
  10. package/dist/src/components/ArrowFunction.js.map +1 -0
  11. package/dist/src/components/BarrelFile.js +2 -1
  12. package/dist/src/components/BarrelFile.js.map +1 -0
  13. package/dist/src/components/BlockScope.d.ts.map +1 -1
  14. package/dist/src/components/BlockScope.js +5 -3
  15. package/dist/src/components/BlockScope.js.map +1 -0
  16. package/dist/src/components/CallSignature.js +2 -1
  17. package/dist/src/components/CallSignature.js.map +1 -0
  18. package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
  19. package/dist/src/components/ClassDeclaration.js +22 -31
  20. package/dist/src/components/ClassDeclaration.js.map +1 -0
  21. package/dist/src/components/CommaList.js +2 -1
  22. package/dist/src/components/CommaList.js.map +1 -0
  23. package/dist/src/components/Declaration.d.ts +2 -9
  24. package/dist/src/components/Declaration.d.ts.map +1 -1
  25. package/dist/src/components/Declaration.js +22 -44
  26. package/dist/src/components/Declaration.js.map +1 -0
  27. package/dist/src/components/EnumDeclaration.d.ts.map +1 -1
  28. package/dist/src/components/EnumDeclaration.js +7 -10
  29. package/dist/src/components/EnumDeclaration.js.map +1 -0
  30. package/dist/src/components/EnumMember.d.ts.map +1 -1
  31. package/dist/src/components/EnumMember.js +5 -5
  32. package/dist/src/components/EnumMember.js.map +1 -0
  33. package/dist/src/components/ExportStatement.d.ts.map +1 -1
  34. package/dist/src/components/ExportStatement.js +4 -2
  35. package/dist/src/components/ExportStatement.js.map +1 -0
  36. package/dist/src/components/FunctionBase.d.ts.map +1 -1
  37. package/dist/src/components/FunctionBase.js +17 -13
  38. package/dist/src/components/FunctionBase.js.map +1 -0
  39. package/dist/src/components/FunctionCallExpression.js +2 -1
  40. package/dist/src/components/FunctionCallExpression.js.map +1 -0
  41. package/dist/src/components/FunctionDeclaration.d.ts.map +1 -1
  42. package/dist/src/components/FunctionDeclaration.js +5 -4
  43. package/dist/src/components/FunctionDeclaration.js.map +1 -0
  44. package/dist/src/components/FunctionExpression.d.ts.map +1 -1
  45. package/dist/src/components/FunctionExpression.js +9 -14
  46. package/dist/src/components/FunctionExpression.js.map +1 -0
  47. package/dist/src/components/FunctionType.d.ts.map +1 -1
  48. package/dist/src/components/FunctionType.js +5 -4
  49. package/dist/src/components/FunctionType.js.map +1 -0
  50. package/dist/src/components/IfStatement.d.ts.map +1 -1
  51. package/dist/src/components/IfStatement.js +4 -2
  52. package/dist/src/components/IfStatement.js.map +1 -0
  53. package/dist/src/components/ImportStatement.d.ts.map +1 -1
  54. package/dist/src/components/ImportStatement.js +5 -5
  55. package/dist/src/components/ImportStatement.js.map +1 -0
  56. package/dist/src/components/Interface.d.ts.map +1 -1
  57. package/dist/src/components/Interface.js +16 -14
  58. package/dist/src/components/Interface.js.map +1 -0
  59. package/dist/src/components/InterfaceMethod.d.ts.map +1 -1
  60. package/dist/src/components/InterfaceMethod.js +6 -4
  61. package/dist/src/components/InterfaceMethod.js.map +1 -0
  62. package/dist/src/components/JSDoc.js +2 -1
  63. package/dist/src/components/JSDoc.js.map +1 -0
  64. package/dist/src/components/JSDocComment.js +2 -1
  65. package/dist/src/components/JSDocComment.js.map +1 -0
  66. package/dist/src/components/JSDocExample.js +2 -1
  67. package/dist/src/components/JSDocExample.js.map +1 -0
  68. package/dist/src/components/JSDocParam.js +2 -1
  69. package/dist/src/components/JSDocParam.js.map +1 -0
  70. package/dist/src/components/LexicalScope.d.ts +12 -0
  71. package/dist/src/components/LexicalScope.d.ts.map +1 -0
  72. package/dist/src/components/LexicalScope.js +25 -0
  73. package/dist/src/components/LexicalScope.js.map +1 -0
  74. package/dist/src/components/MemberDeclaration.d.ts +1 -10
  75. package/dist/src/components/MemberDeclaration.d.ts.map +1 -1
  76. package/dist/src/components/MemberDeclaration.js +5 -8
  77. package/dist/src/components/MemberDeclaration.js.map +1 -0
  78. package/dist/src/components/MemberExpression.d.ts.map +1 -1
  79. package/dist/src/components/MemberExpression.js +15 -6
  80. package/dist/src/components/MemberExpression.js.map +1 -0
  81. package/dist/src/components/MemberScope.d.ts +15 -0
  82. package/dist/src/components/MemberScope.d.ts.map +1 -0
  83. package/dist/src/components/MemberScope.js +18 -0
  84. package/dist/src/components/MemberScope.js.map +1 -0
  85. package/dist/src/components/NewExpression.d.ts.map +1 -1
  86. package/dist/src/components/NewExpression.js +7 -6
  87. package/dist/src/components/NewExpression.js.map +1 -0
  88. package/dist/src/components/ObjectExpression.d.ts.map +1 -1
  89. package/dist/src/components/ObjectExpression.js +12 -15
  90. package/dist/src/components/ObjectExpression.js.map +1 -0
  91. package/dist/src/components/PackageDirectory.js +2 -1
  92. package/dist/src/components/PackageDirectory.js.map +1 -0
  93. package/dist/src/components/PackageJson.js +2 -1
  94. package/dist/src/components/PackageJson.js.map +1 -0
  95. package/dist/src/components/PropertyName.js +3 -3
  96. package/dist/src/components/PropertyName.js.map +1 -0
  97. package/dist/src/components/Reference.js +2 -1
  98. package/dist/src/components/Reference.js.map +1 -0
  99. package/dist/src/components/SingleLineCommentBlock.js +2 -1
  100. package/dist/src/components/SingleLineCommentBlock.js.map +1 -0
  101. package/dist/src/components/SourceFile.d.ts.map +1 -1
  102. package/dist/src/components/SourceFile.js +5 -3
  103. package/dist/src/components/SourceFile.js.map +1 -0
  104. package/dist/src/components/SwitchStatement.js +2 -1
  105. package/dist/src/components/SwitchStatement.js.map +1 -0
  106. package/dist/src/components/TsConfigJson.js +2 -1
  107. package/dist/src/components/TsConfigJson.js.map +1 -0
  108. package/dist/src/components/TypeDeclaration.js +2 -1
  109. package/dist/src/components/TypeDeclaration.js.map +1 -0
  110. package/dist/src/components/TypeRefContext.js +2 -1
  111. package/dist/src/components/TypeRefContext.js.map +1 -0
  112. package/dist/src/components/ValueExpression.js +2 -1
  113. package/dist/src/components/ValueExpression.js.map +1 -0
  114. package/dist/src/components/VarDeclaration.d.ts.map +1 -1
  115. package/dist/src/components/VarDeclaration.js +16 -27
  116. package/dist/src/components/VarDeclaration.js.map +1 -0
  117. package/dist/src/components/index.js +2 -1
  118. package/dist/src/components/index.js.map +1 -0
  119. package/dist/src/components/interface/expression.test.js +2 -1
  120. package/dist/src/components/interface/expression.test.js.map +1 -0
  121. package/dist/src/components/stc/index.js +2 -1
  122. package/dist/src/components/stc/index.js.map +1 -0
  123. package/dist/src/context/index.d.ts +1 -1
  124. package/dist/src/context/index.d.ts.map +1 -1
  125. package/dist/src/context/index.js +2 -1
  126. package/dist/src/context/index.js.map +1 -0
  127. package/dist/src/context/type-ref-context.js +2 -1
  128. package/dist/src/context/type-ref-context.js.map +1 -0
  129. package/dist/src/create-package.d.ts.map +1 -1
  130. package/dist/src/create-package.js +13 -34
  131. package/dist/src/create-package.js.map +1 -0
  132. package/dist/src/index.js +2 -1
  133. package/dist/src/index.js.map +1 -0
  134. package/dist/src/name-conflict-resolver.js +2 -1
  135. package/dist/src/name-conflict-resolver.js.map +1 -0
  136. package/dist/src/name-policy.js +2 -1
  137. package/dist/src/name-policy.js.map +1 -0
  138. package/dist/src/parameter-descriptor.js +2 -1
  139. package/dist/src/parameter-descriptor.js.map +1 -0
  140. package/dist/src/source-directory-data.js +2 -1
  141. package/dist/src/source-directory-data.js.map +1 -0
  142. package/dist/src/symbols/index.d.ts +19 -0
  143. package/dist/src/symbols/index.d.ts.map +1 -1
  144. package/dist/src/symbols/index.js +73 -1
  145. package/dist/src/symbols/index.js.map +1 -0
  146. package/dist/src/symbols/reference.d.ts +2 -2
  147. package/dist/src/symbols/reference.d.ts.map +1 -1
  148. package/dist/src/symbols/reference.js +69 -70
  149. package/dist/src/symbols/reference.js.map +1 -0
  150. package/dist/src/symbols/scopes.d.ts +5 -8
  151. package/dist/src/symbols/scopes.d.ts.map +1 -1
  152. package/dist/src/symbols/scopes.js +28 -1
  153. package/dist/src/symbols/scopes.js.map +1 -0
  154. package/dist/src/symbols/ts-lexical-scope.d.ts +12 -0
  155. package/dist/src/symbols/ts-lexical-scope.d.ts.map +1 -0
  156. package/dist/src/symbols/ts-lexical-scope.js +17 -0
  157. package/dist/src/symbols/ts-lexical-scope.js.map +1 -0
  158. package/dist/src/symbols/ts-member-scope.d.ts +12 -4
  159. package/dist/src/symbols/ts-member-scope.d.ts.map +1 -1
  160. package/dist/src/symbols/ts-member-scope.js +17 -7
  161. package/dist/src/symbols/ts-member-scope.js.map +1 -0
  162. package/dist/src/symbols/ts-module-scope.d.ts +8 -3
  163. package/dist/src/symbols/ts-module-scope.d.ts.map +1 -1
  164. package/dist/src/symbols/ts-module-scope.js +31 -19
  165. package/dist/src/symbols/ts-module-scope.js.map +1 -0
  166. package/dist/src/symbols/ts-output-symbol.d.ts +19 -18
  167. package/dist/src/symbols/ts-output-symbol.d.ts.map +1 -1
  168. package/dist/src/symbols/ts-output-symbol.js +62 -38
  169. package/dist/src/symbols/ts-output-symbol.js.map +1 -0
  170. package/dist/src/symbols/ts-package-scope.d.ts +1 -1
  171. package/dist/src/symbols/ts-package-scope.d.ts.map +1 -1
  172. package/dist/src/symbols/ts-package-scope.js +6 -6
  173. package/dist/src/symbols/ts-package-scope.js.map +1 -0
  174. package/dist/src/utils.d.ts +4 -0
  175. package/dist/src/utils.d.ts.map +1 -1
  176. package/dist/src/utils.js +25 -2
  177. package/dist/src/utils.js.map +1 -0
  178. package/dist/test/array.test.js +2 -1
  179. package/dist/test/array.test.js.map +1 -0
  180. package/dist/test/arrow-function.test.js +2 -1
  181. package/dist/test/arrow-function.test.js.map +1 -0
  182. package/dist/test/barrel.test.js +26 -17
  183. package/dist/test/barrel.test.js.map +1 -0
  184. package/dist/test/basic.test.js +22 -26
  185. package/dist/test/basic.test.js.map +1 -0
  186. package/dist/test/block-scope.test.js +2 -1
  187. package/dist/test/block-scope.test.js.map +1 -0
  188. package/dist/test/class.test.js +24 -18
  189. package/dist/test/class.test.js.map +1 -0
  190. package/dist/test/enum-jsdoc.test.js +2 -1
  191. package/dist/test/enum-jsdoc.test.js.map +1 -0
  192. package/dist/test/enum.test.js +2 -1
  193. package/dist/test/enum.test.js.map +1 -0
  194. package/dist/test/externals.test.js +12 -51
  195. package/dist/test/externals.test.js.map +1 -0
  196. package/dist/test/function-call-expression.test.js +9 -8
  197. package/dist/test/function-call-expression.test.js.map +1 -0
  198. package/dist/test/function-declaration-jsdoc.test.js +2 -1
  199. package/dist/test/function-declaration-jsdoc.test.js.map +1 -0
  200. package/dist/test/function-declaration.test.js +2 -1
  201. package/dist/test/function-declaration.test.js.map +1 -0
  202. package/dist/test/function-expression.test.js +2 -1
  203. package/dist/test/function-expression.test.js.map +1 -0
  204. package/dist/test/function-type.test.js +2 -1
  205. package/dist/test/function-type.test.js.map +1 -0
  206. package/dist/test/if-statement.test.js +2 -1
  207. package/dist/test/if-statement.test.js.map +1 -0
  208. package/dist/test/imports.test.d.ts.map +1 -1
  209. package/dist/test/imports.test.js +62 -60
  210. package/dist/test/imports.test.js.map +1 -0
  211. package/dist/test/interface-jsdoc.test.js +2 -1
  212. package/dist/test/interface-jsdoc.test.js.map +1 -0
  213. package/dist/test/interface.test.js +2 -1
  214. package/dist/test/interface.test.js.map +1 -0
  215. package/dist/test/jscomment.test.js +2 -1
  216. package/dist/test/jscomment.test.js.map +1 -0
  217. package/dist/test/jsdoc.test.js +2 -1
  218. package/dist/test/jsdoc.test.js.map +1 -0
  219. package/dist/test/jsdocparam.test.js +2 -1
  220. package/dist/test/jsdocparam.test.js.map +1 -0
  221. package/dist/test/member-expression.test.js +8 -7
  222. package/dist/test/member-expression.test.js.map +1 -0
  223. package/dist/test/name-conflict.test.js +5 -7
  224. package/dist/test/name-conflict.test.js.map +1 -0
  225. package/dist/test/name-policy.test.js +9 -13
  226. package/dist/test/name-policy.test.js.map +1 -0
  227. package/dist/test/new-expression.test.js +6 -7
  228. package/dist/test/new-expression.test.js.map +1 -0
  229. package/dist/test/object.test.js +2 -1
  230. package/dist/test/object.test.js.map +1 -0
  231. package/dist/test/package-external.test.js +71 -66
  232. package/dist/test/package-external.test.js.map +1 -0
  233. package/dist/test/package-json.test.js +8 -10
  234. package/dist/test/package-json.test.js.map +1 -0
  235. package/dist/test/package.test.js +12 -12
  236. package/dist/test/package.test.js.map +1 -0
  237. package/dist/test/reference.test.js +10 -12
  238. package/dist/test/reference.test.js.map +1 -0
  239. package/dist/test/source-file.test.js +7 -10
  240. package/dist/test/source-file.test.js.map +1 -0
  241. package/dist/test/switch-statement.test.js +2 -1
  242. package/dist/test/switch-statement.test.js.map +1 -0
  243. package/dist/test/utils.js +6 -2
  244. package/dist/test/utils.js.map +1 -0
  245. package/dist/test/value-expression.test.js +2 -1
  246. package/dist/test/value-expression.test.js.map +1 -0
  247. package/dist/test/values.test.d.ts.map +1 -1
  248. package/dist/test/values.test.js +11 -8
  249. package/dist/test/values.test.js.map +1 -0
  250. package/dist/test/var-declaration-jsdoc.test.js +2 -1
  251. package/dist/test/var-declaration-jsdoc.test.js.map +1 -0
  252. package/dist/test/var-declaration.test.d.ts.map +1 -1
  253. package/dist/test/var-declaration.test.js +21 -12
  254. package/dist/test/var-declaration.test.js.map +1 -0
  255. package/dist/test/vitest.setup.js +2 -1
  256. package/dist/test/vitest.setup.js.map +1 -0
  257. package/dist/tsconfig.tsbuildinfo +1 -1
  258. package/package.json +4 -4
  259. package/src/components/ArrowFunction.tsx +7 -10
  260. package/src/components/BlockScope.tsx +3 -3
  261. package/src/components/ClassDeclaration.tsx +19 -44
  262. package/src/components/Declaration.tsx +22 -53
  263. package/src/components/EnumDeclaration.tsx +4 -11
  264. package/src/components/EnumMember.tsx +3 -3
  265. package/src/components/ExportStatement.tsx +2 -1
  266. package/src/components/FunctionBase.tsx +33 -28
  267. package/src/components/FunctionDeclaration.tsx +3 -3
  268. package/src/components/FunctionExpression.tsx +7 -10
  269. package/src/components/FunctionType.tsx +3 -3
  270. package/src/components/IfStatement.tsx +2 -1
  271. package/src/components/ImportStatement.tsx +4 -8
  272. package/src/components/Interface.tsx +15 -22
  273. package/src/components/InterfaceMethod.tsx +4 -4
  274. package/src/components/LexicalScope.tsx +27 -0
  275. package/src/components/MemberDeclaration.tsx +8 -20
  276. package/src/components/MemberExpression.tsx +25 -5
  277. package/src/components/MemberScope.tsx +29 -0
  278. package/src/components/NewExpression.tsx +4 -5
  279. package/src/components/ObjectExpression.tsx +11 -18
  280. package/src/components/PropertyName.tsx +2 -2
  281. package/src/components/SourceFile.tsx +3 -1
  282. package/src/components/VarDeclaration.tsx +14 -28
  283. package/src/context/index.ts +1 -1
  284. package/src/create-package.ts +10 -39
  285. package/src/symbols/index.ts +118 -0
  286. package/src/symbols/reference.tsx +163 -0
  287. package/src/symbols/scopes.ts +38 -13
  288. package/src/symbols/ts-lexical-scope.ts +18 -0
  289. package/src/symbols/ts-member-scope.ts +23 -6
  290. package/src/symbols/ts-module-scope.ts +31 -21
  291. package/src/symbols/ts-output-symbol.ts +111 -49
  292. package/src/symbols/ts-package-scope.ts +5 -5
  293. package/src/utils.ts +38 -1
  294. package/temp/api.json +1641 -713
  295. package/test/barrel.test.tsx +24 -18
  296. package/test/basic.test.tsx +20 -29
  297. package/test/class.test.tsx +28 -18
  298. package/test/externals.test.tsx +10 -57
  299. package/test/function-call-expression.test.tsx +6 -7
  300. package/test/imports.test.tsx +57 -74
  301. package/test/member-expression.test.tsx +5 -13
  302. package/test/name-conflict.test.tsx +4 -7
  303. package/test/name-policy.test.tsx +7 -15
  304. package/test/new-expression.test.tsx +4 -7
  305. package/test/package-external.test.tsx +69 -73
  306. package/test/package-json.test.tsx +6 -11
  307. package/test/package.test.tsx +8 -11
  308. package/test/reference.test.tsx +10 -15
  309. package/test/source-file.test.tsx +5 -11
  310. package/test/utils.tsx +1 -1
  311. package/test/values.test.tsx +8 -8
  312. package/test/var-declaration.test.tsx +19 -20
  313. package/tsdoc-metadata.json +1 -1
  314. package/dist/src/context/private-scope.d.ts +0 -18
  315. package/dist/src/context/private-scope.d.ts.map +0 -1
  316. package/dist/src/context/private-scope.js +0 -8
  317. package/src/context/private-scope.ts +0 -23
  318. package/src/symbols/reference.ts +0 -197
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alloy-js/typescript",
3
- "version": "0.20.0-dev.0",
3
+ "version": "0.20.0-dev.2",
4
4
  "description": "",
5
5
  "exports": {
6
6
  ".": {
@@ -14,16 +14,16 @@
14
14
  "author": "brian.terlson@microsoft.com",
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
- "@alloy-js/core": "~0.19.0 || >= 0.20.0-dev.0",
17
+ "@alloy-js/core": "~0.19.0 || >= 0.20.0-dev.9",
18
18
  "change-case": "^5.4.4",
19
19
  "pathe": "^2.0.3"
20
20
  },
21
21
  "devDependencies": {
22
- "@alloy-js/cli": "~0.19.0 || >= 0.20.0-dev.0",
22
+ "@alloy-js/cli": "~0.19.0 || >= 0.20.0-dev.1",
23
23
  "@alloy-js/rollup-plugin": "~0.1.0 || >= 0.1.1-dev.0",
24
24
  "@microsoft/api-extractor": "~7.52.8",
25
25
  "@rollup/plugin-typescript": "^12.1.2",
26
- "concurrently": "^9.1.2",
26
+ "concurrently": "^9.2.0",
27
27
  "typescript": "^5.8.3",
28
28
  "vitest": "^3.2.4"
29
29
  },
@@ -2,18 +2,17 @@ import {
2
2
  childrenArray,
3
3
  findKeyedChild,
4
4
  findUnkeyedChildren,
5
- Scope,
6
5
  type Children,
7
6
  } from "@alloy-js/core";
8
7
  import { getCallSignatureProps } from "../utils.js";
9
8
  import { CallSignature, CallSignatureProps } from "./CallSignature.jsx";
10
- import { Declaration } from "./Declaration.jsx";
11
9
  import {
12
10
  FunctionBody,
13
11
  FunctionParameters,
14
12
  getReturnType,
15
13
  TypeParameters,
16
14
  } from "./FunctionBase.jsx";
15
+ import { LexicalScope } from "./LexicalScope.jsx";
17
16
 
18
17
  export interface ArrowFunctionProps extends CallSignatureProps {
19
18
  async?: boolean;
@@ -70,14 +69,12 @@ export function ArrowFunction(props: ArrowFunctionProps) {
70
69
 
71
70
  return (
72
71
  <>
73
- <Declaration {...props} nameKind="function">
74
- {asyncKwd}
75
- <Scope kind="function">
76
- <CallSignature {...callSignatureProps} returnType={returnType} />
77
- {" => "}
78
- {sBody}
79
- </Scope>
80
- </Declaration>
72
+ {asyncKwd}
73
+ <LexicalScope>
74
+ <CallSignature {...callSignatureProps} returnType={returnType} />
75
+ {" => "}
76
+ {sBody}
77
+ </LexicalScope>
81
78
  </>
82
79
  );
83
80
  }
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  Block,
3
3
  BlockProps,
4
- Scope,
5
4
  ScopePropsWithInfo,
6
5
  ScopePropsWithValue,
7
6
  } from "@alloy-js/core";
7
+ import { LexicalScope } from "./LexicalScope.jsx";
8
8
 
9
9
  export interface BlockScopePropsWithScopeValue
10
10
  extends ScopePropsWithValue,
@@ -24,8 +24,8 @@ export type BlockScopeProps =
24
24
  */
25
25
  export function BlockScope(props: BlockScopeProps) {
26
26
  return (
27
- <Scope {...props}>
27
+ <LexicalScope {...props}>
28
28
  <Block {...props}>{props.children}</Block>
29
- </Scope>
29
+ </LexicalScope>
30
30
  );
31
31
  }
@@ -3,24 +3,25 @@ import {
3
3
  Children,
4
4
  MemberDeclaration,
5
5
  Name,
6
- OutputSymbolFlags,
7
6
  Prose,
8
7
  Refkey,
9
- Scope,
10
8
  Show,
11
9
  splitProps,
12
- useMemberScope,
13
10
  } from "@alloy-js/core";
14
11
 
15
- import { usePrivateScope } from "../context/private-scope.js";
16
12
  import { useTSNamePolicy } from "../name-policy.js";
17
- import { TSOutputScope } from "../symbols/scopes.js";
18
- import { TSOutputSymbol, TSSymbolFlags } from "../symbols/ts-output-symbol.js";
13
+ import {
14
+ createMemberSymbol,
15
+ createTypeAndValueSymbol,
16
+ } from "../symbols/index.js";
17
+ import { TSSymbolFlags } from "../symbols/ts-output-symbol.js";
19
18
  import { getCallSignatureProps } from "../utils.js";
20
19
  import { CallSignature, CallSignatureProps } from "./CallSignature.jsx";
21
20
  import { BaseDeclarationProps, Declaration } from "./Declaration.jsx";
22
21
  import { JSDoc } from "./JSDoc.jsx";
23
22
  import { JSDocParams } from "./JSDocParam.jsx";
23
+ import { LexicalScope } from "./LexicalScope.jsx";
24
+ import { MemberScope } from "./MemberScope.jsx";
24
25
  import { PropertyName } from "./PropertyName.jsx";
25
26
  import { TypeRefContext } from "./TypeRefContext.jsx";
26
27
 
@@ -63,18 +64,15 @@ export interface ClassDeclarationProps extends BaseDeclarationProps {
63
64
  */
64
65
  export function ClassDeclaration(props: ClassDeclarationProps) {
65
66
  const namePolicy = useTSNamePolicy();
66
- const extendsPart = props.extends && <> extends {props.extends}</>;
67
+ const name = namePolicy.getName(props.name!, "class");
67
68
 
68
- const sym = new TSOutputSymbol(namePolicy.getName(props.name!, "class"), {
69
+ const extendsPart = props.extends && <> extends {props.extends}</>;
70
+ const sym = createTypeAndValueSymbol(name, {
69
71
  refkeys: props.refkey,
70
72
  export: props.export,
71
73
  default: props.default,
72
- flags:
73
- (props.flags ?? OutputSymbolFlags.None) |
74
- (OutputSymbolFlags.MemberContainer |
75
- OutputSymbolFlags.StaticMemberContainer),
76
- tsFlags: TSSymbolFlags.PrivateMemberContainer,
77
74
  metadata: props.metadata,
75
+ hasInstanceMembers: true,
78
76
  });
79
77
 
80
78
  return (
@@ -84,8 +82,10 @@ export function ClassDeclaration(props: ClassDeclarationProps) {
84
82
  <hbr />
85
83
  </Show>
86
84
  <Declaration symbol={sym} export={props.export} default={props.default}>
87
- class <Name />
88
- {extendsPart} <Block>{props.children}</Block>
85
+ <MemberScope ownerSymbol={sym}>
86
+ class <Name />
87
+ {extendsPart} <Block>{props.children}</Block>
88
+ </MemberScope>
89
89
  </Declaration>
90
90
  </>
91
91
  );
@@ -108,38 +108,13 @@ export function ClassMember(props: ClassMemberProps) {
108
108
  const namer = useTSNamePolicy();
109
109
  const name = namer.getName(props.name, "class-member-data");
110
110
 
111
- let flags = OutputSymbolFlags.None;
112
-
113
- if (props.static) {
114
- flags |= OutputSymbolFlags.StaticMember;
115
- } else {
116
- flags |= OutputSymbolFlags.InstanceMember;
117
- }
118
-
119
- let scope: TSOutputScope;
120
- if (props.jsPrivate) {
121
- const memberScope = usePrivateScope()!;
122
- scope =
123
- props.static ? memberScope.staticMembers : memberScope.instanceMembers;
124
- } else {
125
- const memberScope = useMemberScope();
126
- scope = (
127
- props.static ?
128
- memberScope.staticMembers!
129
- : memberScope.instanceMembers!) as TSOutputScope;
130
- }
131
-
132
- let tsFlags =
133
- props.jsPrivate ? TSSymbolFlags.PrivateMember : TSSymbolFlags.None;
134
-
111
+ let tsFlags = TSSymbolFlags.None;
135
112
  if (props.nullish) {
136
113
  tsFlags |= TSSymbolFlags.Nullish;
137
114
  }
138
115
 
139
- const sym = new TSOutputSymbol(name, {
140
- scope,
116
+ const sym = createMemberSymbol(name, props, {
141
117
  refkeys: props.refkey,
142
- flags,
143
118
  tsFlags,
144
119
  });
145
120
 
@@ -208,9 +183,9 @@ export function ClassMethod(props: ClassMethodProps) {
208
183
  <ClassMember {...rest}>
209
184
  {props.async && "async "}
210
185
  <PropertyName />
211
- <Scope name={props.name} kind="function">
186
+ <LexicalScope name={props.name}>
212
187
  <CallSignature {...callProps} /> <Block>{props.children}</Block>
213
- </Scope>
188
+ </LexicalScope>
214
189
  </ClassMember>
215
190
  </>
216
191
  );
@@ -1,18 +1,19 @@
1
1
  import {
2
2
  Children,
3
3
  Declaration as CoreDeclaration,
4
- MemberScope,
5
- OutputSymbolFlags,
6
4
  Refkey,
7
5
  } from "@alloy-js/core";
8
6
  import { TypeScriptElements, useTSNamePolicy } from "../name-policy.js";
9
- import { TSOutputSymbol, TSSymbolFlags } from "../symbols/index.js";
7
+ import {
8
+ createTypeSymbol,
9
+ createValueSymbol,
10
+ TSOutputSymbol,
11
+ } from "../symbols/index.js";
10
12
 
11
13
  // imports for documentation
12
14
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
13
15
  import { TypeDeclaration } from "./TypeDeclaration.jsx";
14
16
 
15
- import { PrivateScopeContext } from "../context/private-scope.js";
16
17
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
17
18
  import { EnumDeclaration } from "./EnumDeclaration.jsx";
18
19
 
@@ -38,11 +39,6 @@ export interface BaseDeclarationProps {
38
39
  */
39
40
  default?: boolean;
40
41
 
41
- /**
42
- * Flags for the symbol created by this component.
43
- */
44
- flags?: OutputSymbolFlags;
45
-
46
42
  children?: Children;
47
43
 
48
44
  /**
@@ -88,10 +84,7 @@ export interface DeclarationProps extends Omit<BaseDeclarationProps, "name"> {
88
84
  * @remarks
89
85
  *
90
86
  * This component will wrap its contents in a {@link @alloy-js/core#Declaration} component,
91
- * so children can make use of declaration context. Additionally, if the
92
- * provided symbol flags have {@link @alloy-js/core#OutputSymbolFlags.MemberContainer}, this
93
- * component will create a {@link @alloy-js/core#MemberScope}.
94
- *
87
+ * so children can make use of declaration context.
95
88
  */
96
89
  export function Declaration(props: DeclarationProps) {
97
90
  let sym: TSOutputSymbol;
@@ -100,53 +93,29 @@ export function Declaration(props: DeclarationProps) {
100
93
  sym = props.symbol;
101
94
  } else {
102
95
  const namePolicy = useTSNamePolicy();
103
-
104
- let tsFlags: TSSymbolFlags = TSSymbolFlags.None;
105
- if (props.kind && props.kind === "type") {
106
- tsFlags |= TSSymbolFlags.TypeSymbol;
96
+ const name = namePolicy.getName(props.name!, props.nameKind!);
97
+ if (props.kind === "type") {
98
+ sym = createTypeSymbol(name, {
99
+ refkeys: props.refkey,
100
+ export: props.export,
101
+ default: props.default,
102
+ metadata: props.metadata,
103
+ });
104
+ } else {
105
+ sym = createValueSymbol(name, {
106
+ refkeys: props.refkey,
107
+ export: props.export,
108
+ default: props.default,
109
+ metadata: props.metadata,
110
+ });
107
111
  }
108
-
109
- sym = new TSOutputSymbol(namePolicy.getName(props.name!, props.nameKind!), {
110
- refkeys: props.refkey,
111
- export: props.export,
112
- default: props.default,
113
- flags: props.flags,
114
- tsFlags,
115
- metadata: props.metadata,
116
- });
117
- }
118
-
119
- function withMemberScope(children: Children) {
120
- return <MemberScope owner={sym}>{children}</MemberScope>;
121
- }
122
-
123
- function withPrivateMemberScope(children: Children) {
124
- const context: PrivateScopeContext = {
125
- instanceMembers: sym.privateMemberScope!,
126
- staticMembers: sym.privateStaticMemberScope!,
127
- };
128
- return (
129
- <PrivateScopeContext.Provider value={context}>
130
- {children}
131
- </PrivateScopeContext.Provider>
132
- );
133
- }
134
-
135
- let children: Children = () => props.children;
136
-
137
- if (sym.flags & OutputSymbolFlags.MemberContainer) {
138
- children = withMemberScope(children);
139
- }
140
-
141
- if (sym.tsFlags & TSSymbolFlags.PrivateMemberContainer) {
142
- children = withPrivateMemberScope(children);
143
112
  }
144
113
 
145
114
  return (
146
115
  <CoreDeclaration symbol={sym}>
147
116
  {props.export ? "export " : ""}
148
117
  {props.default ? "default " : ""}
149
- {children}
118
+ {props.children}
150
119
  </CoreDeclaration>
151
120
  );
152
121
  }
@@ -3,17 +3,15 @@ import {
3
3
  computed,
4
4
  Declaration as CoreDeclaration,
5
5
  For,
6
- MemberScope,
7
6
  Name,
8
- OutputSymbolFlags,
9
7
  Show,
10
- useBinder,
11
8
  } from "@alloy-js/core";
12
9
  import { useTSNamePolicy } from "../name-policy.js";
13
- import { TSOutputSymbol, useTSScope } from "../symbols/index.js";
10
+ import { createTypeAndValueSymbol } from "../symbols/index.js";
14
11
  import { BaseDeclarationProps } from "./Declaration.js";
15
12
  import { EnumMember } from "./EnumMember.jsx";
16
13
  import { JSDoc } from "./JSDoc.jsx";
14
+ import { MemberScope } from "./MemberScope.jsx";
17
15
  export interface EnumDeclarationProps extends BaseDeclarationProps {
18
16
  /**
19
17
  * A JS object representing the enum member names and values.
@@ -26,15 +24,10 @@ export interface EnumDeclarationProps extends BaseDeclarationProps {
26
24
  */
27
25
  export function EnumDeclaration(props: EnumDeclarationProps) {
28
26
  const name = useTSNamePolicy().getName(props.name, "enum");
29
- const binder = useBinder();
30
- const scope = useTSScope();
31
- const sym = new TSOutputSymbol(name, {
32
- binder,
33
- scope,
27
+ const sym = createTypeAndValueSymbol(name, {
34
28
  refkeys: props.refkey,
35
29
  default: props.default,
36
30
  export: props.export,
37
- flags: OutputSymbolFlags.StaticMemberContainer,
38
31
  metadata: props.metadata,
39
32
  });
40
33
 
@@ -48,7 +41,7 @@ export function EnumDeclaration(props: EnumDeclarationProps) {
48
41
  <CoreDeclaration symbol={sym}>
49
42
  {props.export ? "export " : ""}
50
43
  {props.default ? "default " : ""}enum <Name />{" "}
51
- <MemberScope owner={sym}>
44
+ <MemberScope ownerSymbol={sym}>
52
45
  <Block>
53
46
  <For each={valueEntries} comma hardline enderPunctuation>
54
47
  {([name, value]) => <EnumMember name={name} jsValue={value} />}
@@ -1,5 +1,6 @@
1
- import { Children, OutputSymbolFlags, Refkey, Show } from "@alloy-js/core";
1
+ import { Children, Refkey, Show } from "@alloy-js/core";
2
2
  import { useTSNamePolicy } from "../name-policy.js";
3
+ import { createStaticMemberSymbol } from "../symbols/index.js";
3
4
  import { TSOutputSymbol } from "../symbols/ts-output-symbol.js";
4
5
  import { JSDoc } from "./JSDoc.jsx";
5
6
  import { PropertyName } from "./PropertyName.jsx";
@@ -49,9 +50,8 @@ export function EnumMember(props: EnumMemberProps) {
49
50
  const name = namer.getName(props.name, "enum-member");
50
51
  let sym: TSOutputSymbol | undefined = undefined;
51
52
  if (props.refkey) {
52
- sym = new TSOutputSymbol(name, {
53
+ sym = createStaticMemberSymbol(name, {
53
54
  refkeys: props.refkey,
54
- flags: OutputSymbolFlags.StaticMember,
55
55
  metadata: props.metadata,
56
56
  });
57
57
  }
@@ -11,7 +11,8 @@ export interface ExportStatementProps {
11
11
  export function ExportStatement(props: ExportStatementProps) {
12
12
  if (props.star) {
13
13
  const module = useSourceFile();
14
- for (const symbol of props.from!.symbols.values()) {
14
+ const allSymbols = props.from!.getAllSymbols();
15
+ for (const symbol of allSymbols) {
15
16
  for (const refkey of symbol.refkeys) {
16
17
  module.scope.exportedSymbols.set(refkey, symbol as TSOutputSymbol);
17
18
  }
@@ -6,6 +6,7 @@ import {
6
6
  Indent,
7
7
  onCleanup,
8
8
  Show,
9
+ SymbolSlot,
9
10
  taggedComponent,
10
11
  type Children,
11
12
  } from "@alloy-js/core";
@@ -15,7 +16,11 @@ import type {
15
16
  ParameterDescriptor,
16
17
  } from "../parameter-descriptor.js";
17
18
  import { TypeParameterDescriptor } from "../parameter-descriptor.js";
18
- import { TSOutputSymbol, TSSymbolFlags } from "../symbols/index.js";
19
+ import {
20
+ createValueSymbol,
21
+ TSOutputSymbol,
22
+ TSSymbolFlags,
23
+ } from "../symbols/index.js";
19
24
  import { TypeRefContext } from "./TypeRefContext.jsx";
20
25
 
21
26
  const functionParametersTag = Symbol();
@@ -72,7 +77,9 @@ export const FunctionParameters = taggedComponent(
72
77
  return props.children;
73
78
  }
74
79
 
75
- const parameters = normalizeAndDeclareParameters(props.parameters ?? []);
80
+ const parameters = normalizeAndDeclareParameters(
81
+ props.parameters ?? [],
82
+ ) as DeclaredParameterDescriptor[];
76
83
  if (parameters.length === 0) {
77
84
  return null;
78
85
  }
@@ -106,7 +113,9 @@ export const FunctionTypeParameters = taggedComponent(
106
113
  return props.children;
107
114
  }
108
115
 
109
- const parameters = normalizeAndDeclareParameters(props.parameters ?? []);
116
+ const parameters = normalizeAndDeclareParameters(
117
+ props.parameters ?? [],
118
+ ) as DeclaredFunctionTypeParameterDescriptor[];
110
119
  if (parameters.length === 0) {
111
120
  return null;
112
121
  }
@@ -124,11 +133,9 @@ export const FunctionTypeParameters = taggedComponent(
124
133
  },
125
134
  );
126
135
 
127
- function parameter(param: DeclaredParameterDescriptor) {
128
- const SymbolSlot = createSymbolSlot();
129
-
130
- SymbolSlot.instantiateInto(param.symbol);
131
-
136
+ function parameter(
137
+ param: DeclaredParameterDescriptor | DeclaredFunctionTypeParameterDescriptor,
138
+ ) {
132
139
  return (
133
140
  <group>
134
141
  <Show when={param.rest}>...</Show>
@@ -137,14 +144,14 @@ function parameter(param: DeclaredParameterDescriptor) {
137
144
  <Show when={!!param.type}>
138
145
  <indent>
139
146
  :{" "}
140
- <SymbolSlot>
147
+ <param.TypeSlot>
141
148
  <TypeRefContext>{param.type}</TypeRefContext>
142
- </SymbolSlot>
149
+ </param.TypeSlot>
143
150
  </indent>
144
151
  </Show>
145
- <Show when={!!param.default}>
152
+ <Show when={!!(param as any).default}>
146
153
  {" = "}
147
- <SymbolSlot>{param.default!}</SymbolSlot>
154
+ <param.TypeSlot>{(param as any).default!}</param.TypeSlot>
148
155
  </Show>
149
156
  </group>
150
157
  );
@@ -153,10 +160,12 @@ function parameter(param: DeclaredParameterDescriptor) {
153
160
  interface DeclaredParameterDescriptor
154
161
  extends Omit<ParameterDescriptor, "name"> {
155
162
  symbol: TSOutputSymbol;
163
+ TypeSlot: SymbolSlot;
156
164
  }
157
165
  interface DeclaredFunctionTypeParameterDescriptor
158
166
  extends Omit<FunctionTypeParameterDescriptor, "name"> {
159
167
  symbol: TSOutputSymbol;
168
+ TypeSlot: SymbolSlot;
160
169
  }
161
170
 
162
171
  interface DeclaredTypeParameterDescriptor
@@ -194,16 +203,11 @@ function normalizeAndDeclareParameters(
194
203
  }
195
204
  if (typeof parameters[0] === "string") {
196
205
  return (parameters as string[]).map((paramName) => {
197
- const name = namePolicy.getName(
198
- paramName,
199
- flags & TSSymbolFlags.TypeSymbol ? "type" : "parameter",
200
- );
206
+ const name = namePolicy.getName(paramName, "parameter");
207
+ const TypeSlot = createSymbolSlot();
208
+ const symbol = createValueSymbol(name, { type: TypeSlot.firstSymbol });
201
209
 
202
- const symbol = new TSOutputSymbol(name, {
203
- tsFlags: flags,
204
- });
205
-
206
- return { refkeys: symbol.refkeys, symbol };
210
+ return { refkeys: symbol.refkeys, symbol, TypeSlot };
207
211
  });
208
212
  } else {
209
213
  return (parameters as ParameterDescriptor[]).map((param) => {
@@ -211,22 +215,21 @@ function normalizeAndDeclareParameters(
211
215
  (param.nullish ?? param.optional) ?
212
216
  TSSymbolFlags.Nullish
213
217
  : TSSymbolFlags.None;
214
-
215
- const symbol = new TSOutputSymbol(
216
- namePolicy.getName(
217
- param.name,
218
- flags & TSSymbolFlags.TypeSymbol ? "type" : "parameter",
219
- ),
218
+ const TypeSlot = createSymbolSlot();
219
+ const symbol = createValueSymbol(
220
+ namePolicy.getName(param.name, "parameter"),
220
221
  {
221
222
  refkeys: param.refkey,
222
223
  tsFlags: flags | nullishFlag,
223
224
  metadata: param.metadata,
225
+ type: TypeSlot.firstSymbol,
224
226
  },
225
227
  );
226
228
 
227
229
  return {
228
230
  ...param,
229
231
  symbol,
232
+ TypeSlot,
230
233
  };
231
234
  });
232
235
  }
@@ -265,7 +268,9 @@ export const TypeParameters = taggedComponent(
265
268
  <group>
266
269
  <Indent softline>
267
270
  <For each={typeParameters} comma line>
268
- {(param) => typeParameter(param)}
271
+ {(param) =>
272
+ typeParameter(param as DeclaredTypeParameterDescriptor)
273
+ }
269
274
  </For>
270
275
  <ifBreak>,</ifBreak>
271
276
  </Indent>
@@ -4,7 +4,6 @@ import {
4
4
  findUnkeyedChildren,
5
5
  Name,
6
6
  Prose,
7
- Scope,
8
7
  Show,
9
8
  type Children,
10
9
  } from "@alloy-js/core";
@@ -19,6 +18,7 @@ import {
19
18
  } from "./FunctionBase.jsx";
20
19
  import { JSDoc } from "./JSDoc.jsx";
21
20
  import { JSDocParams } from "./JSDocParam.jsx";
21
+ import { LexicalScope } from "./LexicalScope.jsx";
22
22
 
23
23
  export interface FunctionDeclarationProps
24
24
  extends BaseDeclarationProps,
@@ -77,10 +77,10 @@ export function FunctionDeclaration(props: FunctionDeclarationProps) {
77
77
  </Show>
78
78
  <Declaration {...props} nameKind="function">
79
79
  {asyncKwd}function <Name />
80
- <Scope name={props.name} kind="function">
80
+ <LexicalScope name={props.name}>
81
81
  <CallSignature {...callSignatureProps} returnType={returnType} />{" "}
82
82
  {sBody}
83
- </Scope>
83
+ </LexicalScope>
84
84
  </Declaration>
85
85
  </>
86
86
  );
@@ -2,18 +2,17 @@ import {
2
2
  childrenArray,
3
3
  findKeyedChild,
4
4
  findUnkeyedChildren,
5
- Scope,
6
5
  type Children,
7
6
  } from "@alloy-js/core";
8
7
  import { getCallSignatureProps } from "../utils.js";
9
8
  import { CallSignature, CallSignatureProps } from "./CallSignature.jsx";
10
- import { Declaration } from "./Declaration.jsx";
11
9
  import {
12
10
  FunctionBody,
13
11
  FunctionParameters,
14
12
  getReturnType,
15
13
  TypeParameters,
16
14
  } from "./FunctionBase.jsx";
15
+ import { LexicalScope } from "./LexicalScope.jsx";
17
16
 
18
17
  export interface FunctionExpressionProps extends CallSignatureProps {
19
18
  async?: boolean;
@@ -69,14 +68,12 @@ export function FunctionExpression(props: FunctionExpressionProps) {
69
68
 
70
69
  return (
71
70
  <>
72
- <Declaration {...props} nameKind="function">
73
- {asyncKwd}
74
- {"function "}
75
- <Scope kind="function">
76
- <CallSignature {...callSignatureProps} returnType={returnType} />{" "}
77
- {sBody}
78
- </Scope>
79
- </Declaration>
71
+ {asyncKwd}
72
+ {"function "}
73
+ <LexicalScope>
74
+ <CallSignature {...callSignatureProps} returnType={returnType} />{" "}
75
+ {sBody}
76
+ </LexicalScope>
80
77
  </>
81
78
  );
82
79
  }
@@ -2,7 +2,6 @@ import {
2
2
  childrenArray,
3
3
  findKeyedChild,
4
4
  Prose,
5
- Scope,
6
5
  Show,
7
6
  type Children,
8
7
  } from "@alloy-js/core";
@@ -16,6 +15,7 @@ import {
16
15
  } from "./FunctionBase.jsx";
17
16
  import { JSDoc } from "./JSDoc.jsx";
18
17
  import { JSDocParams } from "./JSDocParam.jsx";
18
+ import { LexicalScope } from "./LexicalScope.jsx";
19
19
  import { ensureTypeRefContext } from "./TypeRefContext.jsx";
20
20
 
21
21
  /**
@@ -57,11 +57,11 @@ const FunctionTypeComponent = ensureTypeRefContext(
57
57
  </JSDoc>
58
58
  <hbr />
59
59
  </Show>
60
- <Scope kind="function">
60
+ <LexicalScope>
61
61
  <CallSignature {...callSignatureProps} returnType={null} />
62
62
  {" => "}
63
63
  {returnType}
64
- </Scope>
64
+ </LexicalScope>
65
65
  </>
66
66
  );
67
67
  },
@@ -1,4 +1,5 @@
1
1
  import { Block, type Children } from "@alloy-js/core";
2
+ import { BlockScope } from "./BlockScope.jsx";
2
3
 
3
4
  export interface IfStatementProps {
4
5
  condition: Children;
@@ -11,7 +12,7 @@ export interface IfStatementProps {
11
12
  export function IfStatement(props: IfStatementProps) {
12
13
  return (
13
14
  <>
14
- if ({props.condition}) <Block>{props.children}</Block>
15
+ if ({props.condition}) <BlockScope>{props.children}</BlockScope>
15
16
  </>
16
17
  );
17
18
  }