@alloy-js/typescript 0.10.0 → 0.12.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 +28 -0
- package/dist/src/builtins/node.js +1 -2
- package/dist/src/components/ArrayExpression.js +2 -5
- package/dist/src/components/ArrowFunction.d.ts +40 -0
- package/dist/src/components/ArrowFunction.d.ts.map +1 -0
- package/dist/src/components/ArrowFunction.js +67 -0
- package/dist/src/components/BarrelFile.js +1 -2
- package/dist/src/components/BlockScope.js +2 -4
- package/dist/src/components/CallSignature.js +2 -4
- package/dist/src/components/ClassDeclaration.d.ts +2 -0
- package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
- package/dist/src/components/ClassDeclaration.js +16 -8
- package/dist/src/components/CommaList.js +2 -5
- package/dist/src/components/Declaration.js +3 -5
- package/dist/src/components/EnumDeclaration.js +2 -5
- package/dist/src/components/EnumMember.js +2 -4
- package/dist/src/components/ExportStatement.js +1 -2
- package/dist/src/components/FunctionBase.d.ts +60 -0
- package/dist/src/components/FunctionBase.d.ts.map +1 -0
- package/dist/src/components/FunctionBase.js +217 -0
- package/dist/src/components/FunctionCallExpression.js +2 -5
- package/dist/src/components/FunctionDeclaration.d.ts +3 -18
- package/dist/src/components/FunctionDeclaration.d.ts.map +1 -1
- package/dist/src/components/FunctionDeclaration.js +9 -157
- package/dist/src/components/FunctionExpression.d.ts +39 -0
- package/dist/src/components/FunctionExpression.d.ts.map +1 -0
- package/dist/src/components/FunctionExpression.js +66 -0
- package/dist/src/components/FunctionType.d.ts +38 -0
- package/dist/src/components/FunctionType.d.ts.map +1 -0
- package/dist/src/components/FunctionType.js +77 -0
- package/dist/src/components/IfStatement.js +2 -4
- package/dist/src/components/ImportStatement.d.ts.map +1 -1
- package/dist/src/components/ImportStatement.js +10 -4
- package/dist/src/components/Interface.d.ts +3 -2
- package/dist/src/components/Interface.d.ts.map +1 -1
- package/dist/src/components/Interface.js +40 -15
- package/dist/src/components/InterfaceMethod.d.ts +43 -0
- package/dist/src/components/InterfaceMethod.d.ts.map +1 -0
- package/dist/src/components/InterfaceMethod.js +87 -0
- package/dist/src/components/JSDoc.js +1 -2
- package/dist/src/components/JSDocComment.js +3 -5
- package/dist/src/components/JSDocExample.js +2 -5
- package/dist/src/components/JSDocParam.js +2 -5
- package/dist/src/components/MemberChainExpression.js +2 -4
- package/dist/src/components/MemberDeclaration.d.ts +34 -0
- package/dist/src/components/MemberDeclaration.d.ts.map +1 -0
- package/dist/src/components/MemberDeclaration.js +29 -0
- package/dist/src/components/MemberExpression.d.ts.map +1 -1
- package/dist/src/components/MemberExpression.js +5 -7
- package/dist/src/components/ObjectExpression.js +2 -5
- package/dist/src/components/PackageDirectory.js +2 -5
- package/dist/src/components/PackageJson.js +1 -2
- package/dist/src/components/PropertyName.js +1 -2
- package/dist/src/components/Reference.d.ts +8 -1
- package/dist/src/components/Reference.d.ts.map +1 -1
- package/dist/src/components/Reference.js +8 -4
- package/dist/src/components/SingleLineCommentBlock.js +2 -4
- package/dist/src/components/SourceFile.js +2 -4
- package/dist/src/components/SwitchStatement.js +2 -5
- package/dist/src/components/TsConfigJson.js +1 -2
- package/dist/src/components/TypeDeclaration.d.ts +1 -1
- package/dist/src/components/TypeDeclaration.d.ts.map +1 -1
- package/dist/src/components/TypeDeclaration.js +4 -7
- package/dist/src/components/TypeRefContext.d.ts +22 -0
- package/dist/src/components/TypeRefContext.d.ts.map +1 -0
- package/dist/src/components/TypeRefContext.js +41 -0
- package/dist/src/components/ValueExpression.js +1 -2
- package/dist/src/components/VarDeclaration.d.ts +1 -0
- package/dist/src/components/VarDeclaration.d.ts.map +1 -1
- package/dist/src/components/VarDeclaration.js +11 -8
- package/dist/src/components/index.d.ts +7 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +7 -1
- package/dist/src/components/stc/index.d.ts +8 -0
- package/dist/src/components/stc/index.d.ts.map +1 -1
- package/dist/src/components/stc/index.js +9 -2
- package/dist/src/context/private-scope.js +1 -2
- package/dist/src/context/type-ref-context.d.ts +15 -0
- package/dist/src/context/type-ref-context.d.ts.map +1 -0
- package/dist/src/context/type-ref-context.js +12 -0
- package/dist/src/create-package.js +1 -2
- package/dist/src/index.js +1 -2
- package/dist/src/name-conflict-resolver.js +1 -2
- package/dist/src/name-policy.js +1 -2
- package/dist/src/parameter-descriptor.d.ts +33 -17
- package/dist/src/parameter-descriptor.d.ts.map +1 -1
- package/dist/src/source-directory-data.js +1 -2
- package/dist/src/symbols/index.js +1 -2
- package/dist/src/symbols/reference.d.ts +4 -1
- package/dist/src/symbols/reference.d.ts.map +1 -1
- package/dist/src/symbols/reference.js +13 -8
- package/dist/src/symbols/scopes.js +1 -2
- package/dist/src/symbols/ts-member-scope.js +1 -2
- package/dist/src/symbols/ts-module-scope.d.ts +4 -1
- package/dist/src/symbols/ts-module-scope.d.ts.map +1 -1
- package/dist/src/symbols/ts-module-scope.js +11 -5
- package/dist/src/symbols/ts-output-symbol.d.ts +2 -1
- package/dist/src/symbols/ts-output-symbol.d.ts.map +1 -1
- package/dist/src/symbols/ts-output-symbol.js +2 -2
- package/dist/src/symbols/ts-package-scope.js +1 -2
- package/dist/src/utils.js +1 -2
- package/dist/test/array.test.js +105 -0
- package/dist/test/arrow-function.test.d.ts +2 -0
- package/dist/test/arrow-function.test.d.ts.map +1 -0
- package/dist/test/arrow-function.test.js +194 -0
- package/dist/test/barrel.test.js +53 -0
- package/dist/test/basic.test.js +91 -0
- package/dist/test/block-scope.test.js +30 -0
- package/dist/test/class.test.js +438 -0
- package/dist/test/enum-jsdoc.test.js +88 -0
- package/dist/test/enum.test.js +247 -0
- package/dist/test/externals.test.js +145 -0
- package/dist/test/function-call-expression.test.js +87 -0
- package/dist/test/function-declaration-jsdoc.test.js +91 -0
- package/dist/test/function-declaration.test.js +228 -0
- package/dist/test/function-expression.test.d.ts +2 -0
- package/dist/test/function-expression.test.d.ts.map +1 -0
- package/dist/test/function-expression.test.js +194 -0
- package/dist/test/function-type.test.d.ts +2 -0
- package/dist/test/function-type.test.d.ts.map +1 -0
- package/dist/test/function-type.test.js +122 -0
- package/dist/test/if-statement.test.js +25 -0
- package/dist/test/imports.test.d.ts.map +1 -1
- package/dist/test/imports.test.js +640 -0
- package/dist/test/interface-jsdoc.test.js +178 -0
- package/dist/test/interface.test.d.ts.map +1 -1
- package/dist/test/interface.test.js +490 -0
- package/dist/test/jscomment.test.js +70 -0
- package/dist/test/jsdoc.test.js +134 -0
- package/dist/test/jsdocparam.test.js +164 -0
- package/dist/test/member-chain.test.js +141 -0
- package/dist/test/member-expression.test.js +575 -0
- package/dist/test/name-conflict.test.js +108 -0
- package/dist/test/name-policy.test.js +122 -0
- package/dist/test/package-external.test.js +196 -0
- package/dist/test/package-json.test.js +93 -0
- package/dist/test/package.test.js +136 -0
- package/dist/test/reference.test.js +81 -0
- package/dist/test/source-file.test.js +36 -0
- package/dist/test/switch-statement.test.js +61 -0
- package/dist/test/utils.js +45 -0
- package/dist/test/value-expression.test.js +30 -0
- package/dist/test/values.test.js +351 -0
- package/dist/test/var-declaration-jsdoc.test.js +50 -0
- package/dist/test/var-declaration.test.js +63 -0
- package/dist/test/vitest.d.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -18
- package/src/components/ArrowFunction.tsx +87 -0
- package/src/components/ClassDeclaration.tsx +19 -3
- package/src/components/Declaration.tsx +1 -1
- package/src/components/FunctionBase.tsx +282 -0
- package/src/components/FunctionDeclaration.tsx +13 -195
- package/src/components/FunctionExpression.tsx +86 -0
- package/src/components/FunctionType.tsx +93 -0
- package/src/components/ImportStatement.tsx +30 -3
- package/src/components/Interface.tsx +58 -23
- package/src/components/InterfaceMethod.tsx +96 -0
- package/src/components/JSDocComment.tsx +1 -1
- package/src/components/MemberDeclaration.tsx +76 -0
- package/src/components/MemberExpression.tsx +7 -2
- package/src/components/Reference.tsx +12 -2
- package/src/components/TypeDeclaration.tsx +16 -13
- package/src/components/TypeRefContext.tsx +49 -0
- package/src/components/VarDeclaration.tsx +6 -2
- package/src/components/index.ts +11 -0
- package/src/components/stc/index.ts +8 -0
- package/src/context/type-ref-context.tsx +19 -0
- package/src/parameter-descriptor.ts +35 -17
- package/src/symbols/reference.ts +21 -6
- package/src/symbols/ts-module-scope.ts +19 -4
- package/src/symbols/ts-output-symbol.ts +1 -0
- package/temp/api.json +4999 -2681
- package/test/arrow-function.test.tsx +188 -0
- package/test/class.test.tsx +5 -6
- package/test/enum-jsdoc.test.tsx +6 -6
- package/test/function-call-expression.test.tsx +1 -2
- package/test/function-declaration-jsdoc.test.tsx +3 -3
- package/test/function-declaration.test.tsx +1 -2
- package/test/function-expression.test.tsx +195 -0
- package/test/function-type.test.tsx +118 -0
- package/test/imports.test.tsx +165 -1
- package/test/interface-jsdoc.test.tsx +9 -9
- package/test/interface.test.tsx +256 -6
- package/test/jsdoc.test.tsx +5 -5
- package/test/jsdocparam.test.tsx +8 -8
- package/test/member-expression.test.tsx +171 -2
- package/test/var-declaration-jsdoc.test.tsx +3 -3
- package/test/var-declaration.test.tsx +1 -1
- package/tsdoc-metadata.json +1 -1
- package/babel.config.cjs +0 -4
- package/dist/src/builtins/index.js.map +0 -1
- package/dist/src/builtins/node.js.map +0 -1
- package/dist/src/components/ArrayExpression.js.map +0 -1
- package/dist/src/components/BarrelFile.js.map +0 -1
- package/dist/src/components/BlockScope.js.map +0 -1
- package/dist/src/components/CallSignature.js.map +0 -1
- package/dist/src/components/ClassDeclaration.js.map +0 -1
- package/dist/src/components/CommaList.js.map +0 -1
- package/dist/src/components/Declaration.js.map +0 -1
- package/dist/src/components/EnumDeclaration.js.map +0 -1
- package/dist/src/components/EnumMember.js.map +0 -1
- package/dist/src/components/ExportStatement.js.map +0 -1
- package/dist/src/components/FunctionCallExpression.js.map +0 -1
- package/dist/src/components/FunctionDeclaration.js.map +0 -1
- package/dist/src/components/IfStatement.js.map +0 -1
- package/dist/src/components/ImportStatement.js.map +0 -1
- package/dist/src/components/Interface.js.map +0 -1
- package/dist/src/components/JSDoc.js.map +0 -1
- package/dist/src/components/JSDocComment.js.map +0 -1
- package/dist/src/components/JSDocExample.js.map +0 -1
- package/dist/src/components/JSDocParam.js.map +0 -1
- package/dist/src/components/MemberChainExpression.js.map +0 -1
- package/dist/src/components/MemberExpression.js.map +0 -1
- package/dist/src/components/ObjectExpression.js.map +0 -1
- package/dist/src/components/PackageDirectory.js.map +0 -1
- package/dist/src/components/PackageJson.js.map +0 -1
- package/dist/src/components/PropertyName.js.map +0 -1
- package/dist/src/components/Reference.js.map +0 -1
- package/dist/src/components/SingleLineCommentBlock.js.map +0 -1
- package/dist/src/components/SourceFile.js.map +0 -1
- package/dist/src/components/SwitchStatement.js.map +0 -1
- package/dist/src/components/TsConfigJson.js.map +0 -1
- package/dist/src/components/TypeDeclaration.js.map +0 -1
- package/dist/src/components/ValueExpression.js.map +0 -1
- package/dist/src/components/VarDeclaration.js.map +0 -1
- package/dist/src/components/index.js.map +0 -1
- package/dist/src/components/stc/index.js.map +0 -1
- package/dist/src/context/index.js.map +0 -1
- package/dist/src/context/private-scope.js.map +0 -1
- package/dist/src/create-package.js.map +0 -1
- package/dist/src/index.js.map +0 -1
- package/dist/src/name-conflict-resolver.js.map +0 -1
- package/dist/src/name-policy.js.map +0 -1
- package/dist/src/parameter-descriptor.js.map +0 -1
- package/dist/src/source-directory-data.js.map +0 -1
- package/dist/src/symbols/index.js.map +0 -1
- package/dist/src/symbols/reference.js.map +0 -1
- package/dist/src/symbols/scopes.js.map +0 -1
- package/dist/src/symbols/ts-member-scope.js.map +0 -1
- package/dist/src/symbols/ts-module-scope.js.map +0 -1
- package/dist/src/symbols/ts-output-symbol.js.map +0 -1
- package/dist/src/symbols/ts-package-scope.js.map +0 -1
- package/dist/src/utils.js.map +0 -1
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { Children } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { ParameterDescriptor } from "../parameter-descriptor.js";
|
|
3
2
|
import { CallSignatureProps } from "./CallSignature.jsx";
|
|
4
3
|
import { BaseDeclarationProps } from "./Declaration.js";
|
|
5
4
|
export interface FunctionDeclarationProps extends BaseDeclarationProps, CallSignatureProps {
|
|
6
5
|
async?: boolean;
|
|
7
6
|
children?: Children;
|
|
8
7
|
}
|
|
9
|
-
export declare const functionParametersTag: unique symbol;
|
|
10
|
-
export declare const functionTypeParametersTag: unique symbol;
|
|
11
|
-
export declare const functionBodyTag: unique symbol;
|
|
12
8
|
/**
|
|
13
9
|
* A TypeScript function declaration.
|
|
14
10
|
*
|
|
@@ -27,19 +23,8 @@ export declare const functionBodyTag: unique symbol;
|
|
|
27
23
|
*/
|
|
28
24
|
export declare function FunctionDeclaration(props: FunctionDeclarationProps): Children;
|
|
29
25
|
export declare namespace FunctionDeclaration {
|
|
30
|
-
var TypeParameters: import("@alloy-js/core").Component<
|
|
31
|
-
var Parameters: import("@alloy-js/core").Component<FunctionParametersProps
|
|
32
|
-
var Body: import("@alloy-js/core").Component<FunctionBodyProps
|
|
33
|
-
}
|
|
34
|
-
export interface FunctionTypeParametersProps {
|
|
35
|
-
parameters?: ParameterDescriptor[] | string[];
|
|
36
|
-
children?: Children;
|
|
37
|
-
}
|
|
38
|
-
export interface FunctionParametersProps {
|
|
39
|
-
parameters?: ParameterDescriptor[] | string[];
|
|
40
|
-
children?: Children;
|
|
41
|
-
}
|
|
42
|
-
export interface FunctionBodyProps {
|
|
43
|
-
children?: Children;
|
|
26
|
+
var TypeParameters: import("@alloy-js/core").Component<import("./FunctionBase.jsx").TypeParametersProps> & Required<Pick<import("@alloy-js/core").Component<import("./FunctionBase.jsx").TypeParametersProps>, "tag">>;
|
|
27
|
+
var Parameters: import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionParametersProps> & Required<Pick<import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionParametersProps>, "tag">>;
|
|
28
|
+
var Body: import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionBodyProps> & Required<Pick<import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionBodyProps>, "tag">>;
|
|
44
29
|
}
|
|
45
30
|
//# sourceMappingURL=FunctionDeclaration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/FunctionDeclaration.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FunctionDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/FunctionDeclaration.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD,OAAO,EAAiB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAe,MAAM,kBAAkB,CAAC;AAUrE,MAAM,WAAW,wBACf,SAAQ,oBAAoB,EAC1B,kBAAkB;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,YAyClE;yBAzCe,mBAAmB"}
|
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
import { mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
4
|
-
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
5
|
-
import { Block, childrenArray, code, findKeyedChild, findUnkeyedChildren, For, Indent, Name, Prose, Scope, Show, taggedComponent } from "@alloy-js/core";
|
|
6
|
-
import { onCleanup } from "@alloy-js/core/jsx-runtime";
|
|
7
|
-
import { useTSNamePolicy } from "../name-policy.js";
|
|
8
|
-
import { createTSSymbol, TSSymbolFlags } from "../symbols/index.js";
|
|
1
|
+
import { createComponent as _$createComponent, memo as _$memo, createIntrinsic as _$createIntrinsic, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { childrenArray, findKeyedChild, findUnkeyedChildren, Name, Prose, Scope, Show } from "@alloy-js/core";
|
|
9
3
|
import { getCallSignatureProps } from "../utils.js";
|
|
10
4
|
import { CallSignature } from "./CallSignature.js";
|
|
11
5
|
import { Declaration } from "./Declaration.js";
|
|
6
|
+
import { FunctionBody, FunctionParameters, getReturnType, TypeParameters } from "./FunctionBase.js";
|
|
12
7
|
import { JSDoc } from "./JSDoc.js";
|
|
13
8
|
import { JSDocParams } from "./JSDocParam.js";
|
|
14
|
-
export const functionParametersTag = Symbol();
|
|
15
|
-
export const functionTypeParametersTag = Symbol();
|
|
16
|
-
export const functionBodyTag = Symbol();
|
|
17
|
-
|
|
18
9
|
/**
|
|
19
10
|
* A TypeScript function declaration.
|
|
20
11
|
*
|
|
@@ -33,9 +24,9 @@ export const functionBodyTag = Symbol();
|
|
|
33
24
|
*/
|
|
34
25
|
export function FunctionDeclaration(props) {
|
|
35
26
|
const children = childrenArray(() => props.children);
|
|
36
|
-
const typeParametersChildren = findKeyedChild(children,
|
|
37
|
-
const parametersChildren = findKeyedChild(children,
|
|
38
|
-
const bodyChildren = findKeyedChild(children,
|
|
27
|
+
const typeParametersChildren = findKeyedChild(children, TypeParameters.tag) ?? undefined;
|
|
28
|
+
const parametersChildren = findKeyedChild(children, FunctionParameters.tag) ?? undefined;
|
|
29
|
+
const bodyChildren = findKeyedChild(children, FunctionBody.tag) ?? undefined;
|
|
39
30
|
const filteredChildren = findUnkeyedChildren(children);
|
|
40
31
|
const returnType = getReturnType(props.returnType, {
|
|
41
32
|
async: props.async
|
|
@@ -84,145 +75,6 @@ export function FunctionDeclaration(props) {
|
|
|
84
75
|
}
|
|
85
76
|
}))];
|
|
86
77
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (returnType) {
|
|
91
|
-
return options.async ? code`Promise<${returnType}>` : returnType;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
function normalizeAndDeclareParameters(parameters, flags = TSSymbolFlags.ParameterSymbol) {
|
|
95
|
-
const namePolicy = useTSNamePolicy();
|
|
96
|
-
if (parameters.length === 0) {
|
|
97
|
-
return [];
|
|
98
|
-
}
|
|
99
|
-
if (typeof parameters[0] === "string") {
|
|
100
|
-
return parameters.map(paramName => {
|
|
101
|
-
const symbol = createTSSymbol({
|
|
102
|
-
name: namePolicy.getName(paramName, flags & TSSymbolFlags.TypeSymbol ? "type" : "parameter"),
|
|
103
|
-
tsFlags: flags
|
|
104
|
-
});
|
|
105
|
-
return {
|
|
106
|
-
refkeys: symbol.refkeys,
|
|
107
|
-
symbol
|
|
108
|
-
};
|
|
109
|
-
});
|
|
110
|
-
} else {
|
|
111
|
-
return parameters.map(param => {
|
|
112
|
-
const symbol = createTSSymbol({
|
|
113
|
-
name: namePolicy.getName(param.name, flags & TSSymbolFlags.TypeSymbol ? "type" : "parameter"),
|
|
114
|
-
refkey: param.refkey,
|
|
115
|
-
tsFlags: flags,
|
|
116
|
-
metadata: param.metadata
|
|
117
|
-
});
|
|
118
|
-
return {
|
|
119
|
-
...param,
|
|
120
|
-
symbol
|
|
121
|
-
};
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
FunctionDeclaration.TypeParameters = taggedComponent(functionTypeParametersTag, function TypeParameters(props) {
|
|
126
|
-
if (props.children) {
|
|
127
|
-
return props.children;
|
|
128
|
-
}
|
|
129
|
-
if (!props.parameters) {
|
|
130
|
-
return undefined;
|
|
131
|
-
}
|
|
132
|
-
const typeParameters = normalizeAndDeclareParameters(props.parameters);
|
|
133
|
-
onCleanup(() => {
|
|
134
|
-
for (const param of typeParameters) {
|
|
135
|
-
param.symbol.binder.deleteSymbol(param.symbol);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
return ["<", _$createIntrinsic("group", {
|
|
139
|
-
get children() {
|
|
140
|
-
return _$createComponent(Indent, {
|
|
141
|
-
softline: true,
|
|
142
|
-
get children() {
|
|
143
|
-
return [_$createComponent(For, {
|
|
144
|
-
each: typeParameters,
|
|
145
|
-
comma: true,
|
|
146
|
-
line: true,
|
|
147
|
-
children: param => typeParameter(param)
|
|
148
|
-
}), _$createIntrinsic("ifBreak", {
|
|
149
|
-
children: ","
|
|
150
|
-
})];
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
}), ">"];
|
|
155
|
-
});
|
|
156
|
-
function typeParameter(param) {
|
|
157
|
-
return _$createIntrinsic("group", {
|
|
158
|
-
get children() {
|
|
159
|
-
return [_$memo(() => param.symbol.name), _$createComponent(Show, {
|
|
160
|
-
get when() {
|
|
161
|
-
return !!param.extends;
|
|
162
|
-
},
|
|
163
|
-
get children() {
|
|
164
|
-
return [" ", "extends", _$createIntrinsic("indent", {
|
|
165
|
-
get children() {
|
|
166
|
-
return [" ", _$memo(() => param.extends)];
|
|
167
|
-
}
|
|
168
|
-
})];
|
|
169
|
-
}
|
|
170
|
-
})];
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
FunctionDeclaration.Parameters = taggedComponent(functionParametersTag, function Parameters(props) {
|
|
175
|
-
if (props.children) {
|
|
176
|
-
return props.children;
|
|
177
|
-
}
|
|
178
|
-
const parameters = normalizeAndDeclareParameters(props.parameters ?? []);
|
|
179
|
-
return _$createIntrinsic("group", {
|
|
180
|
-
get children() {
|
|
181
|
-
return _$createComponent(Indent, {
|
|
182
|
-
softline: true,
|
|
183
|
-
trailingBreak: true,
|
|
184
|
-
get children() {
|
|
185
|
-
return [_$createComponent(For, {
|
|
186
|
-
each: parameters,
|
|
187
|
-
comma: true,
|
|
188
|
-
line: true,
|
|
189
|
-
children: param => parameter(param)
|
|
190
|
-
}), _$createIntrinsic("ifBreak", {
|
|
191
|
-
children: ","
|
|
192
|
-
})];
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
});
|
|
198
|
-
function parameter(param) {
|
|
199
|
-
return _$createIntrinsic("group", {
|
|
200
|
-
get children() {
|
|
201
|
-
return [_$memo(() => param.symbol.name), _$createComponent(Show, {
|
|
202
|
-
get when() {
|
|
203
|
-
return !!param.optional;
|
|
204
|
-
},
|
|
205
|
-
children: "?"
|
|
206
|
-
}), _$createComponent(Show, {
|
|
207
|
-
get when() {
|
|
208
|
-
return !!param.type;
|
|
209
|
-
},
|
|
210
|
-
get children() {
|
|
211
|
-
return _$createIntrinsic("indent", {
|
|
212
|
-
get children() {
|
|
213
|
-
return [": ", _$memo(() => param.type)];
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
})];
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
FunctionDeclaration.Body = taggedComponent(functionBodyTag, function Body(props) {
|
|
222
|
-
return _$createComponent(Block, {
|
|
223
|
-
get children() {
|
|
224
|
-
return props.children;
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
//# sourceMappingURL=FunctionDeclaration.js.map
|
|
78
|
+
FunctionDeclaration.TypeParameters = TypeParameters;
|
|
79
|
+
FunctionDeclaration.Parameters = FunctionParameters;
|
|
80
|
+
FunctionDeclaration.Body = FunctionBody;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Children } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { CallSignatureProps } from "./CallSignature.jsx";
|
|
3
|
+
export interface FunctionExpressionProps extends CallSignatureProps {
|
|
4
|
+
async?: boolean;
|
|
5
|
+
children?: Children;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A TypeScript function expression.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <FunctionExpression async parameters={[{ name: "a", type: "number" }, { name: "b", type: "number" }]}>
|
|
13
|
+
* return a + b;
|
|
14
|
+
* <FunctionExpression>
|
|
15
|
+
* ```
|
|
16
|
+
* renders to
|
|
17
|
+
* ```ts
|
|
18
|
+
* async function (a, b) { return a + b; }
|
|
19
|
+
* ```
|
|
20
|
+
* @remarks
|
|
21
|
+
*
|
|
22
|
+
* Providing parameters and type parameters can be accomplished in one of three
|
|
23
|
+
* ways:
|
|
24
|
+
*
|
|
25
|
+
* 1. As an array of {@link ParameterDescriptor}s or
|
|
26
|
+
* {@link TypeParameterDescriptor}s.
|
|
27
|
+
* 2. As raw content via the `parametersChildren` or `typeParametersChildren`
|
|
28
|
+
* props.
|
|
29
|
+
* 3. As a child of this component via the
|
|
30
|
+
* {@link (FunctionExpression:namespace).Parameters} or
|
|
31
|
+
* {@link (FunctionExpression:namespace).TypeParameters} components.
|
|
32
|
+
*/
|
|
33
|
+
export declare function FunctionExpression(props: FunctionExpressionProps): Children;
|
|
34
|
+
export declare namespace FunctionExpression {
|
|
35
|
+
var TypeParameters: import("@alloy-js/core").Component<import("./FunctionBase.jsx").TypeParametersProps> & Required<Pick<import("@alloy-js/core").Component<import("./FunctionBase.jsx").TypeParametersProps>, "tag">>;
|
|
36
|
+
var Parameters: import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionParametersProps> & Required<Pick<import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionParametersProps>, "tag">>;
|
|
37
|
+
var Body: import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionBodyProps> & Required<Pick<import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionBodyProps>, "tag">>;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=FunctionExpression.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FunctionExpression.d.ts","sourceRoot":"","sources":["../../../src/components/FunctionExpression.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD,OAAO,EAAiB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AASxE,MAAM,WAAW,uBAAwB,SAAQ,kBAAkB;IACjE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,YAiChE;yBAjCe,kBAAkB"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { createComponent as _$createComponent, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { childrenArray, findKeyedChild, findUnkeyedChildren, Scope } from "@alloy-js/core";
|
|
3
|
+
import { getCallSignatureProps } from "../utils.js";
|
|
4
|
+
import { CallSignature } from "./CallSignature.js";
|
|
5
|
+
import { Declaration } from "./Declaration.js";
|
|
6
|
+
import { FunctionBody, FunctionParameters, getReturnType, TypeParameters } from "./FunctionBase.js";
|
|
7
|
+
/**
|
|
8
|
+
* A TypeScript function expression.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <FunctionExpression async parameters={[{ name: "a", type: "number" }, { name: "b", type: "number" }]}>
|
|
13
|
+
* return a + b;
|
|
14
|
+
* <FunctionExpression>
|
|
15
|
+
* ```
|
|
16
|
+
* renders to
|
|
17
|
+
* ```ts
|
|
18
|
+
* async function (a, b) { return a + b; }
|
|
19
|
+
* ```
|
|
20
|
+
* @remarks
|
|
21
|
+
*
|
|
22
|
+
* Providing parameters and type parameters can be accomplished in one of three
|
|
23
|
+
* ways:
|
|
24
|
+
*
|
|
25
|
+
* 1. As an array of {@link ParameterDescriptor}s or
|
|
26
|
+
* {@link TypeParameterDescriptor}s.
|
|
27
|
+
* 2. As raw content via the `parametersChildren` or `typeParametersChildren`
|
|
28
|
+
* props.
|
|
29
|
+
* 3. As a child of this component via the
|
|
30
|
+
* {@link (FunctionExpression:namespace).Parameters} or
|
|
31
|
+
* {@link (FunctionExpression:namespace).TypeParameters} components.
|
|
32
|
+
*/
|
|
33
|
+
export function FunctionExpression(props) {
|
|
34
|
+
const children = childrenArray(() => props.children);
|
|
35
|
+
const typeParametersChildren = findKeyedChild(children, TypeParameters.tag) ?? undefined;
|
|
36
|
+
const parametersChildren = findKeyedChild(children, FunctionParameters.tag) ?? undefined;
|
|
37
|
+
const bodyChildren = findKeyedChild(children, FunctionBody.tag) ?? undefined;
|
|
38
|
+
const filteredChildren = findUnkeyedChildren(children);
|
|
39
|
+
const returnType = getReturnType(props.returnType, {
|
|
40
|
+
async: props.async
|
|
41
|
+
});
|
|
42
|
+
const sBody = bodyChildren ?? _$createComponent(FunctionExpression.Body, {
|
|
43
|
+
children: filteredChildren
|
|
44
|
+
});
|
|
45
|
+
const asyncKwd = props.async ? "async " : "";
|
|
46
|
+
const callSignatureProps = getCallSignatureProps(props, {
|
|
47
|
+
parametersChildren,
|
|
48
|
+
typeParametersChildren
|
|
49
|
+
});
|
|
50
|
+
return [_$createComponent(Declaration, _$mergeProps(props, {
|
|
51
|
+
nameKind: "function",
|
|
52
|
+
get children() {
|
|
53
|
+
return [asyncKwd, "function ", _$createComponent(Scope, {
|
|
54
|
+
kind: "function",
|
|
55
|
+
get children() {
|
|
56
|
+
return [_$createComponent(CallSignature, _$mergeProps(callSignatureProps, {
|
|
57
|
+
returnType: returnType
|
|
58
|
+
})), " ", sBody];
|
|
59
|
+
}
|
|
60
|
+
})];
|
|
61
|
+
}
|
|
62
|
+
}))];
|
|
63
|
+
}
|
|
64
|
+
FunctionExpression.TypeParameters = TypeParameters;
|
|
65
|
+
FunctionExpression.Parameters = FunctionParameters;
|
|
66
|
+
FunctionExpression.Body = FunctionBody;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Children } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { CallSignatureProps } from "./CallSignature.jsx";
|
|
3
|
+
/**
|
|
4
|
+
* Options for {@link FunctionType} component.
|
|
5
|
+
*/
|
|
6
|
+
export interface FunctionTypeProps extends CallSignatureProps {
|
|
7
|
+
/** If the method is async */
|
|
8
|
+
readonly async?: boolean;
|
|
9
|
+
/** Documentation for this method. */
|
|
10
|
+
readonly doc?: Children;
|
|
11
|
+
/** Jsx content */
|
|
12
|
+
readonly children?: Children;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A TypeScript function declaration.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* (foo: string, bar: number) => void
|
|
20
|
+
* ```
|
|
21
|
+
* @remarks
|
|
22
|
+
*
|
|
23
|
+
* Providing parameters and type parameters can be accomplished in one of three
|
|
24
|
+
* ways:
|
|
25
|
+
*
|
|
26
|
+
* 1. As an array of {@link TypeParameterDescriptor}s or
|
|
27
|
+
* {@link TypeParameterDescriptor}s.
|
|
28
|
+
* 2. As raw content via the `parametersChildren` or `typeParametersChildren`
|
|
29
|
+
* props.
|
|
30
|
+
* 3. As a child of this component via the
|
|
31
|
+
* {@link FunctionType.Parameters} or
|
|
32
|
+
* {@link FunctionType.TypeParameters} components.
|
|
33
|
+
*/
|
|
34
|
+
export declare const FunctionType: ((props: FunctionTypeProps) => Children) & {
|
|
35
|
+
TypeParameters: import("@alloy-js/core").Component<import("./FunctionBase.jsx").TypeParametersProps> & Required<Pick<import("@alloy-js/core").Component<import("./FunctionBase.jsx").TypeParametersProps>, "tag">>;
|
|
36
|
+
Parameters: import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionTypeParametersProps> & Required<Pick<import("@alloy-js/core").Component<import("./FunctionBase.jsx").FunctionTypeParametersProps>, "tag">>;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=FunctionType.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FunctionType.d.ts","sourceRoot":"","sources":["../../../src/components/FunctionType.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD,OAAO,EAAiB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAWxE;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,kBAAkB;IAC3D,6BAA6B;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,qCAAqC;IACrC,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC;IACxB,kBAAkB;IAClB,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CAC9B;AAuCD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,YAAY;;;CAGvB,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { memo as _$memo, createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { childrenArray, findKeyedChild, Prose, Scope, Show } from "@alloy-js/core";
|
|
3
|
+
import { getCallSignatureProps } from "../utils.js";
|
|
4
|
+
import { CallSignature } from "./CallSignature.js";
|
|
5
|
+
import { FunctionParameters, FunctionTypeParameters, getReturnType, TypeParameters } from "./FunctionBase.js";
|
|
6
|
+
import { JSDoc } from "./JSDoc.js";
|
|
7
|
+
import { JSDocParams } from "./JSDocParam.js";
|
|
8
|
+
import { ensureTypeRefContext } from "./TypeRefContext.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Options for {@link FunctionType} component.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const FunctionTypeComponent = ensureTypeRefContext(props => {
|
|
15
|
+
const children = childrenArray(() => props.children);
|
|
16
|
+
const typeParametersChildren = findKeyedChild(children, TypeParameters.tag) ?? undefined;
|
|
17
|
+
const parametersChildren = findKeyedChild(children, FunctionParameters.tag) ?? undefined;
|
|
18
|
+
const returnType = getReturnType(props.returnType ?? "void", {
|
|
19
|
+
async: props.async
|
|
20
|
+
});
|
|
21
|
+
const callSignatureProps = getCallSignatureProps(props, {
|
|
22
|
+
parametersChildren,
|
|
23
|
+
typeParametersChildren
|
|
24
|
+
});
|
|
25
|
+
return [_$createComponent(Show, {
|
|
26
|
+
get when() {
|
|
27
|
+
return Boolean(props.doc);
|
|
28
|
+
},
|
|
29
|
+
get children() {
|
|
30
|
+
return [_$createComponent(JSDoc, {
|
|
31
|
+
get children() {
|
|
32
|
+
return [_$memo(() => _$memo(() => !!props.doc)() && _$createComponent(Prose, {
|
|
33
|
+
get children() {
|
|
34
|
+
return props.doc;
|
|
35
|
+
}
|
|
36
|
+
})), _$memo(() => _$memo(() => !!Array.isArray(props.parameters))() && _$createComponent(JSDocParams, {
|
|
37
|
+
get parameters() {
|
|
38
|
+
return props.parameters;
|
|
39
|
+
}
|
|
40
|
+
}))];
|
|
41
|
+
}
|
|
42
|
+
}), _$createIntrinsic("hbr", {})];
|
|
43
|
+
}
|
|
44
|
+
}), _$createComponent(Scope, {
|
|
45
|
+
kind: "function",
|
|
46
|
+
get children() {
|
|
47
|
+
return [_$createComponent(CallSignature, _$mergeProps(callSignatureProps, {
|
|
48
|
+
returnType: null
|
|
49
|
+
})), " => ", returnType];
|
|
50
|
+
}
|
|
51
|
+
})];
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* A TypeScript function declaration.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* (foo: string, bar: number) => void
|
|
60
|
+
* ```
|
|
61
|
+
* @remarks
|
|
62
|
+
*
|
|
63
|
+
* Providing parameters and type parameters can be accomplished in one of three
|
|
64
|
+
* ways:
|
|
65
|
+
*
|
|
66
|
+
* 1. As an array of {@link TypeParameterDescriptor}s or
|
|
67
|
+
* {@link TypeParameterDescriptor}s.
|
|
68
|
+
* 2. As raw content via the `parametersChildren` or `typeParametersChildren`
|
|
69
|
+
* props.
|
|
70
|
+
* 3. As a child of this component via the
|
|
71
|
+
* {@link FunctionType.Parameters} or
|
|
72
|
+
* {@link FunctionType.TypeParameters} components.
|
|
73
|
+
*/
|
|
74
|
+
export const FunctionType = Object.assign(FunctionTypeComponent, {
|
|
75
|
+
TypeParameters,
|
|
76
|
+
Parameters: FunctionTypeParameters
|
|
77
|
+
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
1
|
+
import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
3
2
|
import { Block } from "@alloy-js/core";
|
|
4
3
|
/**
|
|
5
4
|
* An if statement.
|
|
@@ -30,5 +29,4 @@ export function ElseClause(props) {
|
|
|
30
29
|
return props.children;
|
|
31
30
|
}
|
|
32
31
|
})];
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=IfStatement.js.map
|
|
32
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImportStatement.d.ts","sourceRoot":"","sources":["../../../src/components/ImportStatement.tsx"],"names":[],"mappings":"AAOA,OAAO,EACL,cAAc,EACd,aAAa,
|
|
1
|
+
{"version":3,"file":"ImportStatement.d.ts","sourceRoot":"","sources":["../../../src/components/ImportStatement.tsx"],"names":[],"mappings":"AAOA,OAAO,EACL,cAAc,EACd,aAAa,EAGd,MAAM,qBAAqB,CAAC;AAI7B,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,6CA0C5D;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC9B;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eAkD1D"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import { mapJoin, memo, SourceDirectoryContext, useContext } from "@alloy-js/core";
|
|
3
3
|
import { relative } from "pathe";
|
|
4
|
+
import { TSSymbolFlags } from "../symbols/index.js";
|
|
4
5
|
import { modulePath } from "../utils.js";
|
|
5
6
|
import { usePackage } from "./PackageDirectory.js";
|
|
6
7
|
export function ImportStatements(props) {
|
|
@@ -57,9 +58,14 @@ export function ImportStatement(props) {
|
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
if (namedImportSymbols.length > 0) {
|
|
61
|
+
const allNamedImportsAreTypes = namedImportSymbols.every(nis => nis.local.tsFlags & TSSymbolFlags.TypeSymbol);
|
|
62
|
+
if (allNamedImportsAreTypes) {
|
|
63
|
+
parts.push("type ");
|
|
64
|
+
}
|
|
60
65
|
parts.push("{ ");
|
|
61
66
|
parts.push(mapJoin(() => namedImportSymbols, nis => _$createComponent(ImportBinding, {
|
|
62
|
-
importedSymbol: nis
|
|
67
|
+
importedSymbol: nis,
|
|
68
|
+
inTypeImport: allNamedImportsAreTypes
|
|
63
69
|
}), {
|
|
64
70
|
joiner: ", "
|
|
65
71
|
}));
|
|
@@ -81,6 +87,6 @@ function ImportBinding(props) {
|
|
|
81
87
|
return `${targetName} as ${localName}`;
|
|
82
88
|
}
|
|
83
89
|
});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
90
|
+
const prefix = memo(() => !props.inTypeImport && props.importedSymbol.local.tsFlags & TSSymbolFlags.TypeSymbol ? "type " : "");
|
|
91
|
+
return [prefix, text];
|
|
92
|
+
}
|
|
@@ -12,17 +12,18 @@ export interface InterfaceDeclarationProps extends BaseDeclarationProps {
|
|
|
12
12
|
* `default` boolean props determine whether and how this symbol is exported
|
|
13
13
|
* from the package.
|
|
14
14
|
*/
|
|
15
|
-
export declare
|
|
15
|
+
export declare const InterfaceDeclaration: (props: InterfaceDeclarationProps) => Children;
|
|
16
16
|
export interface InterfaceExpressionProps {
|
|
17
17
|
children?: Children;
|
|
18
18
|
}
|
|
19
|
-
export declare
|
|
19
|
+
export declare const InterfaceExpression: (props: InterfaceExpressionProps) => Children;
|
|
20
20
|
export interface InterfaceMemberProps {
|
|
21
21
|
name?: string;
|
|
22
22
|
indexer?: Children;
|
|
23
23
|
type?: Children;
|
|
24
24
|
children?: Children;
|
|
25
25
|
optional?: boolean;
|
|
26
|
+
nullish?: boolean;
|
|
26
27
|
readonly?: boolean;
|
|
27
28
|
doc?: Children;
|
|
28
29
|
refkey?: Refkey | Refkey[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Interface.d.ts","sourceRoot":"","sources":["../../../src/components/Interface.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAIR,MAAM,
|
|
1
|
+
{"version":3,"file":"Interface.d.ts","sourceRoot":"","sources":["../../../src/components/Interface.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAIR,MAAM,EAKP,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAe,MAAM,kBAAkB,CAAC;AAOrE,MAAM,WAAW,yBAA0B,SAAQ,oBAAoB;IACrE,OAAO,CAAC,EAAE,QAAQ,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,gDAmBhC,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,eAAO,MAAM,mBAAmB,+CAmB/B,CAAC;AAEF,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC5B;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,YAkD1D"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
4
|
-
import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
5
|
-
import { Block, MemberDeclaration, Name, OutputSymbolFlags, Show } from "@alloy-js/core";
|
|
1
|
+
import { memo as _$memo, createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { Block, MemberScope, Name, OutputSymbolFlags, Show, useMemberDeclaration, useMemberScope, Wrap } from "@alloy-js/core";
|
|
6
3
|
import { useTSNamePolicy } from "../name-policy.js";
|
|
7
4
|
import { Declaration } from "./Declaration.js";
|
|
8
5
|
import { JSDoc } from "./JSDoc.js";
|
|
6
|
+
import { MemberDeclaration } from "./MemberDeclaration.js";
|
|
9
7
|
import { PropertyName } from "./PropertyName.js";
|
|
8
|
+
import { ensureTypeRefContext } from "./TypeRefContext.js";
|
|
10
9
|
/**
|
|
11
10
|
* Create a TypeScript interface declaration.
|
|
12
11
|
*
|
|
@@ -16,7 +15,7 @@ import { PropertyName } from "./PropertyName.js";
|
|
|
16
15
|
* `default` boolean props determine whether and how this symbol is exported
|
|
17
16
|
* from the package.
|
|
18
17
|
*/
|
|
19
|
-
export
|
|
18
|
+
export const InterfaceDeclaration = ensureTypeRefContext(props => {
|
|
20
19
|
const extendsPart = props.extends ? [" extends ", _$memo(() => props.extends)] : "";
|
|
21
20
|
const flags = OutputSymbolFlags.StaticMemberContainer;
|
|
22
21
|
return [_$createComponent(Show, {
|
|
@@ -33,6 +32,7 @@ export function InterfaceDeclaration(props) {
|
|
|
33
32
|
}), _$createComponent(Declaration, _$mergeProps(props, {
|
|
34
33
|
nameKind: "interface",
|
|
35
34
|
flags: flags,
|
|
35
|
+
kind: "type",
|
|
36
36
|
get children() {
|
|
37
37
|
return ["interface ", _$createComponent(Name, {}), extendsPart, " ", _$createComponent(InterfaceExpression, {
|
|
38
38
|
get children() {
|
|
@@ -41,14 +41,31 @@ export function InterfaceDeclaration(props) {
|
|
|
41
41
|
})];
|
|
42
42
|
}
|
|
43
43
|
}))];
|
|
44
|
-
}
|
|
45
|
-
export
|
|
46
|
-
|
|
44
|
+
});
|
|
45
|
+
export const InterfaceExpression = ensureTypeRefContext(props => {
|
|
46
|
+
const parentMemberSym = useMemberDeclaration();
|
|
47
|
+
if (parentMemberSym) {
|
|
48
|
+
parentMemberSym.binder.addStaticMembersToSymbol(parentMemberSym);
|
|
49
|
+
}
|
|
50
|
+
return _$createIntrinsic("group", {
|
|
47
51
|
get children() {
|
|
48
|
-
return
|
|
52
|
+
return _$createComponent(Wrap, {
|
|
53
|
+
when: !!parentMemberSym,
|
|
54
|
+
"with": MemberScope,
|
|
55
|
+
props: {
|
|
56
|
+
owner: parentMemberSym
|
|
57
|
+
},
|
|
58
|
+
get children() {
|
|
59
|
+
return _$createComponent(Block, {
|
|
60
|
+
get children() {
|
|
61
|
+
return props.children;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
49
66
|
}
|
|
50
67
|
});
|
|
51
|
-
}
|
|
68
|
+
});
|
|
52
69
|
/**
|
|
53
70
|
* Create a TypeScript interface member.
|
|
54
71
|
*
|
|
@@ -67,10 +84,19 @@ export function InterfaceMember(props) {
|
|
|
67
84
|
} else {
|
|
68
85
|
const namer = useTSNamePolicy();
|
|
69
86
|
const name = namer.getName(props.name, "interface-member");
|
|
70
|
-
|
|
87
|
+
const memberScope = useMemberScope();
|
|
88
|
+
if (memberScope) {
|
|
71
89
|
return _$createComponent(MemberDeclaration, {
|
|
72
90
|
"static": true,
|
|
73
|
-
|
|
91
|
+
exactName: name,
|
|
92
|
+
kind: "type",
|
|
93
|
+
nameKind: "interface-member",
|
|
94
|
+
get flags() {
|
|
95
|
+
return OutputSymbolFlags.StaticMember;
|
|
96
|
+
},
|
|
97
|
+
get nullish() {
|
|
98
|
+
return props.nullish ?? props.optional;
|
|
99
|
+
},
|
|
74
100
|
get refkey() {
|
|
75
101
|
return props.refkey;
|
|
76
102
|
},
|
|
@@ -106,5 +132,4 @@ export function InterfaceMember(props) {
|
|
|
106
132
|
}), optionality, ": ", type];
|
|
107
133
|
}
|
|
108
134
|
}
|
|
109
|
-
}
|
|
110
|
-
//# sourceMappingURL=Interface.js.map
|
|
135
|
+
}
|