@alloy-js/typescript 0.23.0-dev.0 → 0.23.0-dev.4

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 (80) hide show
  1. package/dist/src/components/FunctionType.d.ts +1 -1
  2. package/dist/src/components/FunctionType.js +1 -1
  3. package/dist/src/components/FunctionType.js.map +1 -1
  4. package/dist/src/components/IfStatement.d.ts.map +1 -1
  5. package/dist/src/components/IfStatement.js +2 -3
  6. package/dist/src/components/IfStatement.js.map +1 -1
  7. package/dist/src/components/Interface.d.ts +1 -1
  8. package/dist/src/components/Interface.d.ts.map +1 -1
  9. package/dist/src/components/Interface.js +14 -9
  10. package/dist/src/components/Interface.js.map +1 -1
  11. package/dist/src/components/MemberScope.d.ts.map +1 -1
  12. package/dist/src/components/MemberScope.js +6 -2
  13. package/dist/src/components/MemberScope.js.map +1 -1
  14. package/dist/src/components/PackageDirectory.d.ts.map +1 -1
  15. package/dist/src/components/PackageDirectory.js +2 -2
  16. package/dist/src/components/PackageDirectory.js.map +1 -1
  17. package/dist/src/components/SourceFile.d.ts.map +1 -1
  18. package/dist/src/components/SourceFile.js +4 -2
  19. package/dist/src/components/SourceFile.js.map +1 -1
  20. package/dist/src/components/TryStatement.d.ts +80 -0
  21. package/dist/src/components/TryStatement.d.ts.map +1 -0
  22. package/dist/src/components/TryStatement.js +112 -0
  23. package/dist/src/components/TryStatement.js.map +1 -0
  24. package/dist/src/components/TryStatement.test.d.ts +2 -0
  25. package/dist/src/components/TryStatement.test.d.ts.map +1 -0
  26. package/dist/src/components/TryStatement.test.js +121 -0
  27. package/dist/src/components/TryStatement.test.js.map +1 -0
  28. package/dist/src/components/TypeDeclaration.d.ts +1 -1
  29. package/dist/src/components/TypeDeclaration.d.ts.map +1 -1
  30. package/dist/src/components/TypeDeclaration.js +1 -1
  31. package/dist/src/components/TypeDeclaration.js.map +1 -1
  32. package/dist/src/components/TypeRefContext.d.ts +1 -1
  33. package/dist/src/components/TypeRefContext.d.ts.map +1 -1
  34. package/dist/src/components/TypeRefContext.js +1 -1
  35. package/dist/src/components/TypeRefContext.js.map +1 -1
  36. package/dist/src/components/index.d.ts +1 -0
  37. package/dist/src/components/index.d.ts.map +1 -1
  38. package/dist/src/components/index.js +1 -0
  39. package/dist/src/components/index.js.map +1 -1
  40. package/dist/src/context/type-ref-context.d.ts.map +1 -1
  41. package/dist/src/context/type-ref-context.js +2 -2
  42. package/dist/src/context/type-ref-context.js.map +1 -1
  43. package/dist/src/create-package.d.ts.map +1 -1
  44. package/dist/src/create-package.js +7 -6
  45. package/dist/src/create-package.js.map +1 -1
  46. package/dist/src/symbols/index.d.ts.map +1 -1
  47. package/dist/src/symbols/index.js +47 -11
  48. package/dist/src/symbols/index.js.map +1 -1
  49. package/dist/src/symbols/ts-module-scope.d.ts +1 -0
  50. package/dist/src/symbols/ts-module-scope.d.ts.map +1 -1
  51. package/dist/src/symbols/ts-module-scope.js +14 -3
  52. package/dist/src/symbols/ts-module-scope.js.map +1 -1
  53. package/dist/src/symbols/ts-output-symbol.d.ts +1 -0
  54. package/dist/src/symbols/ts-output-symbol.d.ts.map +1 -1
  55. package/dist/src/symbols/ts-output-symbol.js +20 -3
  56. package/dist/src/symbols/ts-output-symbol.js.map +1 -1
  57. package/dist/src/symbols/ts-package-scope.d.ts +1 -0
  58. package/dist/src/symbols/ts-package-scope.d.ts.map +1 -1
  59. package/dist/src/symbols/ts-package-scope.js +8 -0
  60. package/dist/src/symbols/ts-package-scope.js.map +1 -1
  61. package/dist/tsconfig.tsbuildinfo +1 -1
  62. package/package.json +9 -5
  63. package/src/components/FunctionType.tsx +1 -1
  64. package/src/components/IfStatement.tsx +3 -3
  65. package/src/components/Interface.tsx +24 -13
  66. package/src/components/MemberScope.tsx +13 -3
  67. package/src/components/PackageDirectory.tsx +2 -1
  68. package/src/components/SourceFile.tsx +4 -1
  69. package/src/components/TryStatement.test.tsx +123 -0
  70. package/src/components/TryStatement.tsx +141 -0
  71. package/src/components/TypeDeclaration.tsx +15 -15
  72. package/src/components/TypeRefContext.tsx +2 -2
  73. package/src/components/index.ts +1 -0
  74. package/src/context/type-ref-context.tsx +6 -2
  75. package/src/create-package.ts +29 -15
  76. package/src/symbols/index.ts +36 -10
  77. package/src/symbols/ts-module-scope.ts +36 -9
  78. package/src/symbols/ts-output-symbol.ts +21 -2
  79. package/src/symbols/ts-package-scope.ts +9 -0
  80. package/temp/api.json +471 -63
@@ -1,5 +1,7 @@
1
1
  import {
2
2
  createComponent,
3
+ createScope,
4
+ createSymbol,
3
5
  Namekey,
4
6
  onCleanup,
5
7
  OutputScopeOptions,
@@ -25,7 +27,8 @@ export function createTypeAndValueSymbol(
25
27
  ) {
26
28
  const scope = useLexicalScope();
27
29
  const spaces = scope ? [scope.types, scope.values] : [];
28
- return new TSOutputSymbol(name, spaces, options);
30
+ const binder = options.binder ?? scope?.binder;
31
+ return createSymbol(TSOutputSymbol, name, spaces, { ...options, binder });
29
32
  }
30
33
 
31
34
  export function createTypeSymbol(
@@ -39,7 +42,8 @@ export function createTypeSymbol(
39
42
  );
40
43
  }
41
44
  const spaces = scope ? [scope.types] : [];
42
- return new TSOutputSymbol(name, spaces, options);
45
+ const binder = options.binder ?? scope?.binder;
46
+ return createSymbol(TSOutputSymbol, name, spaces, { ...options, binder });
43
47
  }
44
48
 
45
49
  export function createValueSymbol(
@@ -53,11 +57,12 @@ export function createValueSymbol(
53
57
  );
54
58
  }
55
59
  const spaces = scope ? [scope.values] : [];
56
- return new TSOutputSymbol(name, spaces, options);
60
+ const binder = options.binder ?? scope?.binder;
61
+ return createSymbol(TSOutputSymbol, name, spaces, { ...options, binder });
57
62
  }
58
63
 
59
64
  export function createTransientValueSymbol() {
60
- return new TSOutputSymbol("transient-value", undefined, {
65
+ return createSymbol(TSOutputSymbol, "transient-value", undefined, {
61
66
  transient: true,
62
67
  });
63
68
  }
@@ -67,7 +72,11 @@ export function createStaticMemberSymbol(
67
72
  options: CreateTsSymbolOptions = {},
68
73
  ) {
69
74
  const owner = useMemberOwner();
70
- return new TSOutputSymbol(name, owner.staticMembers, options);
75
+ const binder = options.binder ?? owner.binder;
76
+ return createSymbol(TSOutputSymbol, name, owner.staticMembers, {
77
+ ...options,
78
+ binder,
79
+ });
71
80
  }
72
81
 
73
82
  export function createInstanceMemberSymbol(
@@ -75,7 +84,11 @@ export function createInstanceMemberSymbol(
75
84
  options: CreateTsSymbolOptions = {},
76
85
  ) {
77
86
  const owner = useMemberOwner();
78
- return new TSOutputSymbol(name, owner.instanceMembers, options);
87
+ const binder = options.binder ?? owner.binder;
88
+ return createSymbol(TSOutputSymbol, name, owner.instanceMembers, {
89
+ ...options,
90
+ binder,
91
+ });
79
92
  }
80
93
 
81
94
  export function createPrivateStaticMemberSymbol(
@@ -83,7 +96,11 @@ export function createPrivateStaticMemberSymbol(
83
96
  options: CreateTsSymbolOptions = {},
84
97
  ) {
85
98
  const owner = useMemberOwner();
86
- return new TSOutputSymbol(name, owner.privateStaticMembers, options);
99
+ const binder = options.binder ?? owner.binder;
100
+ return createSymbol(TSOutputSymbol, name, owner.privateStaticMembers, {
101
+ ...options,
102
+ binder,
103
+ });
87
104
  }
88
105
 
89
106
  export function createPrivateInstanceMemberSymbol(
@@ -91,7 +108,11 @@ export function createPrivateInstanceMemberSymbol(
91
108
  options: CreateTsSymbolOptions = {},
92
109
  ) {
93
110
  const owner = useMemberOwner();
94
- return new TSOutputSymbol(name, owner.privateInstanceMembers, options);
111
+ const binder = options.binder ?? owner.binder;
112
+ return createSymbol(TSOutputSymbol, name, owner.privateInstanceMembers, {
113
+ ...options,
114
+ binder,
115
+ });
95
116
  }
96
117
 
97
118
  export function createMemberSymbol(
@@ -120,7 +141,8 @@ export function createLexicalScope(
120
141
  ) {
121
142
  const parent = useTSScope();
122
143
 
123
- return new TSLexicalScope(name, parent, options);
144
+ const binder = options.binder ?? parent?.binder;
145
+ return createScope(TSLexicalScope, name, parent, { ...options, binder });
124
146
  }
125
147
 
126
148
  export function createMemberScope(
@@ -129,7 +151,11 @@ export function createMemberScope(
129
151
  options: OutputScopeOptions = {},
130
152
  ) {
131
153
  const parent = useTSScope();
132
- return new TSMemberScope(name, parent, ownerSymbol, options);
154
+ const binder = options.binder ?? parent?.binder ?? ownerSymbol.binder;
155
+ return createScope(TSMemberScope, name, parent, ownerSymbol, {
156
+ ...options,
157
+ binder,
158
+ });
133
159
  }
134
160
 
135
161
  export function decl(namekey: Namekey, options?: CreateTsSymbolOptions) {
@@ -1,4 +1,9 @@
1
- import { reactive, Refkey, shallowReactive } from "@alloy-js/core";
1
+ import {
2
+ createSymbol,
3
+ reactive,
4
+ Refkey,
5
+ shallowReactive,
6
+ } from "@alloy-js/core";
2
7
  import { TSLexicalScope } from "./ts-lexical-scope.js";
3
8
  import { TSOutputSymbol, TSSymbolFlags } from "./ts-output-symbol.js";
4
9
 
@@ -52,18 +57,31 @@ export class TSModuleScope extends TSLexicalScope {
52
57
  this.importedModules.set(targetModule, new Set());
53
58
  }
54
59
 
60
+ const binder = this.binder;
55
61
  let localSymbol;
56
62
 
57
63
  if (options?.type) {
58
- localSymbol = new TSOutputSymbol(targetSymbol.name, this.types, {
59
- aliasTarget: targetSymbol,
60
- tsFlags: TSSymbolFlags.LocalImportSymbol,
61
- });
64
+ localSymbol = createSymbol(
65
+ TSOutputSymbol,
66
+ targetSymbol.name,
67
+ this.types,
68
+ {
69
+ binder,
70
+ aliasTarget: targetSymbol,
71
+ tsFlags: TSSymbolFlags.LocalImportSymbol,
72
+ },
73
+ );
62
74
  } else {
63
- localSymbol = new TSOutputSymbol(targetSymbol.name, this.values, {
64
- aliasTarget: targetSymbol,
65
- tsFlags: TSSymbolFlags.LocalImportSymbol,
66
- });
75
+ localSymbol = createSymbol(
76
+ TSOutputSymbol,
77
+ targetSymbol.name,
78
+ this.values,
79
+ {
80
+ binder,
81
+ aliasTarget: targetSymbol,
82
+ tsFlags: TSSymbolFlags.LocalImportSymbol,
83
+ },
84
+ );
67
85
  }
68
86
 
69
87
  this.importedSymbols.set(targetSymbol, localSymbol);
@@ -85,4 +103,13 @@ export class TSModuleScope extends TSLexicalScope {
85
103
  }
86
104
  return allSymbols;
87
105
  }
106
+
107
+ override get debugInfo(): Record<string, unknown> {
108
+ return {
109
+ ...super.debugInfo,
110
+ exportedSymbolCount: this.#exportedSymbols.size,
111
+ importedSymbolCount: this.#importedSymbols.size,
112
+ importedModuleCount: this.#importedModules.size,
113
+ };
114
+ }
88
115
  }
@@ -1,4 +1,5 @@
1
1
  import {
2
+ createSymbol,
2
3
  Namekey,
3
4
  OutputSpace,
4
5
  OutputSymbol,
@@ -68,8 +69,9 @@ export class TSOutputSymbol extends OutputSymbol {
68
69
  }
69
70
 
70
71
  copy() {
71
- const copy = new TSOutputSymbol(this.name, undefined, {
72
- binder: this.binder,
72
+ const binder = this.binder;
73
+ const copy = createSymbol(TSOutputSymbol, this.name, undefined, {
74
+ binder,
73
75
  aliasTarget: this.aliasTarget,
74
76
  default: this.default,
75
77
  export: this.export,
@@ -199,4 +201,21 @@ export class TSOutputSymbol extends OutputSymbol {
199
201
  get isValueSymbol() {
200
202
  return this.spaces.some((s) => s.key === "values");
201
203
  }
204
+
205
+ override get debugInfo(): Record<string, unknown> {
206
+ const info = super.debugInfo;
207
+ return {
208
+ ...info,
209
+ export: this.export,
210
+ default: this.default,
211
+ tsFlags: this.tsFlags,
212
+ hasInstanceMembers: this.hasInstanceMembers,
213
+ isTypeSymbol: this.isTypeSymbol,
214
+ isValueSymbol: this.isValueSymbol,
215
+ isPrivateMemberSymbol: this.isPrivateMemberSymbol,
216
+ isInstanceMemberSymbol: this.isInstanceMemberSymbol,
217
+ isStaticMemberSymbol: this.isStaticMemberSymbol,
218
+ isPublicMemberSymbol: this.isPublicMemberSymbol,
219
+ };
220
+ }
202
221
  }
@@ -99,4 +99,13 @@ export class TSPackageScope extends OutputScope {
99
99
  copyTo(): TSPackageScope {
100
100
  throw new Error("Not supported");
101
101
  }
102
+
103
+ override get debugInfo(): Record<string, unknown> {
104
+ return {
105
+ ...super.debugInfo,
106
+ version: this.version,
107
+ path: this.path,
108
+ builtin: this.builtin,
109
+ };
110
+ }
102
111
  }