@alloy-js/typescript 0.15.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/dist/src/builtins/node.d.ts +9 -41
- package/dist/src/builtins/node.d.ts.map +1 -1
- package/dist/src/components/ArrowFunction.d.ts +3 -3
- package/dist/src/components/BarrelFile.d.ts +1 -1
- package/dist/src/components/BarrelFile.d.ts.map +1 -1
- package/dist/src/components/BlockScope.d.ts +1 -1
- package/dist/src/components/BlockScope.d.ts.map +1 -1
- package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
- package/dist/src/components/ClassDeclaration.js +5 -7
- package/dist/src/components/Declaration.d.ts.map +1 -1
- package/dist/src/components/Declaration.js +3 -4
- package/dist/src/components/EnumDeclaration.d.ts +1 -1
- package/dist/src/components/EnumDeclaration.d.ts.map +1 -1
- package/dist/src/components/EnumDeclaration.js +3 -4
- package/dist/src/components/EnumMember.d.ts.map +1 -1
- package/dist/src/components/EnumMember.js +3 -4
- package/dist/src/components/FunctionBase.d.ts +4 -4
- package/dist/src/components/FunctionBase.d.ts.map +1 -1
- package/dist/src/components/FunctionBase.js +15 -10
- package/dist/src/components/FunctionDeclaration.d.ts +3 -3
- package/dist/src/components/FunctionExpression.d.ts +3 -3
- package/dist/src/components/FunctionType.d.ts +2 -2
- package/dist/src/components/ImportStatement.d.ts +1 -1
- package/dist/src/components/ImportStatement.d.ts.map +1 -1
- package/dist/src/components/Interface.js +1 -1
- package/dist/src/components/InterfaceMethod.d.ts +2 -2
- package/dist/src/components/MemberDeclaration.d.ts +1 -1
- package/dist/src/components/MemberDeclaration.d.ts.map +1 -1
- package/dist/src/components/MemberDeclaration.js +4 -4
- package/dist/src/components/MemberExpression.d.ts +27 -5
- package/dist/src/components/MemberExpression.d.ts.map +1 -1
- package/dist/src/components/MemberExpression.js +327 -89
- package/dist/src/components/NewExpression.d.ts +5 -0
- package/dist/src/components/NewExpression.d.ts.map +1 -0
- package/dist/src/components/NewExpression.js +12 -0
- package/dist/src/components/ObjectExpression.d.ts.map +1 -1
- package/dist/src/components/ObjectExpression.js +14 -15
- package/dist/src/components/PackageDirectory.d.ts.map +1 -1
- package/dist/src/components/PackageDirectory.js +3 -3
- package/dist/src/components/PackageJson.d.ts +1 -1
- package/dist/src/components/PackageJson.d.ts.map +1 -1
- package/dist/src/components/PropertyName.d.ts +1 -1
- package/dist/src/components/PropertyName.d.ts.map +1 -1
- package/dist/src/components/Reference.d.ts +1 -1
- package/dist/src/components/Reference.d.ts.map +1 -1
- package/dist/src/components/Reference.js +5 -1
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +3 -3
- package/dist/src/components/TsConfigJson.d.ts +1 -1
- package/dist/src/components/TsConfigJson.d.ts.map +1 -1
- package/dist/src/components/TypeDeclaration.d.ts +1 -1
- package/dist/src/components/TypeDeclaration.d.ts.map +1 -1
- package/dist/src/components/VarDeclaration.d.ts.map +1 -1
- package/dist/src/components/VarDeclaration.js +30 -10
- package/dist/src/components/index.d.ts +1 -1
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +1 -1
- package/dist/src/components/stc/index.d.ts +45 -44
- package/dist/src/components/stc/index.d.ts.map +1 -1
- package/dist/src/components/stc/index.js +46 -45
- package/dist/src/create-package.d.ts +62 -18
- package/dist/src/create-package.d.ts.map +1 -1
- package/dist/src/create-package.js +153 -15
- package/dist/src/source-directory-data.d.ts.map +1 -1
- package/dist/src/source-directory-data.js +2 -2
- package/dist/src/symbols/reference.d.ts +2 -1
- package/dist/src/symbols/reference.d.ts.map +1 -1
- package/dist/src/symbols/reference.js +3 -4
- package/dist/src/symbols/scopes.d.ts +1 -4
- package/dist/src/symbols/scopes.d.ts.map +1 -1
- package/dist/src/symbols/ts-member-scope.d.ts +4 -6
- package/dist/src/symbols/ts-member-scope.d.ts.map +1 -1
- package/dist/src/symbols/ts-member-scope.js +8 -10
- package/dist/src/symbols/ts-module-scope.d.ts +8 -11
- package/dist/src/symbols/ts-module-scope.d.ts.map +1 -1
- package/dist/src/symbols/ts-module-scope.js +47 -40
- package/dist/src/symbols/ts-output-symbol.d.ts +23 -16
- package/dist/src/symbols/ts-output-symbol.d.ts.map +1 -1
- package/dist/src/symbols/ts-output-symbol.js +88 -27
- package/dist/src/symbols/ts-package-scope.d.ts +18 -14
- package/dist/src/symbols/ts-package-scope.d.ts.map +1 -1
- package/dist/src/symbols/ts-package-scope.js +78 -27
- package/dist/test/class.test.js +2 -1
- package/dist/test/externals.test.js +87 -2
- package/dist/test/function-declaration.test.js +74 -3
- package/dist/test/member-expression.test.js +391 -5
- package/dist/test/new-expression.test.d.ts +2 -0
- package/dist/test/new-expression.test.d.ts.map +1 -0
- package/dist/test/new-expression.test.js +62 -0
- package/dist/test/var-declaration.test.d.ts.map +1 -1
- package/dist/test/var-declaration.test.js +145 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/components/ClassDeclaration.tsx +5 -7
- package/src/components/Declaration.tsx +3 -8
- package/src/components/EnumDeclaration.tsx +3 -4
- package/src/components/EnumMember.tsx +3 -4
- package/src/components/FunctionBase.tsx +25 -18
- package/src/components/ImportStatement.tsx +0 -1
- package/src/components/Interface.tsx +1 -1
- package/src/components/MemberDeclaration.tsx +5 -8
- package/src/components/MemberExpression.tsx +416 -103
- package/src/components/NewExpression.tsx +25 -0
- package/src/components/ObjectExpression.tsx +18 -16
- package/src/components/PackageDirectory.tsx +2 -10
- package/src/components/Reference.tsx +4 -2
- package/src/components/SourceFile.tsx +2 -5
- package/src/components/VarDeclaration.tsx +34 -11
- package/src/components/index.ts +1 -1
- package/src/components/stc/index.ts +46 -45
- package/src/create-package.ts +274 -35
- package/src/source-directory-data.ts +2 -2
- package/src/symbols/reference.ts +10 -5
- package/src/symbols/scopes.ts +1 -6
- package/src/symbols/ts-member-scope.ts +8 -23
- package/src/symbols/ts-module-scope.ts +58 -62
- package/src/symbols/ts-output-symbol.ts +108 -50
- package/src/symbols/ts-package-scope.ts +71 -53
- package/temp/api.json +1665 -1733
- package/test/class.test.tsx +2 -1
- package/test/externals.test.tsx +99 -1
- package/test/function-declaration.test.tsx +75 -2
- package/test/member-expression.test.tsx +312 -8
- package/test/new-expression.test.tsx +42 -0
- package/test/values.test.tsx +1 -0
- package/test/var-declaration.test.tsx +101 -1
- package/tsdoc-metadata.json +1 -1
- package/dist/src/components/MemberChainExpression.d.ts +0 -11
- package/dist/src/components/MemberChainExpression.d.ts.map +0 -1
- package/dist/src/components/MemberChainExpression.js +0 -98
- package/dist/test/member-chain.test.d.ts +0 -2
- package/dist/test/member-chain.test.d.ts.map +0 -1
- package/dist/test/member-chain.test.js +0 -141
- package/src/components/MemberChainExpression.tsx +0 -91
- package/test/member-chain.test.tsx +0 -124
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
import { usePrivateScope } from "../context/private-scope.js";
|
|
16
16
|
import { useTSNamePolicy } from "../name-policy.js";
|
|
17
17
|
import { TSOutputScope } from "../symbols/scopes.js";
|
|
18
|
-
import {
|
|
18
|
+
import { TSOutputSymbol, TSSymbolFlags } from "../symbols/ts-output-symbol.js";
|
|
19
19
|
import { getCallSignatureProps } from "../utils.js";
|
|
20
20
|
import { CallSignature, CallSignatureProps } from "./CallSignature.jsx";
|
|
21
21
|
import { BaseDeclarationProps, Declaration } from "./Declaration.jsx";
|
|
@@ -65,9 +65,8 @@ export function ClassDeclaration(props: ClassDeclarationProps) {
|
|
|
65
65
|
const namePolicy = useTSNamePolicy();
|
|
66
66
|
const extendsPart = props.extends && <> extends {props.extends}</>;
|
|
67
67
|
|
|
68
|
-
const sym =
|
|
69
|
-
|
|
70
|
-
refkey: props.refkey,
|
|
68
|
+
const sym = new TSOutputSymbol(namePolicy.getName(props.name!, "class"), {
|
|
69
|
+
refkeys: props.refkey,
|
|
71
70
|
export: props.export,
|
|
72
71
|
default: props.default,
|
|
73
72
|
flags:
|
|
@@ -137,10 +136,9 @@ export function ClassMember(props: ClassMemberProps) {
|
|
|
137
136
|
tsFlags |= TSSymbolFlags.Nullish;
|
|
138
137
|
}
|
|
139
138
|
|
|
140
|
-
const sym =
|
|
141
|
-
name,
|
|
139
|
+
const sym = new TSOutputSymbol(name, {
|
|
142
140
|
scope,
|
|
143
|
-
|
|
141
|
+
refkeys: props.refkey,
|
|
144
142
|
flags,
|
|
145
143
|
tsFlags,
|
|
146
144
|
});
|
|
@@ -6,11 +6,7 @@ import {
|
|
|
6
6
|
Refkey,
|
|
7
7
|
} from "@alloy-js/core";
|
|
8
8
|
import { TypeScriptElements, useTSNamePolicy } from "../name-policy.js";
|
|
9
|
-
import {
|
|
10
|
-
createTSSymbol,
|
|
11
|
-
TSOutputSymbol,
|
|
12
|
-
TSSymbolFlags,
|
|
13
|
-
} from "../symbols/index.js";
|
|
9
|
+
import { TSOutputSymbol, TSSymbolFlags } from "../symbols/index.js";
|
|
14
10
|
|
|
15
11
|
// imports for documentation
|
|
16
12
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -112,9 +108,8 @@ export function Declaration(props: DeclarationProps) {
|
|
|
112
108
|
tsFlags |= TSSymbolFlags.TypeSymbol;
|
|
113
109
|
}
|
|
114
110
|
|
|
115
|
-
sym =
|
|
116
|
-
|
|
117
|
-
refkey: props.refkey,
|
|
111
|
+
sym = new TSOutputSymbol(namePolicy.getName(props.name!, props.nameKind!), {
|
|
112
|
+
refkeys: props.refkey,
|
|
118
113
|
export: props.export,
|
|
119
114
|
default: props.default,
|
|
120
115
|
flags: props.flags,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
useBinder,
|
|
11
11
|
} from "@alloy-js/core";
|
|
12
12
|
import { useTSNamePolicy } from "../name-policy.js";
|
|
13
|
-
import {
|
|
13
|
+
import { TSOutputSymbol, useTSScope } from "../symbols/index.js";
|
|
14
14
|
import { BaseDeclarationProps } from "./Declaration.js";
|
|
15
15
|
import { EnumMember } from "./EnumMember.jsx";
|
|
16
16
|
import { JSDoc } from "./JSDoc.jsx";
|
|
@@ -28,11 +28,10 @@ export function EnumDeclaration(props: EnumDeclarationProps) {
|
|
|
28
28
|
const name = useTSNamePolicy().getName(props.name, "enum");
|
|
29
29
|
const binder = useBinder();
|
|
30
30
|
const scope = useTSScope();
|
|
31
|
-
const sym =
|
|
31
|
+
const sym = new TSOutputSymbol(name, {
|
|
32
32
|
binder,
|
|
33
33
|
scope,
|
|
34
|
-
|
|
35
|
-
refkey: props.refkey,
|
|
34
|
+
refkeys: props.refkey,
|
|
36
35
|
default: props.default,
|
|
37
36
|
export: props.export,
|
|
38
37
|
flags: OutputSymbolFlags.StaticMemberContainer,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Children, OutputSymbolFlags, Refkey, Show } from "@alloy-js/core";
|
|
2
2
|
import { useTSNamePolicy } from "../name-policy.js";
|
|
3
|
-
import {
|
|
3
|
+
import { TSOutputSymbol } from "../symbols/ts-output-symbol.js";
|
|
4
4
|
import { JSDoc } from "./JSDoc.jsx";
|
|
5
5
|
import { PropertyName } from "./PropertyName.jsx";
|
|
6
6
|
import { ValueExpression } from "./ValueExpression.jsx";
|
|
@@ -49,9 +49,8 @@ export function EnumMember(props: EnumMemberProps) {
|
|
|
49
49
|
const name = namer.getName(props.name, "enum-member");
|
|
50
50
|
let sym: TSOutputSymbol | undefined = undefined;
|
|
51
51
|
if (props.refkey) {
|
|
52
|
-
sym =
|
|
53
|
-
|
|
54
|
-
refkey: props.refkey,
|
|
52
|
+
sym = new TSOutputSymbol(name, {
|
|
53
|
+
refkeys: props.refkey,
|
|
55
54
|
flags: OutputSymbolFlags.StaticMember,
|
|
56
55
|
metadata: props.metadata,
|
|
57
56
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Block,
|
|
3
3
|
code,
|
|
4
|
+
createSymbolSlot,
|
|
4
5
|
For,
|
|
5
6
|
Indent,
|
|
6
7
|
onCleanup,
|
|
@@ -14,11 +15,7 @@ import type {
|
|
|
14
15
|
ParameterDescriptor,
|
|
15
16
|
} from "../parameter-descriptor.js";
|
|
16
17
|
import { TypeParameterDescriptor } from "../parameter-descriptor.js";
|
|
17
|
-
import {
|
|
18
|
-
createTSSymbol,
|
|
19
|
-
TSOutputSymbol,
|
|
20
|
-
TSSymbolFlags,
|
|
21
|
-
} from "../symbols/index.js";
|
|
18
|
+
import { TSOutputSymbol, TSSymbolFlags } from "../symbols/index.js";
|
|
22
19
|
import { TypeRefContext } from "./TypeRefContext.jsx";
|
|
23
20
|
|
|
24
21
|
const functionParametersTag = Symbol();
|
|
@@ -120,6 +117,10 @@ export const FunctionTypeParameters = taggedComponent(
|
|
|
120
117
|
);
|
|
121
118
|
|
|
122
119
|
function parameter(param: DeclaredParameterDescriptor) {
|
|
120
|
+
const SymbolSlot = createSymbolSlot();
|
|
121
|
+
|
|
122
|
+
SymbolSlot.instantiateInto(param.symbol);
|
|
123
|
+
|
|
123
124
|
return (
|
|
124
125
|
<group>
|
|
125
126
|
<Show when={param.rest}>...</Show>
|
|
@@ -127,7 +128,10 @@ function parameter(param: DeclaredParameterDescriptor) {
|
|
|
127
128
|
<Show when={!!param.optional}>?</Show>
|
|
128
129
|
<Show when={!!param.type}>
|
|
129
130
|
<indent>
|
|
130
|
-
:
|
|
131
|
+
:{" "}
|
|
132
|
+
<SymbolSlot>
|
|
133
|
+
<TypeRefContext>{param.type}</TypeRefContext>
|
|
134
|
+
</SymbolSlot>
|
|
131
135
|
</indent>
|
|
132
136
|
</Show>
|
|
133
137
|
</group>
|
|
@@ -178,11 +182,12 @@ function normalizeAndDeclareParameters(
|
|
|
178
182
|
}
|
|
179
183
|
if (typeof parameters[0] === "string") {
|
|
180
184
|
return (parameters as string[]).map((paramName) => {
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
185
|
+
const name = namePolicy.getName(
|
|
186
|
+
paramName,
|
|
187
|
+
flags & TSSymbolFlags.TypeSymbol ? "type" : "parameter",
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
const symbol = new TSOutputSymbol(name, {
|
|
186
191
|
tsFlags: flags,
|
|
187
192
|
});
|
|
188
193
|
|
|
@@ -195,15 +200,17 @@ function normalizeAndDeclareParameters(
|
|
|
195
200
|
TSSymbolFlags.Nullish
|
|
196
201
|
: TSSymbolFlags.None;
|
|
197
202
|
|
|
198
|
-
const symbol =
|
|
199
|
-
|
|
203
|
+
const symbol = new TSOutputSymbol(
|
|
204
|
+
namePolicy.getName(
|
|
200
205
|
param.name,
|
|
201
206
|
flags & TSSymbolFlags.TypeSymbol ? "type" : "parameter",
|
|
202
207
|
),
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
208
|
+
{
|
|
209
|
+
refkeys: param.refkey,
|
|
210
|
+
tsFlags: flags | nullishFlag,
|
|
211
|
+
metadata: param.metadata,
|
|
212
|
+
},
|
|
213
|
+
);
|
|
207
214
|
|
|
208
215
|
return {
|
|
209
216
|
...param,
|
|
@@ -236,7 +243,7 @@ export const TypeParameters = taggedComponent(
|
|
|
236
243
|
|
|
237
244
|
onCleanup(() => {
|
|
238
245
|
for (const param of typeParameters) {
|
|
239
|
-
param.symbol.
|
|
246
|
+
param.symbol.delete();
|
|
240
247
|
}
|
|
241
248
|
});
|
|
242
249
|
|
|
@@ -61,7 +61,7 @@ export const InterfaceExpression = ensureTypeRefContext(
|
|
|
61
61
|
const parentMemberSym = useMemberDeclaration();
|
|
62
62
|
|
|
63
63
|
if (parentMemberSym) {
|
|
64
|
-
parentMemberSym.
|
|
64
|
+
parentMemberSym.flags |= OutputSymbolFlags.StaticMemberContainer;
|
|
65
65
|
}
|
|
66
66
|
return (
|
|
67
67
|
<group>
|
|
@@ -4,11 +4,7 @@ import {
|
|
|
4
4
|
OutputSymbolFlags,
|
|
5
5
|
} from "@alloy-js/core";
|
|
6
6
|
import { TypeScriptElements, useTSNamePolicy } from "../name-policy.js";
|
|
7
|
-
import {
|
|
8
|
-
createTSSymbol,
|
|
9
|
-
TSOutputSymbol,
|
|
10
|
-
TSSymbolFlags,
|
|
11
|
-
} from "../symbols/index.js";
|
|
7
|
+
import { TSOutputSymbol, TSSymbolFlags } from "../symbols/index.js";
|
|
12
8
|
|
|
13
9
|
export interface MemberDeclarationProps
|
|
14
10
|
extends Omit<MemberDeclarationPropsWithInfo, "name"> {
|
|
@@ -61,9 +57,10 @@ export function MemberDeclaration(props: Readonly<MemberDeclarationProps>) {
|
|
|
61
57
|
tsFlags |= TSSymbolFlags.TypeSymbol;
|
|
62
58
|
}
|
|
63
59
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
const name =
|
|
61
|
+
props.exactName ?? namePolicy.getName(props.name!, props.nameKind!);
|
|
62
|
+
sym = new TSOutputSymbol(name, {
|
|
63
|
+
refkeys: props.refkey,
|
|
67
64
|
flags: props.flags,
|
|
68
65
|
tsFlags,
|
|
69
66
|
metadata: props.metadata,
|