@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,5 +1,6 @@
|
|
|
1
1
|
export * from "../parameter-descriptor.js";
|
|
2
2
|
export * from "./ArrayExpression.js";
|
|
3
|
+
export * from "./ArrowFunction.jsx";
|
|
3
4
|
export * from "./BarrelFile.js";
|
|
4
5
|
export * from "./BlockScope.js";
|
|
5
6
|
export * from "./CallSignature.jsx";
|
|
@@ -9,10 +10,15 @@ export * from "./Declaration.js";
|
|
|
9
10
|
export * from "./EnumDeclaration.js";
|
|
10
11
|
export * from "./EnumMember.js";
|
|
11
12
|
export * from "./ExportStatement.js";
|
|
13
|
+
export { type FunctionBodyProps, type FunctionParametersProps, type FunctionTypeParametersProps, } from "./FunctionBase.js";
|
|
12
14
|
export * from "./FunctionCallExpression.js";
|
|
13
15
|
export * from "./FunctionDeclaration.js";
|
|
16
|
+
export * from "./FunctionExpression.js";
|
|
17
|
+
export * from "./FunctionType.jsx";
|
|
18
|
+
export * from "./IfStatement.jsx";
|
|
14
19
|
export * from "./ImportStatement.js";
|
|
15
20
|
export * from "./Interface.js";
|
|
21
|
+
export * from "./InterfaceMethod.jsx";
|
|
16
22
|
export * from "./JSDoc.jsx";
|
|
17
23
|
export * from "./JSDocComment.jsx";
|
|
18
24
|
export * from "./JSDocExample.jsx";
|
|
@@ -26,6 +32,7 @@ export * from "./SourceFile.js";
|
|
|
26
32
|
export * from "./SwitchStatement.jsx";
|
|
27
33
|
export * from "./TsConfigJson.js";
|
|
28
34
|
export * from "./TypeDeclaration.js";
|
|
35
|
+
export * from "./TypeRefContext.jsx";
|
|
29
36
|
export * from "./ValueExpression.js";
|
|
30
37
|
export * from "./VarDeclaration.js";
|
|
31
38
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAA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,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "../parameter-descriptor.js";
|
|
2
2
|
export * from "./ArrayExpression.js";
|
|
3
|
+
export * from "./ArrowFunction.js";
|
|
3
4
|
export * from "./BarrelFile.js";
|
|
4
5
|
export * from "./BlockScope.js";
|
|
5
6
|
export * from "./CallSignature.js";
|
|
@@ -11,8 +12,12 @@ export * from "./EnumMember.js";
|
|
|
11
12
|
export * from "./ExportStatement.js";
|
|
12
13
|
export * from "./FunctionCallExpression.js";
|
|
13
14
|
export * from "./FunctionDeclaration.js";
|
|
15
|
+
export * from "./FunctionExpression.js";
|
|
16
|
+
export * from "./FunctionType.js";
|
|
17
|
+
export * from "./IfStatement.js";
|
|
14
18
|
export * from "./ImportStatement.js";
|
|
15
19
|
export * from "./Interface.js";
|
|
20
|
+
export * from "./InterfaceMethod.js";
|
|
16
21
|
export * from "./JSDoc.js";
|
|
17
22
|
export * from "./JSDocComment.js";
|
|
18
23
|
export * from "./JSDocExample.js";
|
|
@@ -26,6 +31,7 @@ export * from "./SourceFile.js";
|
|
|
26
31
|
export * from "./SwitchStatement.js";
|
|
27
32
|
export * from "./TsConfigJson.js";
|
|
28
33
|
export * from "./TypeDeclaration.js";
|
|
34
|
+
export * from "./TypeRefContext.js";
|
|
29
35
|
export * from "./ValueExpression.js";
|
|
30
36
|
export * from "./VarDeclaration.js";
|
|
31
|
-
|
|
37
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as base from "../index.js";
|
|
2
2
|
export declare const ArrayExpression: import("@alloy-js/core").StcSignature<base.ArrayExpressionProps>;
|
|
3
|
+
export declare const ArrowFunction: import("@alloy-js/core").StcSignature<base.ArrowFunctionProps>;
|
|
3
4
|
export declare const BarrelFile: import("@alloy-js/core").StcSignature<base.BarrelFileProps>;
|
|
4
5
|
export declare const CallSignature: import("@alloy-js/core").StcSignature<base.CallSignatureProps>;
|
|
5
6
|
export declare const ClassDeclaration: import("@alloy-js/core").StcSignature<base.ClassDeclarationProps>;
|
|
@@ -13,11 +14,16 @@ export declare const EnumMember: import("@alloy-js/core").StcSignature<base.Enum
|
|
|
13
14
|
export declare const ExportStatement: import("@alloy-js/core").StcSignature<base.ExportStatementProps>;
|
|
14
15
|
export declare const FunctionCallExpression: import("@alloy-js/core").StcSignature<base.FunctionCallExpressionProps>;
|
|
15
16
|
export declare const FunctionDeclaration: import("@alloy-js/core").StcSignature<base.FunctionDeclarationProps>;
|
|
17
|
+
export declare const FunctionExpression: import("@alloy-js/core").StcSignature<base.FunctionExpressionProps>;
|
|
18
|
+
export declare const IfStatement: import("@alloy-js/core").StcSignature<base.IfStatementProps>;
|
|
19
|
+
export declare const ElseClause: import("@alloy-js/core").StcSignature<base.ElseClauseProps>;
|
|
20
|
+
export declare const ElseIfClause: import("@alloy-js/core").StcSignature<base.ElseIfClauseProps>;
|
|
16
21
|
export declare const ImportStatement: import("@alloy-js/core").StcSignature<base.ImportStatementProps>;
|
|
17
22
|
export declare const ImportStatements: import("@alloy-js/core").StcSignature<base.ImportStatementsProps>;
|
|
18
23
|
export declare const InterfaceDeclaration: import("@alloy-js/core").StcSignature<base.InterfaceDeclarationProps>;
|
|
19
24
|
export declare const InterfaceExpression: import("@alloy-js/core").StcSignature<base.InterfaceExpressionProps>;
|
|
20
25
|
export declare const InterfaceMember: import("@alloy-js/core").StcSignature<base.InterfaceMemberProps>;
|
|
26
|
+
export declare const InterfaceMethod: import("@alloy-js/core").StcSignature<base.InterfaceMethodProps>;
|
|
21
27
|
export declare const JSDoc: import("@alloy-js/core").StcSignature<base.JSDocProps>;
|
|
22
28
|
export declare const JSDocExample: import("@alloy-js/core").StcSignature<base.JSDocExampleProps>;
|
|
23
29
|
export declare const JSDocComment: import("@alloy-js/core").StcSignature<base.JSDocCommentProps>;
|
|
@@ -32,7 +38,9 @@ export declare const SourceFile: import("@alloy-js/core").StcSignature<base.Sour
|
|
|
32
38
|
export declare const SwitchStatement: import("@alloy-js/core").StcSignature<base.SwitchStatementProps>;
|
|
33
39
|
export declare const CaseClause: import("@alloy-js/core").StcSignature<base.CaseClauseProps>;
|
|
34
40
|
export declare const TSConfigJson: import("@alloy-js/core").StcSignature<base.TSConfigJsonProps>;
|
|
41
|
+
export declare const FunctionType: import("@alloy-js/core").StcSignature<base.FunctionTypeProps>;
|
|
35
42
|
export declare const TypeDeclaration: import("@alloy-js/core").StcSignature<base.TypeDeclarationProps>;
|
|
43
|
+
export declare const TypeRefContext: import("@alloy-js/core").StcSignature<base.TypeRefContextProps>;
|
|
36
44
|
export declare const ValueExpression: import("@alloy-js/core").StcSignature<base.ValueExpressionProps>;
|
|
37
45
|
export declare const VarDeclaration: import("@alloy-js/core").StcSignature<base.VarDeclarationProps>;
|
|
38
46
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/stc/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAEpC,eAAO,MAAM,eAAe,kEAA4B,CAAC;AACzD,eAAO,MAAM,UAAU,6DAAuB,CAAC;AAC/C,eAAO,MAAM,aAAa,gEA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B,CAAC;AACrC,eAAO,MAAM,YAAY,+DAAyB,CAAC;AACnD,eAAO,MAAM,YAAY,+DAAyB,CAAC;AACnD,eAAO,MAAM,gBAAgB,mEAA6B,CAAC;AAC3D,eAAO,MAAM,qBAAqB,wEAAkC,CAAC;AACrE,eAAO,MAAM,gBAAgB,mEAA6B,CAAC;AAC3D,eAAO,MAAM,cAAc,iEAA2B,CAAC;AACvD,eAAO,MAAM,gBAAgB,mEAA6B,CAAC;AAC3D,eAAO,MAAM,eAAe,kEAA4B,CAAC;AACzD,eAAO,MAAM,SAAS,4DAAsB,CAAC;AAC7C,eAAO,MAAM,UAAU,6DAAuB,CAAC;AAC/C,eAAO,MAAM,eAAe,kEAA4B,CAAC;AACzD,eAAO,MAAM,UAAU,6DAAuB,CAAC;AAC/C,eAAO,MAAM,YAAY,+DAAyB,CAAC;AACnD,eAAO,MAAM,YAAY,+DAAyB,CAAC;AACnD,eAAO,MAAM,eAAe,kEAA4B,CAAC;AACzD,eAAO,MAAM,cAAc,iEAA2B,CAAC;AACvD,eAAO,MAAM,eAAe,kEAA4B,CAAC;AACzD,eAAO,MAAM,cAAc,iEAA2B,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { stc } from "@alloy-js/core";
|
|
2
2
|
import * as base from "../index.js";
|
|
3
3
|
export const ArrayExpression = stc(base.ArrayExpression);
|
|
4
|
+
export const ArrowFunction = stc(base.ArrowFunction);
|
|
4
5
|
export const BarrelFile = stc(base.BarrelFile);
|
|
5
6
|
export const CallSignature = stc(base.CallSignature);
|
|
6
7
|
export const ClassDeclaration = stc(base.ClassDeclaration);
|
|
@@ -14,11 +15,16 @@ export const EnumMember = stc(base.EnumMember);
|
|
|
14
15
|
export const ExportStatement = stc(base.ExportStatement);
|
|
15
16
|
export const FunctionCallExpression = stc(base.FunctionCallExpression);
|
|
16
17
|
export const FunctionDeclaration = stc(base.FunctionDeclaration);
|
|
18
|
+
export const FunctionExpression = stc(base.FunctionExpression);
|
|
19
|
+
export const IfStatement = stc(base.IfStatement);
|
|
20
|
+
export const ElseClause = stc(base.ElseClause);
|
|
21
|
+
export const ElseIfClause = stc(base.ElseIfClause);
|
|
17
22
|
export const ImportStatement = stc(base.ImportStatement);
|
|
18
23
|
export const ImportStatements = stc(base.ImportStatements);
|
|
19
24
|
export const InterfaceDeclaration = stc(base.InterfaceDeclaration);
|
|
20
25
|
export const InterfaceExpression = stc(base.InterfaceExpression);
|
|
21
26
|
export const InterfaceMember = stc(base.InterfaceMember);
|
|
27
|
+
export const InterfaceMethod = stc(base.InterfaceMethod);
|
|
22
28
|
export const JSDoc = stc(base.JSDoc);
|
|
23
29
|
export const JSDocExample = stc(base.JSDocExample);
|
|
24
30
|
export const JSDocComment = stc(base.JSDocComment);
|
|
@@ -33,7 +39,8 @@ export const SourceFile = stc(base.SourceFile);
|
|
|
33
39
|
export const SwitchStatement = stc(base.SwitchStatement);
|
|
34
40
|
export const CaseClause = stc(base.CaseClause);
|
|
35
41
|
export const TSConfigJson = stc(base.TSConfigJson);
|
|
42
|
+
export const FunctionType = stc(base.FunctionType);
|
|
36
43
|
export const TypeDeclaration = stc(base.TypeDeclaration);
|
|
44
|
+
export const TypeRefContext = stc(base.TypeRefContext);
|
|
37
45
|
export const ValueExpression = stc(base.ValueExpression);
|
|
38
|
-
export const VarDeclaration = stc(base.VarDeclaration);
|
|
39
|
-
//# sourceMappingURL=index.js.map
|
|
46
|
+
export const VarDeclaration = stc(base.VarDeclaration);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ComponentContext } from "@alloy-js/core";
|
|
2
|
+
interface TypeRefContext {
|
|
3
|
+
/** If in a type context */
|
|
4
|
+
type?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Provides scopes for instance and static private members.
|
|
8
|
+
*/
|
|
9
|
+
export declare const TypeRefContext: ComponentContext<TypeRefContext>;
|
|
10
|
+
/**
|
|
11
|
+
* @returns 'true' if in a type context, 'false' if in a value context.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isTypeRefContext(): boolean;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=type-ref-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-ref-context.d.ts","sourceRoot":"","sources":["../../../src/context/type-ref-context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA6B,MAAM,gBAAgB,CAAC;AAE7E,UAAU,cAAc;IACtB,2BAA2B;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,gBAAgB,CAAC,cAAc,CAC3B,CAAC;AAElC;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createContext, useContext } from "@alloy-js/core";
|
|
2
|
+
/**
|
|
3
|
+
* Provides scopes for instance and static private members.
|
|
4
|
+
*/
|
|
5
|
+
export const TypeRefContext = createContext();
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @returns 'true' if in a type context, 'false' if in a value context.
|
|
9
|
+
*/
|
|
10
|
+
export function isTypeRefContext() {
|
|
11
|
+
return useContext(TypeRefContext)?.type ?? false;
|
|
12
|
+
}
|
package/dist/src/index.js
CHANGED
package/dist/src/name-policy.js
CHANGED
|
@@ -1,36 +1,52 @@
|
|
|
1
1
|
import { Children, Refkey } from "@alloy-js/core";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Common properties for ParameterDescriptor and FunctionTypeParameterDescriptor.
|
|
4
4
|
*/
|
|
5
|
-
export interface
|
|
5
|
+
export interface ParameterDescriptorBase {
|
|
6
6
|
/**
|
|
7
7
|
* The name of the parameter.
|
|
8
8
|
*/
|
|
9
|
-
name: string;
|
|
9
|
+
readonly name: string;
|
|
10
10
|
/**
|
|
11
11
|
* The type of the parameter.
|
|
12
12
|
*/
|
|
13
|
-
type?: Children;
|
|
14
|
-
/**
|
|
15
|
-
* The default value of the parameter.
|
|
16
|
-
*/
|
|
17
|
-
default?: Children;
|
|
13
|
+
readonly type?: Children;
|
|
18
14
|
/**
|
|
19
15
|
* The refkey for this parameter.
|
|
20
16
|
*/
|
|
21
|
-
refkey?: Refkey | Refkey[];
|
|
17
|
+
readonly refkey?: Refkey | Refkey[];
|
|
22
18
|
/**
|
|
23
19
|
* Whether the parameter is optional.
|
|
24
20
|
*/
|
|
25
|
-
optional?: boolean;
|
|
21
|
+
readonly optional?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the parameter is can be null or undefined.
|
|
24
|
+
* when optional is true, this will be set to true by default,
|
|
25
|
+
* but explicitly setting this to false will override that.
|
|
26
|
+
*/
|
|
27
|
+
readonly nullish?: boolean;
|
|
26
28
|
/**
|
|
27
29
|
* Arbitrary metadata for the parameter symbol.
|
|
28
30
|
*/
|
|
29
|
-
metadata?: Record<string, unknown>;
|
|
31
|
+
readonly metadata?: Record<string, unknown>;
|
|
30
32
|
/**
|
|
31
33
|
* Documentation for the parameter.
|
|
32
34
|
*/
|
|
33
|
-
doc?: Children;
|
|
35
|
+
readonly doc?: Children;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Information for a TypeScript function parameter.
|
|
39
|
+
*/
|
|
40
|
+
export interface ParameterDescriptor extends ParameterDescriptorBase {
|
|
41
|
+
/**
|
|
42
|
+
* The default value of the parameter.
|
|
43
|
+
*/
|
|
44
|
+
readonly default?: Children;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Information for a TypeScript type function parameter.
|
|
48
|
+
*/
|
|
49
|
+
export interface FunctionTypeParameterDescriptor extends ParameterDescriptorBase {
|
|
34
50
|
}
|
|
35
51
|
/**
|
|
36
52
|
* Information for a TypeScript generic type parameter.
|
|
@@ -39,22 +55,22 @@ export interface TypeParameterDescriptor {
|
|
|
39
55
|
/**
|
|
40
56
|
* The name of the type parameter.
|
|
41
57
|
*/
|
|
42
|
-
name: string;
|
|
58
|
+
readonly name: string;
|
|
43
59
|
/**
|
|
44
60
|
* The extends constraint for the type parameter.
|
|
45
61
|
*/
|
|
46
|
-
extends?: Children;
|
|
62
|
+
readonly extends?: Children;
|
|
47
63
|
/**
|
|
48
64
|
* The default type of the type parameter.
|
|
49
65
|
*/
|
|
50
|
-
default?: Children;
|
|
66
|
+
readonly default?: Children;
|
|
51
67
|
/**
|
|
52
68
|
* A refkey or array of refkeys for this type parameter.
|
|
53
69
|
*/
|
|
54
|
-
refkey?: Refkey | Refkey[];
|
|
70
|
+
readonly refkey?: Refkey | Refkey[];
|
|
55
71
|
/**
|
|
56
72
|
* Arbitrary metadata for the type parameter symbol.
|
|
57
73
|
*/
|
|
58
|
-
metadata?: Record<string, unknown>;
|
|
74
|
+
readonly metadata?: Record<string, unknown>;
|
|
59
75
|
}
|
|
60
76
|
//# sourceMappingURL=parameter-descriptor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameter-descriptor.d.ts","sourceRoot":"","sources":["../../src/parameter-descriptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"parameter-descriptor.d.ts","sourceRoot":"","sources":["../../src/parameter-descriptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAEpC;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAE5B;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE5C;;OAEG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,uBAAuB;IAClE;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,+BACf,SAAQ,uBAAuB;CAAG;AAEpC;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAEpC;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7C"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { Refkey } from "@alloy-js/core";
|
|
2
|
-
export
|
|
2
|
+
export interface RefOptions {
|
|
3
|
+
type?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function ref(refkey: Refkey, options?: RefOptions): () => string;
|
|
3
6
|
//# sourceMappingURL=reference.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../src/symbols/reference.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,EAKP,MAAM,gBAAgB,CAAC;AAcxB,wBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../src/symbols/reference.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,EAKP,MAAM,gBAAgB,CAAC;AAcxB,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AACD,wBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,MAAM,MAAM,CAuGtE"}
|
|
@@ -4,7 +4,7 @@ import { SourceFileContext } from "../components/SourceFile.js";
|
|
|
4
4
|
import { usePrivateScope } from "../context/private-scope.js";
|
|
5
5
|
import { isValidJSIdentifier } from "../utils.js";
|
|
6
6
|
import { TSSymbolFlags } from "./ts-output-symbol.js";
|
|
7
|
-
export function ref(refkey) {
|
|
7
|
+
export function ref(refkey, options) {
|
|
8
8
|
const sourceFile = useContext(SourceFileContext);
|
|
9
9
|
const resolveResult = resolve(refkey);
|
|
10
10
|
const currentScope = useMemberScope();
|
|
@@ -65,7 +65,9 @@ export function ref(refkey) {
|
|
|
65
65
|
} else if (targetLocation === "module") {
|
|
66
66
|
const symbolPath = [...pathDown.slice(1).map(s => s.owner), targetDeclaration];
|
|
67
67
|
const importSymbol = symbolPath[0];
|
|
68
|
-
localSymbol = untrack(() => sourceFile.scope.addImport(importSymbol, pathDown[0]
|
|
68
|
+
localSymbol = untrack(() => sourceFile.scope.addImport(importSymbol, pathDown[0], {
|
|
69
|
+
type: options?.type
|
|
70
|
+
}));
|
|
69
71
|
}
|
|
70
72
|
if (memberPath && memberPath.length > 0) {
|
|
71
73
|
if (localSymbol) {
|
|
@@ -86,14 +88,18 @@ function buildMemberExpression(path) {
|
|
|
86
88
|
memberExpr += base.name;
|
|
87
89
|
path = path.slice(1);
|
|
88
90
|
}
|
|
91
|
+
let prevNullish = base.tsFlags & TSSymbolFlags.Nullish;
|
|
89
92
|
for (const sym of path) {
|
|
93
|
+
const optional = prevNullish ? "?" : "";
|
|
90
94
|
if (sym.tsFlags & TSSymbolFlags.PrivateMember) {
|
|
91
|
-
memberExpr +=
|
|
92
|
-
} else if (isValidJSIdentifier(sym.name)) {
|
|
93
|
-
memberExpr +=
|
|
95
|
+
memberExpr += `${optional}.#${sym.name}`;
|
|
96
|
+
} else if (isValidJSIdentifier(sym.name) && !(sym.tsFlags & TSSymbolFlags.TypeSymbol)) {
|
|
97
|
+
memberExpr += `${optional}.${sym.name}`;
|
|
94
98
|
} else {
|
|
95
|
-
|
|
99
|
+
const joiner = sym.tsFlags & TSSymbolFlags.Nullish ? "?." : "";
|
|
100
|
+
memberExpr += `${joiner}[${JSON.stringify(sym.name)}]`;
|
|
96
101
|
}
|
|
102
|
+
prevNullish = sym.tsFlags & TSSymbolFlags.Nullish;
|
|
97
103
|
}
|
|
98
104
|
return memberExpr;
|
|
99
105
|
}
|
|
@@ -112,5 +118,4 @@ function validateSymbolReachable(path, memberPath, currentPrivateScope) {
|
|
|
112
118
|
}
|
|
113
119
|
}
|
|
114
120
|
}
|
|
115
|
-
}
|
|
116
|
-
//# sourceMappingURL=reference.js.map
|
|
121
|
+
}
|
|
@@ -5,6 +5,9 @@ export interface ImportedSymbol {
|
|
|
5
5
|
target: TSOutputSymbol;
|
|
6
6
|
}
|
|
7
7
|
export type ImportRecords = Map<TSModuleScope, Set<ImportedSymbol>>;
|
|
8
|
+
export interface AddImportOptions {
|
|
9
|
+
type?: boolean;
|
|
10
|
+
}
|
|
8
11
|
export interface TSModuleScope extends OutputScope {
|
|
9
12
|
kind: "module";
|
|
10
13
|
exportedSymbols: Map<Refkey, TSOutputSymbol>;
|
|
@@ -13,7 +16,7 @@ export interface TSModuleScope extends OutputScope {
|
|
|
13
16
|
*/
|
|
14
17
|
importedSymbols: Map<TSOutputSymbol, TSOutputSymbol>;
|
|
15
18
|
importedModules: ImportRecords;
|
|
16
|
-
addImport(symbol: TSOutputSymbol, module: TSModuleScope): TSOutputSymbol;
|
|
19
|
+
addImport(symbol: TSOutputSymbol, module: TSModuleScope, options?: AddImportOptions): TSOutputSymbol;
|
|
17
20
|
}
|
|
18
21
|
export declare function createTSModuleScope(binder: Binder, parent: OutputScope, path: string): TSModuleScope;
|
|
19
22
|
//# sourceMappingURL=ts-module-scope.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ts-module-scope.d.ts","sourceRoot":"","sources":["../../../src/symbols/ts-module-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAU,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAEL,cAAc,EAEf,MAAM,uBAAuB,CAAC;AAE/B,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,cAAc,CAAC;IACtB,MAAM,EAAE,cAAc,CAAC;CACxB;AACD,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;AAEpE,MAAM,WAAW,aAAc,SAAQ,WAAW;IAChD,IAAI,EAAE,QAAQ,CAAC;IACf,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC7C;;OAEG;IACH,eAAe,EAAE,GAAG,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;IACrD,eAAe,EAAE,aAAa,CAAC;IAC/B,SAAS,
|
|
1
|
+
{"version":3,"file":"ts-module-scope.d.ts","sourceRoot":"","sources":["../../../src/symbols/ts-module-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAU,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAEL,cAAc,EAEf,MAAM,uBAAuB,CAAC;AAE/B,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,cAAc,CAAC;IACtB,MAAM,EAAE,cAAc,CAAC;CACxB;AACD,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;AAEpE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,aAAc,SAAQ,WAAW;IAChD,IAAI,EAAE,QAAQ,CAAC;IACf,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC7C;;OAEG;IACH,eAAe,EAAE,GAAG,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;IACrD,eAAe,EAAE,aAAa,CAAC;IAC/B,SAAS,CACP,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,aAAa,EACrB,OAAO,CAAC,EAAE,gBAAgB,GACzB,cAAc,CAAC;CACnB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,MAAM,GACX,aAAa,CA6Cf"}
|
|
@@ -8,9 +8,13 @@ export function createTSModuleScope(binder, parent, path) {
|
|
|
8
8
|
exportedSymbols: new Map(),
|
|
9
9
|
importedSymbols: new Map(),
|
|
10
10
|
importedModules: new Map(),
|
|
11
|
-
addImport(targetSymbol, targetModule) {
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
addImport(targetSymbol, targetModule, options) {
|
|
12
|
+
const existing = this.importedSymbols.get(targetSymbol);
|
|
13
|
+
if (existing) {
|
|
14
|
+
if (!options?.type && existing.tsFlags & TSSymbolFlags.TypeSymbol) {
|
|
15
|
+
existing.tsFlags &= ~TSSymbolFlags.TypeSymbol;
|
|
16
|
+
}
|
|
17
|
+
return existing;
|
|
14
18
|
}
|
|
15
19
|
if (targetModule.kind !== "module") {
|
|
16
20
|
throw new Error("Cannot import symbol that isn't in module scope");
|
|
@@ -25,6 +29,9 @@ export function createTSModuleScope(binder, parent, path) {
|
|
|
25
29
|
refkey: refkey({}),
|
|
26
30
|
tsFlags: TSSymbolFlags.LocalImportSymbol
|
|
27
31
|
});
|
|
32
|
+
if (options?.type) {
|
|
33
|
+
localSymbol.tsFlags |= TSSymbolFlags.TypeSymbol;
|
|
34
|
+
}
|
|
28
35
|
this.importedSymbols.set(targetSymbol, localSymbol);
|
|
29
36
|
this.importedModules.get(targetModule).add({
|
|
30
37
|
local: localSymbol,
|
|
@@ -33,5 +40,4 @@ export function createTSModuleScope(binder, parent, path) {
|
|
|
33
40
|
return localSymbol;
|
|
34
41
|
}
|
|
35
42
|
});
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=ts-module-scope.js.map
|
|
43
|
+
}
|
|
@@ -7,7 +7,8 @@ export declare enum TSSymbolFlags {
|
|
|
7
7
|
TypeSymbol = 2,
|
|
8
8
|
ParameterSymbol = 4,
|
|
9
9
|
PrivateMember = 8,
|
|
10
|
-
PrivateMemberContainer = 16
|
|
10
|
+
PrivateMemberContainer = 16,
|
|
11
|
+
Nullish = 32
|
|
11
12
|
}
|
|
12
13
|
export interface TSOutputSymbol extends OutputSymbol {
|
|
13
14
|
scope: TSOutputScope;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ts-output-symbol.d.ts","sourceRoot":"","sources":["../../../src/symbols/ts-output-symbol.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,YAAY,EACZ,iBAAiB,EACjB,MAAM,EAEP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAuB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1E,oBAAY,aAAa;IACvB,IAAI,IAAsB;IAC1B,iBAAiB,IAAc;IAC/B,UAAU,IAAqB;IAC/B,eAAe,IAAgB;IAC/B,aAAa,IAAkB;IAC/B,sBAAsB,KAAS;
|
|
1
|
+
{"version":3,"file":"ts-output-symbol.d.ts","sourceRoot":"","sources":["../../../src/symbols/ts-output-symbol.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,YAAY,EACZ,iBAAiB,EACjB,MAAM,EAEP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAuB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1E,oBAAY,aAAa;IACvB,IAAI,IAAsB;IAC1B,iBAAiB,IAAc;IAC/B,UAAU,IAAqB;IAC/B,eAAe,IAAgB;IAC/B,aAAa,IAAkB;IAC/B,sBAAsB,KAAS;IAC/B,OAAO,KAAS;CACjB;AAED,MAAM,WAAW,cAAe,SAAQ,YAAY;IAClD,KAAK,EAAE,aAAa,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,aAAa,CAAC;IACvB,kBAAkB,CAAC,EAAE,aAAa,CAAC;IACnC,wBAAwB,CAAC,EAAE,aAAa,CAAC;CAC1C;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,cAAc,CAsC7E"}
|
|
@@ -9,6 +9,7 @@ export let TSSymbolFlags = /*#__PURE__*/function (TSSymbolFlags) {
|
|
|
9
9
|
TSSymbolFlags[TSSymbolFlags["ParameterSymbol"] = 4] = "ParameterSymbol";
|
|
10
10
|
TSSymbolFlags[TSSymbolFlags["PrivateMember"] = 8] = "PrivateMember";
|
|
11
11
|
TSSymbolFlags[TSSymbolFlags["PrivateMemberContainer"] = 16] = "PrivateMemberContainer";
|
|
12
|
+
TSSymbolFlags[TSSymbolFlags["Nullish"] = 32] = "Nullish";
|
|
12
13
|
return TSSymbolFlags;
|
|
13
14
|
}({});
|
|
14
15
|
export function createTSSymbol(options) {
|
|
@@ -38,5 +39,4 @@ export function createTSSymbol(options) {
|
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
return sym;
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=ts-output-symbol.js.map
|
|
42
|
+
}
|
package/dist/src/utils.js
CHANGED
|
@@ -20,5 +20,4 @@ export function getCallSignatureProps(props, defaults) {
|
|
|
20
20
|
const identifierRegex = /^(?:[\p{ID_Start}$_])(?:[\p{ID_Continue}$\u200C\u200D])*$/u;
|
|
21
21
|
export function isValidJSIdentifier(str) {
|
|
22
22
|
return identifierRegex.test(str);
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=utils.js.map
|
|
23
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { d } from "@alloy-js/core/testing";
|
|
3
|
+
import { expect, it } from "vitest";
|
|
4
|
+
import { ArrayExpression } from "../src/index.js";
|
|
5
|
+
import { toSourceText } from "./utils.js";
|
|
6
|
+
it("works", () => {
|
|
7
|
+
expect(toSourceText(_$createComponent(ArrayExpression, {
|
|
8
|
+
jsValue: [1, 2, 3]
|
|
9
|
+
}))).toBe(d`
|
|
10
|
+
[1, 2, 3]
|
|
11
|
+
`);
|
|
12
|
+
expect(toSourceText(_$createComponent(ArrayExpression, {
|
|
13
|
+
get jsValue() {
|
|
14
|
+
return [1, 2, 3, "foo".repeat(10)];
|
|
15
|
+
}
|
|
16
|
+
}), {
|
|
17
|
+
printWidth: 20
|
|
18
|
+
})).toBe(d`
|
|
19
|
+
[
|
|
20
|
+
1,
|
|
21
|
+
2,
|
|
22
|
+
3,
|
|
23
|
+
"foofoofoofoofoofoofoofoofoofoo"
|
|
24
|
+
]
|
|
25
|
+
`);
|
|
26
|
+
});
|
|
27
|
+
it("accepts children", () => {
|
|
28
|
+
expect(toSourceText(_$createComponent(ArrayExpression, {
|
|
29
|
+
jsValue: [1, 2, 3],
|
|
30
|
+
get children() {
|
|
31
|
+
return _$createComponent(ArrayExpression, {
|
|
32
|
+
jsValue: [4, 5, 6]
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}))).toBe(d`
|
|
36
|
+
[1, 2, 3, [4, 5, 6]]
|
|
37
|
+
`);
|
|
38
|
+
});
|
|
39
|
+
it("accepts only children", () => {
|
|
40
|
+
expect(toSourceText(_$createComponent(ArrayExpression, {
|
|
41
|
+
get children() {
|
|
42
|
+
return _$createComponent(ArrayExpression, {
|
|
43
|
+
jsValue: [4, 5, 6]
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}))).toBe(d`
|
|
47
|
+
[[4, 5, 6]]
|
|
48
|
+
`);
|
|
49
|
+
});
|
|
50
|
+
it("renders a falsy jsValue", () => {
|
|
51
|
+
expect(toSourceText(_$createComponent(ArrayExpression, {
|
|
52
|
+
jsValue: [undefined]
|
|
53
|
+
}))).toBe(d`
|
|
54
|
+
[undefined]
|
|
55
|
+
`);
|
|
56
|
+
});
|
|
57
|
+
it("renders a falsy jsValue with no leading comma", () => {
|
|
58
|
+
expect(toSourceText(_$createComponent(ArrayExpression, {
|
|
59
|
+
jsValue: [null]
|
|
60
|
+
}))).toBe(d`
|
|
61
|
+
[null]
|
|
62
|
+
`);
|
|
63
|
+
});
|
|
64
|
+
it("renders a falsy jsValue and children", () => {
|
|
65
|
+
expect(toSourceText(_$createComponent(ArrayExpression, {
|
|
66
|
+
jsValue: [false],
|
|
67
|
+
children: "\"Hello\""
|
|
68
|
+
}))).toBe(d`
|
|
69
|
+
[false, "Hello"]
|
|
70
|
+
`);
|
|
71
|
+
});
|
|
72
|
+
it("renders a falsy jsValue but not invisible children", () => {
|
|
73
|
+
expect(toSourceText(_$createComponent(ArrayExpression, {
|
|
74
|
+
jsValue: [false],
|
|
75
|
+
get children() {
|
|
76
|
+
return [null, undefined];
|
|
77
|
+
}
|
|
78
|
+
}))).toBe(d`
|
|
79
|
+
[false]
|
|
80
|
+
`);
|
|
81
|
+
});
|
|
82
|
+
it("renders a falsy jsValue and visible children", () => {
|
|
83
|
+
expect(toSourceText(_$createComponent(ArrayExpression, {
|
|
84
|
+
jsValue: [false],
|
|
85
|
+
children: "\"Hello\""
|
|
86
|
+
}))).toBe(d`
|
|
87
|
+
[false, "Hello"]
|
|
88
|
+
`);
|
|
89
|
+
});
|
|
90
|
+
it("renders a falsy jsValue and visible falsy children", () => {
|
|
91
|
+
expect(toSourceText(_$createComponent(ArrayExpression, {
|
|
92
|
+
jsValue: [false],
|
|
93
|
+
children: "false"
|
|
94
|
+
}))).toBe(d`
|
|
95
|
+
[false, false]
|
|
96
|
+
`);
|
|
97
|
+
});
|
|
98
|
+
it("renders a falsy jsValue but not invisible falsy children", () => {
|
|
99
|
+
expect(toSourceText(_$createComponent(ArrayExpression, {
|
|
100
|
+
jsValue: [false],
|
|
101
|
+
children: false
|
|
102
|
+
}))).toBe(d`
|
|
103
|
+
[false]
|
|
104
|
+
`);
|
|
105
|
+
});
|