@alloy-js/typescript 0.19.0 → 0.20.0-dev.1
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/dist/src/builtins/node.d.ts +1 -1
- package/dist/src/components/ArrowFunction.d.ts.map +1 -1
- package/dist/src/components/ArrowFunction.js +7 -13
- package/dist/src/components/BlockScope.d.ts.map +1 -1
- package/dist/src/components/BlockScope.js +3 -2
- package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
- package/dist/src/components/ClassDeclaration.js +20 -30
- package/dist/src/components/Declaration.d.ts +2 -9
- package/dist/src/components/Declaration.d.ts.map +1 -1
- package/dist/src/components/Declaration.js +20 -43
- package/dist/src/components/EnumDeclaration.d.ts.map +1 -1
- package/dist/src/components/EnumDeclaration.js +5 -9
- package/dist/src/components/EnumMember.d.ts.map +1 -1
- package/dist/src/components/EnumMember.js +3 -4
- package/dist/src/components/ExportStatement.d.ts.map +1 -1
- package/dist/src/components/ExportStatement.js +2 -1
- package/dist/src/components/FunctionBase.d.ts.map +1 -1
- package/dist/src/components/FunctionBase.js +15 -12
- package/dist/src/components/FunctionDeclaration.d.ts.map +1 -1
- package/dist/src/components/FunctionDeclaration.js +3 -3
- package/dist/src/components/FunctionExpression.d.ts.map +1 -1
- package/dist/src/components/FunctionExpression.js +7 -13
- package/dist/src/components/FunctionType.d.ts.map +1 -1
- package/dist/src/components/FunctionType.js +3 -3
- package/dist/src/components/IfStatement.d.ts.map +1 -1
- package/dist/src/components/IfStatement.js +2 -1
- package/dist/src/components/ImportStatement.d.ts.map +1 -1
- package/dist/src/components/ImportStatement.js +3 -4
- package/dist/src/components/Interface.d.ts.map +1 -1
- package/dist/src/components/Interface.js +14 -13
- package/dist/src/components/InterfaceMethod.d.ts.map +1 -1
- package/dist/src/components/InterfaceMethod.js +4 -3
- package/dist/src/components/LexicalScope.d.ts +12 -0
- package/dist/src/components/LexicalScope.d.ts.map +1 -0
- package/dist/src/components/LexicalScope.js +24 -0
- package/dist/src/components/MemberDeclaration.d.ts +1 -10
- package/dist/src/components/MemberDeclaration.d.ts.map +1 -1
- package/dist/src/components/MemberDeclaration.js +3 -7
- package/dist/src/components/MemberExpression.d.ts.map +1 -1
- package/dist/src/components/MemberExpression.js +13 -5
- package/dist/src/components/MemberScope.d.ts +15 -0
- package/dist/src/components/MemberScope.d.ts.map +1 -0
- package/dist/src/components/MemberScope.js +17 -0
- package/dist/src/components/NewExpression.d.ts.map +1 -1
- package/dist/src/components/NewExpression.js +5 -5
- package/dist/src/components/ObjectExpression.d.ts.map +1 -1
- package/dist/src/components/ObjectExpression.js +10 -14
- package/dist/src/components/PropertyName.js +1 -2
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +3 -2
- package/dist/src/components/VarDeclaration.d.ts.map +1 -1
- package/dist/src/components/VarDeclaration.js +14 -26
- package/dist/src/context/index.d.ts +1 -1
- package/dist/src/context/index.d.ts.map +1 -1
- package/dist/src/context/index.js +1 -1
- package/dist/src/create-package.d.ts.map +1 -1
- package/dist/src/create-package.js +11 -33
- package/dist/src/symbols/index.d.ts +19 -0
- package/dist/src/symbols/index.d.ts.map +1 -1
- package/dist/src/symbols/index.js +72 -1
- package/dist/src/symbols/reference.d.ts +2 -2
- package/dist/src/symbols/reference.d.ts.map +1 -1
- package/dist/src/symbols/reference.js +68 -70
- package/dist/src/symbols/scopes.d.ts +5 -8
- package/dist/src/symbols/scopes.d.ts.map +1 -1
- package/dist/src/symbols/scopes.js +26 -0
- package/dist/src/symbols/ts-lexical-scope.d.ts +12 -0
- package/dist/src/symbols/ts-lexical-scope.d.ts.map +1 -0
- package/dist/src/symbols/ts-lexical-scope.js +16 -0
- package/dist/src/symbols/ts-member-scope.d.ts +12 -4
- package/dist/src/symbols/ts-member-scope.d.ts.map +1 -1
- package/dist/src/symbols/ts-member-scope.js +15 -6
- package/dist/src/symbols/ts-module-scope.d.ts +8 -3
- package/dist/src/symbols/ts-module-scope.d.ts.map +1 -1
- package/dist/src/symbols/ts-module-scope.js +29 -18
- package/dist/src/symbols/ts-output-symbol.d.ts +19 -18
- package/dist/src/symbols/ts-output-symbol.d.ts.map +1 -1
- package/dist/src/symbols/ts-output-symbol.js +60 -37
- package/dist/src/symbols/ts-package-scope.d.ts +1 -1
- package/dist/src/symbols/ts-package-scope.d.ts.map +1 -1
- package/dist/src/symbols/ts-package-scope.js +4 -5
- package/dist/src/utils.d.ts +4 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +23 -1
- package/dist/test/class.test.js +4 -4
- package/dist/test/externals.test.js +2 -38
- package/dist/test/reference.test.js +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/components/ArrowFunction.tsx +7 -10
- package/src/components/BlockScope.tsx +3 -3
- package/src/components/ClassDeclaration.tsx +19 -44
- package/src/components/Declaration.tsx +22 -53
- package/src/components/EnumDeclaration.tsx +4 -11
- package/src/components/EnumMember.tsx +3 -3
- package/src/components/ExportStatement.tsx +2 -1
- package/src/components/FunctionBase.tsx +33 -28
- package/src/components/FunctionDeclaration.tsx +3 -3
- package/src/components/FunctionExpression.tsx +7 -10
- package/src/components/FunctionType.tsx +3 -3
- package/src/components/IfStatement.tsx +2 -1
- package/src/components/ImportStatement.tsx +4 -8
- package/src/components/Interface.tsx +15 -22
- package/src/components/InterfaceMethod.tsx +4 -4
- package/src/components/LexicalScope.tsx +27 -0
- package/src/components/MemberDeclaration.tsx +8 -20
- package/src/components/MemberExpression.tsx +25 -5
- package/src/components/MemberScope.tsx +29 -0
- package/src/components/NewExpression.tsx +4 -5
- package/src/components/ObjectExpression.tsx +11 -18
- package/src/components/PropertyName.tsx +2 -2
- package/src/components/SourceFile.tsx +3 -1
- package/src/components/VarDeclaration.tsx +14 -28
- package/src/context/index.ts +1 -1
- package/src/create-package.ts +10 -39
- package/src/symbols/index.ts +118 -0
- package/src/symbols/reference.tsx +163 -0
- package/src/symbols/scopes.ts +38 -13
- package/src/symbols/ts-lexical-scope.ts +18 -0
- package/src/symbols/ts-member-scope.ts +23 -6
- package/src/symbols/ts-module-scope.ts +31 -21
- package/src/symbols/ts-output-symbol.ts +111 -49
- package/src/symbols/ts-package-scope.ts +5 -5
- package/src/utils.ts +38 -1
- package/temp/api.json +1641 -713
- package/test/class.test.tsx +10 -4
- package/test/externals.test.tsx +1 -40
- package/test/reference.test.tsx +5 -5
- package/tsdoc-metadata.json +1 -1
- package/dist/src/context/private-scope.d.ts +0 -18
- package/dist/src/context/private-scope.d.ts.map +0 -1
- package/dist/src/context/private-scope.js +0 -8
- package/src/context/private-scope.ts +0 -23
- 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.
|
|
3
|
+
"version": "0.20.0-dev.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -14,18 +14,18 @@
|
|
|
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.6",
|
|
17
18
|
"change-case": "^5.4.4",
|
|
18
|
-
"pathe": "^2.0.3"
|
|
19
|
-
"@alloy-js/core": "~0.19.0"
|
|
19
|
+
"pathe": "^2.0.3"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
+
"@alloy-js/cli": "~0.19.0 || >= 0.20.0-dev.0",
|
|
23
|
+
"@alloy-js/rollup-plugin": "~0.1.0 || >= 0.1.1-dev.0",
|
|
22
24
|
"@microsoft/api-extractor": "~7.52.8",
|
|
23
25
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
24
|
-
"concurrently": "^9.
|
|
26
|
+
"concurrently": "^9.2.0",
|
|
25
27
|
"typescript": "^5.8.3",
|
|
26
|
-
"vitest": "^3.2.4"
|
|
27
|
-
"@alloy-js/cli": "~0.19.0",
|
|
28
|
-
"@alloy-js/rollup-plugin": "~0.1.0"
|
|
28
|
+
"vitest": "^3.2.4"
|
|
29
29
|
},
|
|
30
30
|
"type": "module",
|
|
31
31
|
"scripts": {
|
|
@@ -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
|
-
|
|
74
|
-
|
|
75
|
-
<
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
<
|
|
27
|
+
<LexicalScope {...props}>
|
|
28
28
|
<Block {...props}>{props.children}</Block>
|
|
29
|
-
</
|
|
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 {
|
|
18
|
-
|
|
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
|
|
67
|
+
const name = namePolicy.getName(props.name!, "class");
|
|
67
68
|
|
|
68
|
-
const
|
|
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
|
-
|
|
88
|
-
|
|
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
|
|
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 =
|
|
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
|
-
<
|
|
186
|
+
<LexicalScope name={props.name}>
|
|
212
187
|
<CallSignature {...callProps} /> <Block>{props.children}</Block>
|
|
213
|
-
</
|
|
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 {
|
|
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.
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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 {
|
|
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
|
|
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
|
|
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,
|
|
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 =
|
|
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
|
-
|
|
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 {
|
|
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(
|
|
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(
|
|
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(
|
|
128
|
-
|
|
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
|
-
<
|
|
147
|
+
<param.TypeSlot>
|
|
141
148
|
<TypeRefContext>{param.type}</TypeRefContext>
|
|
142
|
-
</
|
|
149
|
+
</param.TypeSlot>
|
|
143
150
|
</indent>
|
|
144
151
|
</Show>
|
|
145
|
-
<Show when={!!param.default}>
|
|
152
|
+
<Show when={!!(param as any).default}>
|
|
146
153
|
{" = "}
|
|
147
|
-
<
|
|
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
|
-
|
|
199
|
-
|
|
200
|
-
);
|
|
206
|
+
const name = namePolicy.getName(paramName, "parameter");
|
|
207
|
+
const TypeSlot = createSymbolSlot();
|
|
208
|
+
const symbol = createValueSymbol(name, { type: TypeSlot.firstSymbol });
|
|
201
209
|
|
|
202
|
-
|
|
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 =
|
|
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) =>
|
|
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
|
-
<
|
|
80
|
+
<LexicalScope name={props.name}>
|
|
81
81
|
<CallSignature {...callSignatureProps} returnType={returnType} />{" "}
|
|
82
82
|
{sBody}
|
|
83
|
-
</
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
<
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
<
|
|
60
|
+
<LexicalScope>
|
|
61
61
|
<CallSignature {...callSignatureProps} returnType={null} />
|
|
62
62
|
{" => "}
|
|
63
63
|
{returnType}
|
|
64
|
-
</
|
|
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}) <
|
|
15
|
+
if ({props.condition}) <BlockScope>{props.children}</BlockScope>
|
|
15
16
|
</>
|
|
16
17
|
);
|
|
17
18
|
}
|