@alloy-js/typescript 0.16.0 → 0.18.0-dev.3

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 (169) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/src/builtins/node.d.ts +11 -42
  3. package/dist/src/builtins/node.d.ts.map +1 -1
  4. package/dist/src/builtins/node.js +3 -0
  5. package/dist/src/components/ArrowFunction.d.ts +1 -1
  6. package/dist/src/components/ArrowFunction.d.ts.map +1 -1
  7. package/dist/src/components/CallSignature.d.ts +1 -1
  8. package/dist/src/components/CallSignature.d.ts.map +1 -1
  9. package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
  10. package/dist/src/components/ClassDeclaration.js +5 -7
  11. package/dist/src/components/Declaration.d.ts.map +1 -1
  12. package/dist/src/components/Declaration.js +3 -4
  13. package/dist/src/components/EnumDeclaration.d.ts.map +1 -1
  14. package/dist/src/components/EnumDeclaration.js +3 -4
  15. package/dist/src/components/EnumMember.d.ts.map +1 -1
  16. package/dist/src/components/EnumMember.js +3 -4
  17. package/dist/src/components/ExportStatement.d.ts +1 -1
  18. package/dist/src/components/ExportStatement.d.ts.map +1 -1
  19. package/dist/src/components/FunctionBase.d.ts +1 -1
  20. package/dist/src/components/FunctionBase.d.ts.map +1 -1
  21. package/dist/src/components/FunctionBase.js +15 -10
  22. package/dist/src/components/FunctionDeclaration.d.ts +1 -1
  23. package/dist/src/components/FunctionDeclaration.d.ts.map +1 -1
  24. package/dist/src/components/FunctionExpression.d.ts +1 -1
  25. package/dist/src/components/FunctionExpression.d.ts.map +1 -1
  26. package/dist/src/components/FunctionType.d.ts +1 -1
  27. package/dist/src/components/FunctionType.d.ts.map +1 -1
  28. package/dist/src/components/IfStatement.d.ts +1 -1
  29. package/dist/src/components/IfStatement.d.ts.map +1 -1
  30. package/dist/src/components/ImportStatement.d.ts.map +1 -1
  31. package/dist/src/components/Interface.js +1 -1
  32. package/dist/src/components/InterfaceMethod.d.ts +1 -2
  33. package/dist/src/components/InterfaceMethod.d.ts.map +1 -1
  34. package/dist/src/components/JSDoc.d.ts +1 -1
  35. package/dist/src/components/JSDoc.d.ts.map +1 -1
  36. package/dist/src/components/JSDocComment.d.ts +1 -1
  37. package/dist/src/components/JSDocComment.d.ts.map +1 -1
  38. package/dist/src/components/JSDocExample.d.ts +1 -1
  39. package/dist/src/components/JSDocExample.d.ts.map +1 -1
  40. package/dist/src/components/JSDocParam.d.ts +1 -1
  41. package/dist/src/components/JSDocParam.d.ts.map +1 -1
  42. package/dist/src/components/MemberDeclaration.d.ts.map +1 -1
  43. package/dist/src/components/MemberDeclaration.js +4 -4
  44. package/dist/src/components/MemberExpression.d.ts +6 -1
  45. package/dist/src/components/MemberExpression.d.ts.map +1 -1
  46. package/dist/src/components/MemberExpression.js +38 -14
  47. package/dist/src/components/NewExpression.d.ts +5 -0
  48. package/dist/src/components/NewExpression.d.ts.map +1 -0
  49. package/dist/src/components/NewExpression.js +12 -0
  50. package/dist/src/components/ObjectExpression.d.ts.map +1 -1
  51. package/dist/src/components/ObjectExpression.js +17 -18
  52. package/dist/src/components/PackageDirectory.d.ts.map +1 -1
  53. package/dist/src/components/PackageDirectory.js +3 -3
  54. package/dist/src/components/Reference.d.ts.map +1 -1
  55. package/dist/src/components/Reference.js +5 -1
  56. package/dist/src/components/SingleLineCommentBlock.d.ts +1 -1
  57. package/dist/src/components/SingleLineCommentBlock.d.ts.map +1 -1
  58. package/dist/src/components/SourceFile.d.ts +1 -2
  59. package/dist/src/components/SourceFile.d.ts.map +1 -1
  60. package/dist/src/components/SourceFile.js +3 -3
  61. package/dist/src/components/SwitchStatement.d.ts +1 -1
  62. package/dist/src/components/SwitchStatement.d.ts.map +1 -1
  63. package/dist/src/components/TypeRefContext.d.ts +1 -1
  64. package/dist/src/components/TypeRefContext.d.ts.map +1 -1
  65. package/dist/src/components/VarDeclaration.d.ts.map +1 -1
  66. package/dist/src/components/VarDeclaration.js +30 -10
  67. package/dist/src/components/index.d.ts +1 -0
  68. package/dist/src/components/index.d.ts.map +1 -1
  69. package/dist/src/components/index.js +1 -0
  70. package/dist/src/components/stc/index.d.ts +45 -43
  71. package/dist/src/components/stc/index.d.ts.map +1 -1
  72. package/dist/src/components/stc/index.js +46 -44
  73. package/dist/src/create-package.d.ts +63 -19
  74. package/dist/src/create-package.d.ts.map +1 -1
  75. package/dist/src/create-package.js +153 -15
  76. package/dist/src/index.d.ts +2 -0
  77. package/dist/src/index.d.ts.map +1 -1
  78. package/dist/src/index.js +2 -0
  79. package/dist/src/parameter-descriptor.d.ts +1 -1
  80. package/dist/src/parameter-descriptor.d.ts.map +1 -1
  81. package/dist/src/source-directory-data.d.ts.map +1 -1
  82. package/dist/src/source-directory-data.js +2 -2
  83. package/dist/src/symbols/reference.d.ts +2 -1
  84. package/dist/src/symbols/reference.d.ts.map +1 -1
  85. package/dist/src/symbols/reference.js +3 -4
  86. package/dist/src/symbols/scopes.d.ts +1 -4
  87. package/dist/src/symbols/scopes.d.ts.map +1 -1
  88. package/dist/src/symbols/ts-member-scope.d.ts +4 -6
  89. package/dist/src/symbols/ts-member-scope.d.ts.map +1 -1
  90. package/dist/src/symbols/ts-member-scope.js +8 -10
  91. package/dist/src/symbols/ts-module-scope.d.ts +8 -11
  92. package/dist/src/symbols/ts-module-scope.d.ts.map +1 -1
  93. package/dist/src/symbols/ts-module-scope.js +47 -40
  94. package/dist/src/symbols/ts-output-symbol.d.ts +23 -16
  95. package/dist/src/symbols/ts-output-symbol.d.ts.map +1 -1
  96. package/dist/src/symbols/ts-output-symbol.js +88 -27
  97. package/dist/src/symbols/ts-package-scope.d.ts +18 -14
  98. package/dist/src/symbols/ts-package-scope.d.ts.map +1 -1
  99. package/dist/src/symbols/ts-package-scope.js +78 -27
  100. package/dist/src/utils.js +1 -1
  101. package/dist/test/class.test.js +2 -1
  102. package/dist/test/externals.test.js +87 -2
  103. package/dist/test/function-declaration.test.js +74 -3
  104. package/dist/test/member-expression.test.js +108 -2
  105. package/dist/test/new-expression.test.d.ts +2 -0
  106. package/dist/test/new-expression.test.d.ts.map +1 -0
  107. package/dist/test/new-expression.test.js +62 -0
  108. package/dist/test/values.test.d.ts.map +1 -1
  109. package/dist/test/values.test.js +48 -1
  110. package/dist/test/var-declaration.test.d.ts.map +1 -1
  111. package/dist/test/var-declaration.test.js +145 -2
  112. package/dist/tsconfig.tsbuildinfo +1 -1
  113. package/package.json +22 -21
  114. package/src/builtins/node.ts +4 -0
  115. package/src/components/ArrowFunction.tsx +1 -1
  116. package/src/components/CallSignature.tsx +1 -1
  117. package/src/components/ClassDeclaration.tsx +5 -7
  118. package/src/components/Declaration.tsx +3 -8
  119. package/src/components/EnumDeclaration.tsx +3 -4
  120. package/src/components/EnumMember.tsx +3 -4
  121. package/src/components/FunctionBase.tsx +26 -19
  122. package/src/components/FunctionDeclaration.tsx +1 -1
  123. package/src/components/FunctionExpression.tsx +1 -1
  124. package/src/components/FunctionType.tsx +1 -1
  125. package/src/components/IfStatement.tsx +1 -2
  126. package/src/components/ImportStatement.tsx +0 -1
  127. package/src/components/Interface.tsx +1 -1
  128. package/src/components/InterfaceMethod.tsx +1 -1
  129. package/src/components/JSDoc.tsx +1 -2
  130. package/src/components/JSDocComment.tsx +1 -1
  131. package/src/components/JSDocExample.tsx +1 -2
  132. package/src/components/JSDocParam.tsx +1 -2
  133. package/src/components/MemberDeclaration.tsx +5 -8
  134. package/src/components/MemberExpression.tsx +67 -15
  135. package/src/components/NewExpression.tsx +25 -0
  136. package/src/components/ObjectExpression.tsx +21 -19
  137. package/src/components/PackageDirectory.tsx +2 -10
  138. package/src/components/Reference.tsx +4 -2
  139. package/src/components/SingleLineCommentBlock.tsx +1 -2
  140. package/src/components/SourceFile.tsx +3 -6
  141. package/src/components/SwitchStatement.tsx +1 -2
  142. package/src/components/TypeRefContext.tsx +1 -1
  143. package/src/components/VarDeclaration.tsx +34 -11
  144. package/src/components/index.ts +1 -0
  145. package/src/components/stc/index.ts +46 -44
  146. package/src/create-package.ts +276 -37
  147. package/src/index.ts +2 -0
  148. package/src/parameter-descriptor.ts +1 -1
  149. package/src/source-directory-data.ts +2 -2
  150. package/src/symbols/reference.ts +10 -5
  151. package/src/symbols/scopes.ts +1 -6
  152. package/src/symbols/ts-member-scope.ts +8 -23
  153. package/src/symbols/ts-module-scope.ts +58 -62
  154. package/src/symbols/ts-output-symbol.ts +108 -50
  155. package/src/symbols/ts-package-scope.ts +71 -53
  156. package/src/utils.ts +1 -1
  157. package/temp/api.json +3743 -3667
  158. package/test/class.test.tsx +2 -1
  159. package/test/externals.test.tsx +99 -1
  160. package/test/function-declaration.test.tsx +75 -2
  161. package/test/member-expression.test.tsx +93 -2
  162. package/test/new-expression.test.tsx +42 -0
  163. package/test/values.test.tsx +34 -0
  164. package/test/var-declaration.test.tsx +101 -1
  165. package/tsconfig.json +2 -1
  166. package/tsdoc-metadata.json +1 -1
  167. package/LICENSE +0 -7
  168. package/dist/test/vitest.d.js +0 -1
  169. package/test/vitest.d.ts +0 -15
@@ -1,45 +1,47 @@
1
- import { stc } from "@alloy-js/core";
1
+ // prettier-ignore
2
+ import * as core from "@alloy-js/core";
2
3
  import * as base from "../index.js";
3
- export const ArrayExpression = stc(base.ArrayExpression);
4
- export const ArrowFunction = stc(base.ArrowFunction);
5
- export const BarrelFile = stc(base.BarrelFile);
6
- export const CallSignature = stc(base.CallSignature);
7
- export const ClassDeclaration = stc(base.ClassDeclaration);
8
- export const ClassField = stc(base.ClassField);
9
- export const ClassMember = stc(base.ClassMember);
10
- export const ClassMethod = stc(base.ClassMethod);
11
- export const CommaList = stc(base.CommaList);
12
- export const Declaration = stc(base.Declaration);
13
- export const EnumDeclaration = stc(base.EnumDeclaration);
14
- export const EnumMember = stc(base.EnumMember);
15
- export const ExportStatement = stc(base.ExportStatement);
16
- export const FunctionCallExpression = stc(base.FunctionCallExpression);
17
- export const FunctionDeclaration = stc(base.FunctionDeclaration);
18
- export const FunctionExpression = stc(base.FunctionExpression);
19
- export const IfStatement = stc(base.IfStatement);
20
- export const ElseClause = stc(base.ElseClause);
21
- export const ElseIfClause = stc(base.ElseIfClause);
22
- export const ImportStatement = stc(base.ImportStatement);
23
- export const ImportStatements = stc(base.ImportStatements);
24
- export const InterfaceDeclaration = stc(base.InterfaceDeclaration);
25
- export const InterfaceExpression = stc(base.InterfaceExpression);
26
- export const InterfaceMember = stc(base.InterfaceMember);
27
- export const InterfaceMethod = stc(base.InterfaceMethod);
28
- export const JSDoc = stc(base.JSDoc);
29
- export const JSDocExample = stc(base.JSDocExample);
30
- export const JSDocComment = stc(base.JSDocComment);
31
- export const MemberExpression = stc(base.MemberExpression);
32
- export const ObjectExpression = stc(base.ObjectExpression);
33
- export const ObjectProperty = stc(base.ObjectProperty);
34
- export const PackageDirectory = stc(base.PackageDirectory);
35
- export const PackageJsonFile = stc(base.PackageJsonFile);
36
- export const Reference = stc(base.Reference);
37
- export const SourceFile = stc(base.SourceFile);
38
- export const SwitchStatement = stc(base.SwitchStatement);
39
- export const CaseClause = stc(base.CaseClause);
40
- export const TSConfigJson = stc(base.TSConfigJson);
41
- export const FunctionType = stc(base.FunctionType);
42
- export const TypeDeclaration = stc(base.TypeDeclaration);
43
- export const TypeRefContext = stc(base.TypeRefContext);
44
- export const ValueExpression = stc(base.ValueExpression);
45
- export const VarDeclaration = stc(base.VarDeclaration);
4
+ export const ArrayExpression = core.stc(base.ArrayExpression);
5
+ export const ArrowFunction = core.stc(base.ArrowFunction);
6
+ export const BarrelFile = core.stc(base.BarrelFile);
7
+ export const CallSignature = core.stc(base.CallSignature);
8
+ export const ClassDeclaration = core.stc(base.ClassDeclaration);
9
+ export const ClassField = core.stc(base.ClassField);
10
+ export const ClassMember = core.stc(base.ClassMember);
11
+ export const ClassMethod = core.stc(base.ClassMethod);
12
+ export const CommaList = core.stc(base.CommaList);
13
+ export const Declaration = core.stc(base.Declaration);
14
+ export const EnumDeclaration = core.stc(base.EnumDeclaration);
15
+ export const EnumMember = core.stc(base.EnumMember);
16
+ export const ExportStatement = core.stc(base.ExportStatement);
17
+ export const FunctionCallExpression = core.stc(base.FunctionCallExpression);
18
+ export const FunctionDeclaration = core.stc(base.FunctionDeclaration);
19
+ export const FunctionExpression = core.stc(base.FunctionExpression);
20
+ export const IfStatement = core.stc(base.IfStatement);
21
+ export const ElseClause = core.stc(base.ElseClause);
22
+ export const ElseIfClause = core.stc(base.ElseIfClause);
23
+ export const ImportStatement = core.stc(base.ImportStatement);
24
+ export const ImportStatements = core.stc(base.ImportStatements);
25
+ export const InterfaceDeclaration = core.stc(base.InterfaceDeclaration);
26
+ export const InterfaceExpression = core.stc(base.InterfaceExpression);
27
+ export const InterfaceMember = core.stc(base.InterfaceMember);
28
+ export const InterfaceMethod = core.stc(base.InterfaceMethod);
29
+ export const JSDoc = core.stc(base.JSDoc);
30
+ export const JSDocExample = core.stc(base.JSDocExample);
31
+ export const JSDocComment = core.stc(base.JSDocComment);
32
+ export const MemberExpression = core.stc(base.MemberExpression);
33
+ export const NewExpression = core.stc(base.NewExpression);
34
+ export const ObjectExpression = core.stc(base.ObjectExpression);
35
+ export const ObjectProperty = core.stc(base.ObjectProperty);
36
+ export const PackageDirectory = core.stc(base.PackageDirectory);
37
+ export const PackageJsonFile = core.stc(base.PackageJsonFile);
38
+ export const Reference = core.stc(base.Reference);
39
+ export const SourceFile = core.stc(base.SourceFile);
40
+ export const SwitchStatement = core.stc(base.SwitchStatement);
41
+ export const CaseClause = core.stc(base.CaseClause);
42
+ export const TSConfigJson = core.stc(base.TSConfigJson);
43
+ export const FunctionType = core.stc(base.FunctionType);
44
+ export const TypeDeclaration = core.stc(base.TypeDeclaration);
45
+ export const TypeRefContext = core.stc(base.TypeRefContext);
46
+ export const ValueExpression = core.stc(base.ValueExpression);
47
+ export const VarDeclaration = core.stc(base.VarDeclaration);
@@ -1,33 +1,77 @@
1
- import { Refkey, SymbolCreator } from "@alloy-js/core";
1
+ import { type Refkey, SymbolCreator } from "@alloy-js/core";
2
2
  export interface PackageDescriptor {
3
3
  [path: string]: ModuleSymbolsDescriptor;
4
4
  }
5
+ /**
6
+ * Describes the structure of a module descriptor.
7
+ *
8
+ * A module descriptor can either be a string (representing the module name)
9
+ * or an object with the following properties:
10
+ * - `name`: The name of the module.
11
+ * - `staticMembers`: An optional array of named module descriptors representing
12
+ * static members of the module.
13
+ * - `instanceMembers`: An optional array of named module descriptors representing
14
+ * instance members of the module.
15
+ */
16
+ export type NamedModuleDescriptor = string | {
17
+ name: string;
18
+ staticMembers?: Array<NamedModuleDescriptor>;
19
+ instanceMembers?: Array<NamedModuleDescriptor>;
20
+ };
21
+ /**
22
+ * Describes the symbols exported by a module.
23
+ */
5
24
  export interface ModuleSymbolsDescriptor {
6
25
  default?: string;
7
- named?: readonly string[];
26
+ named?: NamedModuleDescriptor[];
8
27
  }
9
- export type PackageRefkeys<T extends PackageDescriptor> = {
10
- [K in keyof T as K extends "." ? never : K]: {
11
- [N in T[K]["named"] extends readonly string[] ? T[K]["named"][number] : never]: Refkey;
12
- } & (T[K] extends {
13
- default: string;
14
- } ? {
15
- default: Refkey;
16
- } : {});
17
- } & (T["."] extends {
18
- default: string;
19
- } ? {
20
- default: Refkey;
21
- } : {}) & (T["."] extends {
22
- named: readonly string[];
23
- } ? {
24
- [N in T["."]["named"][number]]: Refkey;
25
- } : {});
28
+ /**
29
+ * Props for creating a package with a specific name, version, and descriptor.
30
+ */
26
31
  export interface CreatePackageProps<T extends PackageDescriptor> {
27
32
  name: string;
28
33
  version: string;
29
34
  descriptor: T;
30
35
  builtin?: boolean;
31
36
  }
37
+ /**
38
+ * Infers the exported members of a module based on its descriptor.
39
+ *
40
+ * D - The module descriptor, which may specify a `default` export (as a string)
41
+ * and/or an array of named exports (`named`).
42
+ *
43
+ * If `D` includes a `default` property of type `string`, the resulting type will include a
44
+ * `default` property of type `Refkey`. If `D` includes a `named` property (an array of
45
+ * `NamedModuleDescriptor`), the resulting type will include the mapped named exports as
46
+ * defined by `NamedMap`.
47
+ */
48
+ export type ModuleExports<D extends {
49
+ default?: string;
50
+ named?: NamedModuleDescriptor[];
51
+ }> = (D extends {
52
+ default: string;
53
+ } ? {
54
+ default: Refkey;
55
+ } : {}) & (D["named"] extends NamedModuleDescriptor[] ? NamedMap<D["named"]> : {});
56
+ export type PackageRefkeys<PD extends Record<string, {
57
+ default?: string;
58
+ named?: NamedModuleDescriptor[];
59
+ }>> = ModuleExports<PD["."]> & {
60
+ [P in keyof PD as P extends "." ? never : P]: ModuleExports<PD[P]>;
61
+ };
62
+ export type NamedMap<TDescriptor extends readonly NamedModuleDescriptor[]> = {
63
+ [S in Extract<TDescriptor[number], string>]: Refkey;
64
+ } & {
65
+ [O in Extract<TDescriptor[number], {
66
+ name: string;
67
+ }> as O["name"]]: Refkey & {
68
+ static: O extends ({
69
+ staticMembers: infer SM extends NamedModuleDescriptor[];
70
+ }) ? NamedMap<SM> : {};
71
+ instance: O extends ({
72
+ instanceMembers: infer IM extends NamedModuleDescriptor[];
73
+ }) ? NamedMap<IM> : {};
74
+ };
75
+ };
32
76
  export declare function createPackage<const T extends PackageDescriptor>(props: CreatePackageProps<T>): PackageRefkeys<T> & SymbolCreator;
33
77
  //# sourceMappingURL=create-package.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-package.d.ts","sourceRoot":"","sources":["../../src/create-package.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,EAEN,aAAa,EACd,MAAM,gBAAgB,CAAC;AAQxB,MAAM,WAAW,iBAAiB;IAChC,CAAC,IAAI,EAAE,MAAM,GAAG,uBAAuB,CAAC;CACzC;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B;AAgDD,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,iBAAiB,IAAI;KACvD,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,GAAG,GAAG,KAAK,GAAG,CAAC,GAAG;S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,GAAG,CAAC,GAAG,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;CACnE,CAAC;AAUF,MAAM,MAAM,QAAQ,CAAC,WAAW,SAAS,SAAS,qBAAqB,EAAE,IAEvE;KACG,CAAC,IAAI,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,GAAG,MAAM;CACpD,GAAG;KAED,CAAC,IAAI,OAAO,CACX,WAAW,CAAC,MAAM,CAAC,EACnB;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CACjB,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG;QACxB,MAAM,EAAE,CAAC,SAAS,CAChB;YAAE,aAAa,EAAE,MAAM,EAAE,SAAS,qBAAqB,EAAE,CAAA;SAAE,CAC5D,GACC,QAAQ,CAAC,EAAE,CAAC,GACZ,EAAE,CAAC;QACL,QAAQ,EAAE,CAAC,SAAS,CAClB;YAAE,eAAe,EAAE,MAAM,EAAE,SAAS,qBAAqB,EAAE,CAAA;SAAE,CAC9D,GACC,QAAQ,CAAC,EAAE,CAAC,GACZ,EAAE,CAAC;KACN;CACF,CAAC;AA0KJ,wBAAgB,aAAa,CAAC,KAAK,CAAC,CAAC,SAAS,iBAAiB,EAC7D,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC3B,cAAc,CAAC,CAAC,CAAC,GAAG,aAAa,CA6DnC"}
@@ -1,32 +1,153 @@
1
- import { getSymbolCreatorSymbol, refkey } from "@alloy-js/core";
2
- import { createTSModuleScope, createTSPackageScope, createTSSymbol } from "./symbols/index.js";
1
+ import { getSymbolCreatorSymbol, OutputSymbolFlags, refkey } from "@alloy-js/core";
2
+ import { TSModuleScope, TSOutputSymbol, TSPackageScope } from "./symbols/index.js";
3
+
4
+ /**
5
+ * Describes the structure of a module descriptor.
6
+ *
7
+ * A module descriptor can either be a string (representing the module name)
8
+ * or an object with the following properties:
9
+ * - `name`: The name of the module.
10
+ * - `staticMembers`: An optional array of named module descriptors representing
11
+ * static members of the module.
12
+ * - `instanceMembers`: An optional array of named module descriptors representing
13
+ * instance members of the module.
14
+ */
15
+
16
+ /**
17
+ * Describes the symbols exported by a module.
18
+ */
19
+
20
+ /**
21
+ * Props for creating a package with a specific name, version, and descriptor.
22
+ */
23
+
24
+ /**
25
+ * Infers the exported members of a module based on its descriptor.
26
+ *
27
+ * D - The module descriptor, which may specify a `default` export (as a string)
28
+ * and/or an array of named exports (`named`).
29
+ *
30
+ * If `D` includes a `default` property of type `string`, the resulting type will include a
31
+ * `default` property of type `Refkey`. If `D` includes a `named` property (an array of
32
+ * `NamedModuleDescriptor`), the resulting type will include the mapped named exports as
33
+ * defined by `NamedMap`.
34
+ */
35
+
36
+ // NamedMap is a utility type that maps the named module descriptors
37
+ // to their corresponding Refkey types. It handles both string and object
38
+ // entries in the array of named module descriptors.
39
+ // It creates a mapping where:
40
+ // For each TDescriptor extends NamedModuleDescriptor[]:
41
+ // • string entries ➜ { [s]: Refkey }
42
+ // • object entries ➜ { [name]: Refkey & { static: …; instance: … } }
43
+ // ────────────────────────────────────────────────────────────────
44
+
45
+ function assignMembers(binder, ownerSym, members, keys, isStatic) {
46
+ let scope;
47
+ if (isStatic) {
48
+ ownerSym.flags |= OutputSymbolFlags.StaticMemberContainer;
49
+ scope = ownerSym.staticMemberScope;
50
+ } else {
51
+ ownerSym.flags |= OutputSymbolFlags.InstanceMemberContainer;
52
+ scope = ownerSym.instanceMemberScope;
53
+ }
54
+ const namespace = isStatic ? "static" : "instance";
55
+ for (const member of members) {
56
+ const memberObj = typeof member === "object" ? member : {
57
+ name: member
58
+ };
59
+
60
+ // The refkey is located in the appropriate namespace
61
+ const memberKey = keys[namespace][memberObj.name];
62
+ if (!memberKey) continue; // Skip if key doesn't exist
63
+
64
+ let memberFlags = isStatic ? OutputSymbolFlags.StaticMember : OutputSymbolFlags.InstanceMember;
65
+ if (memberObj.staticMembers?.length) {
66
+ memberFlags |= OutputSymbolFlags.StaticMemberContainer;
67
+ }
68
+ if (memberObj.instanceMembers?.length) {
69
+ memberFlags |= OutputSymbolFlags.InstanceMemberContainer;
70
+ }
71
+ const memberSym = new TSOutputSymbol(memberObj.name, {
72
+ scope,
73
+ binder,
74
+ refkeys: memberKey,
75
+ export: false,
76
+ default: false,
77
+ flags: memberFlags
78
+ });
79
+ scope.symbols.add(memberSym);
80
+
81
+ // Recursively handle nested static and instance members
82
+ if (memberObj.staticMembers && isStatic) {
83
+ assignMembers(binder, memberSym, memberObj.staticMembers, keys[namespace][memberObj.name], true);
84
+ }
85
+ if (memberObj.instanceMembers && !isStatic) {
86
+ assignMembers(binder, memberSym, memberObj.instanceMembers, keys[namespace][memberObj.name], false);
87
+ }
88
+ }
89
+ }
3
90
  function createSymbols(binder, props, refkeys) {
4
- const pkgScope = createTSPackageScope(binder, undefined, props.name, props.version, `node_modules/${props.name}`, props.builtin);
91
+ const pkgScope = new TSPackageScope(props.name, props.version, `node_modules/${props.name}`, {
92
+ binder,
93
+ builtin: props.builtin
94
+ });
5
95
  for (const [path, symbols] of Object.entries(props.descriptor)) {
6
96
  const keys = path === "." ? refkeys : refkeys[path];
7
- const moduleScope = createTSModuleScope(binder, pkgScope, path);
97
+ const moduleScope = new TSModuleScope(path, {
98
+ binder,
99
+ parent: pkgScope
100
+ });
8
101
  pkgScope.exportedSymbols.set(path, moduleScope);
9
102
  if (symbols.default) {
10
103
  const key = keys.default;
11
- const sym = createTSSymbol({
12
- name: symbols.default,
104
+ const sym = new TSOutputSymbol(symbols.default, {
13
105
  scope: moduleScope,
14
- refkey: key,
106
+ refkeys: key,
15
107
  export: true,
16
108
  default: true
17
109
  });
18
110
  moduleScope.exportedSymbols.set(key, sym);
19
111
  }
20
112
  for (const exportedName of symbols.named ?? []) {
21
- const key = keys[exportedName];
22
- const sym = createTSSymbol({
23
- name: exportedName,
113
+ const namedRef = typeof exportedName === "string" ? {
114
+ name: exportedName
115
+ } : exportedName;
116
+ const key = keys[namedRef.name];
117
+ let flags = OutputSymbolFlags.None;
118
+ if (namedRef.staticMembers?.length) {
119
+ flags |= OutputSymbolFlags.StaticMemberContainer;
120
+ }
121
+ if (namedRef.instanceMembers?.length) {
122
+ flags |= OutputSymbolFlags.InstanceMemberContainer;
123
+ }
124
+ const ownerSym = new TSOutputSymbol(namedRef.name, {
125
+ binder,
24
126
  scope: moduleScope,
25
- refkey: key,
127
+ refkeys: key,
26
128
  export: true,
27
- default: false
129
+ default: false,
130
+ flags
28
131
  });
29
- moduleScope.exportedSymbols.set(key, sym);
132
+ moduleScope.exportedSymbols.set(key, ownerSym);
133
+ assignMembers(binder, ownerSym, namedRef.staticMembers ?? [], keys[namedRef.name], /* isStatic */true);
134
+ assignMembers(binder, ownerSym, namedRef.instanceMembers ?? [], keys[namedRef.name], /* isStatic */false);
135
+ }
136
+ }
137
+ }
138
+ function createRefkeysForMembers(members, keys, namespace) {
139
+ keys[namespace] ??= {};
140
+ for (const member of members) {
141
+ const memberObj = typeof member === "string" ? {
142
+ name: member
143
+ } : member;
144
+ const memberKey = refkey();
145
+ keys[namespace][memberObj.name] = memberKey;
146
+ if (memberObj.staticMembers?.length) {
147
+ createRefkeysForMembers(memberObj.staticMembers, memberKey, "static");
148
+ }
149
+ if (memberObj.instanceMembers?.length) {
150
+ createRefkeysForMembers(memberObj.instanceMembers, memberKey, "instance");
30
151
  }
31
152
  }
32
153
  }
@@ -37,12 +158,29 @@ export function createPackage(props) {
37
158
  }
38
159
  };
39
160
  for (const [path, symbols] of Object.entries(props.descriptor)) {
40
- const keys = path === "." ? refkeys : (refkeys[path] = {}, refkeys[path]);
161
+ const keys = path === "." ? refkeys : refkeys[path] = {};
41
162
  if (symbols.default) {
42
163
  keys.default = refkey(props.descriptor, path, "default");
43
164
  }
44
165
  for (const named of symbols.named ?? []) {
45
- keys[named] = refkey(props.descriptor, path, named);
166
+ const namedObj = typeof named === "string" ? {
167
+ name: named
168
+ } : named;
169
+ keys[namedObj.name] = refkey();
170
+ if (namedObj.staticMembers?.length) {
171
+ createRefkeysForMembers(namedObj.staticMembers, keys[namedObj.name], "static");
172
+ }
173
+ if (namedObj.instanceMembers?.length) {
174
+ createRefkeysForMembers(namedObj.instanceMembers, keys[namedObj.name], "instance");
175
+ }
176
+ keys[namedObj.name][getSymbolCreatorSymbol()] = (binder, parentSym) => {
177
+ if (namedObj.staticMembers?.length) {
178
+ assignMembers(binder, parentSym, namedObj.staticMembers, keys[namedObj.name], true);
179
+ }
180
+ if (namedObj.instanceMembers?.length) {
181
+ assignMembers(binder, parentSym, namedObj.instanceMembers, keys[namedObj.name], false);
182
+ }
183
+ };
46
184
  }
47
185
  }
48
186
  return refkeys;
@@ -4,5 +4,7 @@ export * from "./context/index.js";
4
4
  export * from "./create-package.js";
5
5
  export * from "./name-conflict-resolver.js";
6
6
  export * from "./name-policy.js";
7
+ export * from "./parameter-descriptor.js";
8
+ export * from "./source-directory-data.js";
7
9
  export * from "./symbols/index.js";
8
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC"}
package/dist/src/index.js CHANGED
@@ -4,4 +4,6 @@ export * from "./context/index.js";
4
4
  export * from "./create-package.js";
5
5
  export * from "./name-conflict-resolver.js";
6
6
  export * from "./name-policy.js";
7
+ export * from "./parameter-descriptor.js";
8
+ export * from "./source-directory-data.js";
7
9
  export * from "./symbols/index.js";
@@ -1,4 +1,4 @@
1
- import { Children, Refkey } from "@alloy-js/core";
1
+ import type { Children, Refkey } from "@alloy-js/core";
2
2
  /**
3
3
  * Common properties for ParameterDescriptor and FunctionTypeParameterDescriptor.
4
4
  */
@@ -1 +1 @@
1
- {"version":3,"file":"parameter-descriptor.d.ts","sourceRoot":"","sources":["../../src/parameter-descriptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAEpC;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAE5B;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IAExB;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE5C;;OAEG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,uBAAuB;IAClE;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,+BACf,SAAQ,uBAAuB;CAAG;AAEpC;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AC,OAAO,CAAC,EAAE,QAAQ,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,+BACf,SAAQ,uBAAuB;CAAG;AAEpC;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAEpC;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7C"}
@@ -1 +1 @@
1
- {"version":3,"file":"source-directory-data.d.ts","sourceRoot":"","sources":["../../src/source-directory-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;CAC7B;AAOD,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,sBAAsB,uBAYvE"}
1
+ {"version":3,"file":"source-directory-data.d.ts","sourceRoot":"","sources":["../../src/source-directory-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;CAC7B;AAOD,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,sBAAsB,uBAYvE"}
@@ -1,11 +1,11 @@
1
- import { reactive } from "@alloy-js/core";
1
+ import { shallowReactive } from "@alloy-js/core";
2
2
  const sourceDirectoryData = new WeakMap();
3
3
  export function getSourceDirectoryData(sdContext) {
4
4
  if (sourceDirectoryData.has(sdContext)) {
5
5
  return sourceDirectoryData.get(sdContext);
6
6
  }
7
7
  const sdData = {
8
- modules: reactive(new Set())
8
+ modules: shallowReactive(new Set())
9
9
  };
10
10
  sourceDirectoryData.set(sdContext, sdData);
11
11
  return sdData;
@@ -1,6 +1,7 @@
1
1
  import { Refkey } from "@alloy-js/core";
2
+ import { TSOutputSymbol } from "./ts-output-symbol.js";
2
3
  export interface RefOptions {
3
4
  type?: boolean;
4
5
  }
5
- export declare function ref(refkey: Refkey, options?: RefOptions): () => string;
6
+ export declare function ref(refkey: Refkey, options?: RefOptions): () => [string, TSOutputSymbol | undefined];
6
7
  //# sourceMappingURL=reference.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../src/symbols/reference.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,EAKP,MAAM,gBAAgB,CAAC;AAcxB,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AACD,wBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,MAAM,MAAM,CAyGtE"}
1
+ {"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../src/symbols/reference.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,EAKP,MAAM,gBAAgB,CAAC;AAWxB,OAAO,EAAE,cAAc,EAAiB,MAAM,uBAAuB,CAAC;AAGtE,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AACD,wBAAgB,GAAG,CACjB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,UAAU,GACnB,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,CAAC,CA2G5C"}
@@ -11,14 +11,13 @@ export function ref(refkey, options) {
11
11
  const currentPrivateScope = usePrivateScope();
12
12
  return memo(() => {
13
13
  if (resolveResult.value === undefined) {
14
- return "<Unresolved Symbol>";
14
+ return ["<Unresolved Symbol>", undefined];
15
15
  }
16
16
  const {
17
17
  targetDeclaration,
18
18
  pathDown,
19
19
  memberPath
20
20
  } = resolveResult.value;
21
-
22
21
  // if we resolved a instance member, check if we should be able to access
23
22
  // it.
24
23
  if (targetDeclaration.flags & OutputSymbolFlags.InstanceMember) {
@@ -75,9 +74,9 @@ export function ref(refkey, options) {
75
74
  if (localSymbol) {
76
75
  memberPath[0] = localSymbol;
77
76
  }
78
- return buildMemberExpression(memberPath);
77
+ return [buildMemberExpression(memberPath), memberPath.at(-1)];
79
78
  } else {
80
- return buildMemberExpression([localSymbol ?? targetDeclaration]);
79
+ return [buildMemberExpression([localSymbol ?? targetDeclaration]), localSymbol ?? targetDeclaration];
81
80
  }
82
81
  });
83
82
  }
@@ -2,15 +2,12 @@ import { OutputScope } from "@alloy-js/core";
2
2
  import { TSMemberScope } from "./ts-member-scope.js";
3
3
  import { TSModuleScope } from "./ts-module-scope.js";
4
4
  import { TSPackageScope } from "./ts-package-scope.js";
5
- export type TSOutputScope = TSGlobalScope | TSPackageScope | TSModuleScope | TSFunctionScope | TSMemberScope | TSOtherScope;
5
+ export type TSOutputScope = TSGlobalScope | TSPackageScope | TSModuleScope | TSFunctionScope | TSMemberScope;
6
6
  export interface TSGlobalScope extends OutputScope {
7
7
  kind: "global";
8
8
  }
9
9
  export interface TSFunctionScope extends OutputScope {
10
10
  kind: "function";
11
11
  }
12
- export interface TSOtherScope extends OutputScope {
13
- kind: never;
14
- }
15
12
  export declare function useTSScope(): TSOutputScope;
16
13
  //# sourceMappingURL=scopes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../../../src/symbols/scopes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAY,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,MAAM,MAAM,aAAa,GACrB,aAAa,GACb,cAAc,GACd,aAAa,GACb,eAAe,GACf,aAAa,GACb,YAAY,CAAC;AAEjB,MAAM,WAAW,aAAc,SAAQ,WAAW;IAChD,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED,MAAM,WAAW,eAAgB,SAAQ,WAAW;IAClD,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,WAAW,YAAa,SAAQ,WAAW;IAC/C,IAAI,EAAE,KAAK,CAAC;CACb;AAED,wBAAgB,UAAU,IACH,aAAa,CACnC"}
1
+ {"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../../../src/symbols/scopes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAY,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,MAAM,MAAM,aAAa,GACrB,aAAa,GACb,cAAc,GACd,aAAa,GACb,eAAe,GACf,aAAa,CAAC;AAElB,MAAM,WAAW,aAAc,SAAQ,WAAW;IAChD,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED,MAAM,WAAW,eAAgB,SAAQ,WAAW;IAClD,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,wBAAgB,UAAU,IACH,aAAa,CACnC"}
@@ -1,9 +1,7 @@
1
- import { Binder, OutputScope } from "@alloy-js/core";
1
+ import { OutputScope } from "@alloy-js/core";
2
2
  import { TSOutputSymbol } from "./ts-output-symbol.js";
3
- export interface TSMemberScope extends OutputScope {
4
- kind: "member";
5
- owner: TSOutputSymbol;
6
- isStatic: boolean;
3
+ export declare class TSMemberScope extends OutputScope {
4
+ get kind(): "member";
5
+ get owner(): TSOutputSymbol;
7
6
  }
8
- export declare function createTSMemberScope(binder: Binder, parent: OutputScope | undefined, owner: TSOutputSymbol, isStatic?: boolean): TSMemberScope;
9
7
  //# sourceMappingURL=ts-member-scope.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ts-member-scope.d.ts","sourceRoot":"","sources":["../../../src/symbols/ts-member-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAoB,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,MAAM,WAAW,aAAc,SAAQ,WAAW;IAChD,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,cAAc,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,KAAK,EAAE,cAAc,EACrB,QAAQ,GAAE,OAAe,GACxB,aAAa,CAYf"}
1
+ {"version":3,"file":"ts-member-scope.d.ts","sourceRoot":"","sources":["../../../src/symbols/ts-member-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,qBAAa,aAAc,SAAQ,WAAW;IAC5C,IAAI,IAAI,IACC,QAAQ,CAChB;IAED,IAAI,KAAK,IACe,cAAc,CACrC;CACF"}
@@ -1,11 +1,9 @@
1
- import { OutputScopeFlags } from "@alloy-js/core";
2
- export function createTSMemberScope(binder, parent, owner, isStatic = false) {
3
- return binder.createScope({
4
- kind: "member",
5
- name: "members",
6
- flags: isStatic ? OutputScopeFlags.StaticMemberScope : OutputScopeFlags.MemberScope,
7
- owner,
8
- parent,
9
- isStatic
10
- });
1
+ import { OutputScope } from "@alloy-js/core";
2
+ export class TSMemberScope extends OutputScope {
3
+ get kind() {
4
+ return "member";
5
+ }
6
+ get owner() {
7
+ return super.owner;
8
+ }
11
9
  }
@@ -1,4 +1,4 @@
1
- import { Binder, OutputScope, Refkey } from "@alloy-js/core";
1
+ import { OutputScope, Refkey } from "@alloy-js/core";
2
2
  import { TSOutputSymbol } from "./ts-output-symbol.js";
3
3
  export interface ImportedSymbol {
4
4
  local: TSOutputSymbol;
@@ -8,15 +8,12 @@ export type ImportRecords = Map<TSModuleScope, Set<ImportedSymbol>>;
8
8
  export interface AddImportOptions {
9
9
  type?: boolean;
10
10
  }
11
- export interface TSModuleScope extends OutputScope {
12
- kind: "module";
13
- exportedSymbols: Map<Refkey, TSOutputSymbol>;
14
- /**
15
- * A mapping of foreign symbols to module-local symbols
16
- */
17
- importedSymbols: Map<TSOutputSymbol, TSOutputSymbol>;
18
- importedModules: ImportRecords;
19
- addImport(symbol: TSOutputSymbol, module: TSModuleScope, options?: AddImportOptions): TSOutputSymbol;
11
+ export declare class TSModuleScope extends OutputScope {
12
+ #private;
13
+ get kind(): "module";
14
+ get exportedSymbols(): Map<Refkey, TSOutputSymbol>;
15
+ get importedSymbols(): Map<TSOutputSymbol, TSOutputSymbol>;
16
+ get importedModules(): ImportRecords;
17
+ addImport(targetSymbol: TSOutputSymbol, targetModule: TSModuleScope, options?: AddImportOptions): TSOutputSymbol;
20
18
  }
21
- export declare function createTSModuleScope(binder: Binder, parent: OutputScope, path: string): TSModuleScope;
22
19
  //# sourceMappingURL=ts-module-scope.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ts-module-scope.d.ts","sourceRoot":"","sources":["../../../src/symbols/ts-module-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAU,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAEL,cAAc,EAEf,MAAM,uBAAuB,CAAC;AAE/B,MAAM,WAAW,cAAc;IAC7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