@alloy-js/typescript 0.7.0 → 0.8.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/components/ArrayExpression.d.ts.map +1 -1
- package/dist/src/components/ArrayExpression.js +9 -3
- package/dist/src/components/ArrayExpression.js.map +1 -1
- package/dist/src/components/BlockScope.d.ts +13 -0
- package/dist/src/components/BlockScope.d.ts.map +1 -0
- package/dist/src/components/BlockScope.js +20 -0
- package/dist/src/components/BlockScope.js.map +1 -0
- package/dist/src/components/CallSignature.d.ts +38 -0
- package/dist/src/components/CallSignature.d.ts.map +1 -0
- package/dist/src/components/CallSignature.js +26 -0
- package/dist/src/components/CallSignature.js.map +1 -0
- package/dist/src/components/ClassDeclaration.d.ts +3 -4
- package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
- package/dist/src/components/ClassDeclaration.js +99 -41
- package/dist/src/components/ClassDeclaration.js.map +1 -1
- package/dist/src/components/Declaration.d.ts +21 -8
- package/dist/src/components/Declaration.d.ts.map +1 -1
- package/dist/src/components/Declaration.js +39 -21
- package/dist/src/components/Declaration.js.map +1 -1
- package/dist/src/components/EnumDeclaration.d.ts.map +1 -1
- package/dist/src/components/EnumDeclaration.js +18 -6
- package/dist/src/components/EnumDeclaration.js.map +1 -1
- package/dist/src/components/EnumMember.d.ts +8 -0
- package/dist/src/components/EnumMember.d.ts.map +1 -1
- package/dist/src/components/EnumMember.js +27 -5
- package/dist/src/components/EnumMember.js.map +1 -1
- package/dist/src/components/FunctionCallExpression.js +1 -1
- package/dist/src/components/FunctionCallExpression.js.map +1 -1
- package/dist/src/components/FunctionDeclaration.d.ts +21 -13
- package/dist/src/components/FunctionDeclaration.d.ts.map +1 -1
- package/dist/src/components/FunctionDeclaration.js +79 -45
- package/dist/src/components/FunctionDeclaration.js.map +1 -1
- package/dist/src/components/IfStatement.d.ts +25 -0
- package/dist/src/components/IfStatement.d.ts.map +1 -0
- package/dist/src/components/IfStatement.js +34 -0
- package/dist/src/components/IfStatement.js.map +1 -0
- package/dist/src/components/Interface.d.ts +10 -2
- package/dist/src/components/Interface.d.ts.map +1 -1
- package/dist/src/components/Interface.js +66 -6
- package/dist/src/components/Interface.js.map +1 -1
- package/dist/src/components/JSDoc.d.ts.map +1 -1
- package/dist/src/components/JSDoc.js +1 -5
- package/dist/src/components/JSDoc.js.map +1 -1
- package/dist/src/components/JSDocParam.d.ts +22 -0
- package/dist/src/components/JSDocParam.d.ts.map +1 -0
- package/dist/src/components/JSDocParam.js +121 -0
- package/dist/src/components/JSDocParam.js.map +1 -0
- package/dist/src/components/ObjectExpression.d.ts.map +1 -1
- package/dist/src/components/ObjectExpression.js +9 -2
- package/dist/src/components/ObjectExpression.js.map +1 -1
- package/dist/src/components/PropertyName.d.ts +19 -0
- package/dist/src/components/PropertyName.d.ts.map +1 -0
- package/dist/src/components/PropertyName.js +36 -0
- package/dist/src/components/PropertyName.js.map +1 -0
- package/dist/src/components/SingleLineCommentBlock.d.ts +10 -0
- package/dist/src/components/SingleLineCommentBlock.d.ts.map +1 -0
- package/dist/src/components/SingleLineCommentBlock.js +20 -0
- package/dist/src/components/SingleLineCommentBlock.js.map +1 -0
- package/dist/src/components/SourceFile.d.ts +6 -0
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +31 -0
- package/dist/src/components/SourceFile.js.map +1 -1
- package/dist/src/components/SwitchStatement.d.ts +31 -0
- package/dist/src/components/SwitchStatement.d.ts.map +1 -0
- package/dist/src/components/SwitchStatement.js +48 -0
- package/dist/src/components/SwitchStatement.js.map +1 -0
- package/dist/src/components/TypeDeclaration.d.ts.map +1 -1
- package/dist/src/components/TypeDeclaration.js +16 -3
- package/dist/src/components/TypeDeclaration.js.map +1 -1
- package/dist/src/components/VarDeclaration.d.ts +1 -1
- package/dist/src/components/VarDeclaration.d.ts.map +1 -1
- package/dist/src/components/VarDeclaration.js +19 -6
- package/dist/src/components/VarDeclaration.js.map +1 -1
- 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 -0
- package/dist/src/components/index.js.map +1 -1
- package/dist/src/components/stc/index.d.ts +35 -112
- package/dist/src/components/stc/index.d.ts.map +1 -1
- package/dist/src/components/stc/index.js +8 -1
- package/dist/src/components/stc/index.js.map +1 -1
- package/dist/src/context/index.d.ts +2 -0
- package/dist/src/context/index.d.ts.map +1 -0
- package/dist/src/context/index.js +1 -0
- package/dist/src/context/index.js.map +1 -0
- package/dist/src/context/private-scope.d.ts +18 -0
- package/dist/src/context/private-scope.d.ts.map +1 -0
- package/dist/src/context/private-scope.js +9 -0
- package/dist/src/context/private-scope.js.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/parameter-descriptor.d.ts +60 -0
- package/dist/src/parameter-descriptor.d.ts.map +1 -0
- package/dist/src/parameter-descriptor.js +1 -0
- package/dist/src/parameter-descriptor.js.map +1 -0
- package/dist/src/symbols/reference.d.ts.map +1 -1
- package/dist/src/symbols/reference.js +50 -12
- package/dist/src/symbols/reference.js.map +1 -1
- package/dist/src/symbols/ts-member-scope.d.ts +1 -1
- package/dist/src/symbols/ts-member-scope.d.ts.map +1 -1
- package/dist/src/symbols/ts-member-scope.js +2 -0
- package/dist/src/symbols/ts-member-scope.js.map +1 -1
- package/dist/src/symbols/ts-output-symbol.d.ts +7 -4
- package/dist/src/symbols/ts-output-symbol.d.ts.map +1 -1
- package/dist/src/symbols/ts-output-symbol.js +11 -2
- package/dist/src/symbols/ts-output-symbol.js.map +1 -1
- package/dist/src/utils.d.ts +7 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +17 -0
- package/dist/src/utils.js.map +1 -1
- package/dist/test/block-scope.test.d.ts +2 -0
- package/dist/test/block-scope.test.d.ts.map +1 -0
- package/dist/test/enum-jsdoc.test.d.ts +2 -0
- package/dist/test/enum-jsdoc.test.d.ts.map +1 -0
- package/dist/test/function-declaration-jsdoc.test.d.ts +2 -0
- package/dist/test/function-declaration-jsdoc.test.d.ts.map +1 -0
- package/dist/test/if-statement.test.d.ts +2 -0
- package/dist/test/if-statement.test.d.ts.map +1 -0
- package/dist/test/interface-jsdoc.test.d.ts +2 -0
- package/dist/test/interface-jsdoc.test.d.ts.map +1 -0
- package/dist/test/jscomment.test.d.ts +2 -0
- package/dist/test/jscomment.test.d.ts.map +1 -0
- package/dist/test/jsdoc.test.d.ts.map +1 -1
- package/dist/test/jsdocparam.test.d.ts +2 -0
- package/dist/test/jsdocparam.test.d.ts.map +1 -0
- package/dist/test/name-conflict.test.d.ts +2 -0
- package/dist/test/name-conflict.test.d.ts.map +1 -0
- package/dist/test/package-json.test.d.ts +2 -0
- package/dist/test/package-json.test.d.ts.map +1 -0
- package/dist/test/source-file.test.d.ts +2 -0
- package/dist/test/source-file.test.d.ts.map +1 -0
- package/dist/test/switch-statement.test.d.ts +2 -0
- package/dist/test/switch-statement.test.d.ts.map +1 -0
- package/dist/test/var-declaration-jsdoc.test.d.ts +2 -0
- package/dist/test/var-declaration-jsdoc.test.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/components/ArrayExpression.tsx +13 -12
- package/src/components/BlockScope.tsx +31 -0
- package/src/components/CallSignature.tsx +67 -0
- package/src/components/ClassDeclaration.tsx +103 -50
- package/src/components/Declaration.tsx +72 -27
- package/src/components/EnumDeclaration.tsx +26 -18
- package/src/components/EnumMember.tsx +24 -4
- package/src/components/FunctionCallExpression.tsx +1 -1
- package/src/components/FunctionDeclaration.tsx +106 -82
- package/src/components/IfStatement.tsx +51 -0
- package/src/components/Interface.tsx +61 -14
- package/src/components/JSDoc.tsx +1 -10
- package/src/components/JSDocParam.tsx +115 -0
- package/src/components/ObjectExpression.tsx +7 -2
- package/src/components/PropertyName.tsx +50 -0
- package/src/components/SingleLineCommentBlock.tsx +21 -0
- package/src/components/SourceFile.tsx +29 -0
- package/src/components/SwitchStatement.tsx +78 -0
- package/src/components/TypeDeclaration.tsx +11 -4
- package/src/components/VarDeclaration.tsx +19 -11
- package/src/components/index.ts +7 -0
- package/src/components/stc/index.ts +8 -1
- package/src/context/index.ts +1 -0
- package/src/context/private-scope.ts +23 -0
- package/src/index.ts +1 -0
- package/src/parameter-descriptor.ts +71 -0
- package/src/symbols/reference.ts +70 -18
- package/src/symbols/ts-member-scope.ts +6 -2
- package/src/symbols/ts-output-symbol.ts +24 -11
- package/src/utils.ts +33 -0
- package/temp/api.json +3816 -1925
- package/test/array.test.tsx +60 -0
- package/test/basic.test.tsx +2 -2
- package/test/block-scope.test.tsx +29 -0
- package/test/class.test.tsx +173 -5
- package/test/enum-jsdoc.test.tsx +74 -0
- package/test/enum.test.tsx +50 -3
- package/test/function-call-expression.test.tsx +5 -2
- package/test/function-declaration-jsdoc.test.tsx +89 -0
- package/test/function-declaration.test.tsx +13 -9
- package/test/if-statement.test.tsx +28 -0
- package/test/interface-jsdoc.test.tsx +164 -0
- package/test/interface.test.tsx +14 -0
- package/test/jscomment.test.tsx +104 -0
- package/test/jsdoc.test.tsx +9 -15
- package/test/jsdocparam.test.tsx +188 -0
- package/test/name-conflict.test.tsx +105 -0
- package/test/name-policy.test.tsx +1 -1
- package/test/package-json.test.tsx +93 -0
- package/test/reference.test.tsx +6 -2
- package/test/source-file.test.tsx +38 -0
- package/test/switch-statement.test.tsx +50 -0
- package/test/value-expression.test.tsx +9 -0
- package/test/var-declaration-jsdoc.test.tsx +70 -0
- package/test/var-declaration.test.tsx +1 -1
- package/tsconfig.json +1 -8
- package/vitest.config.ts +2 -10
- package/dist/src/components/JSDocParagraph.d.ts +0 -10
- package/dist/src/components/JSDocParagraph.d.ts.map +0 -1
- package/dist/src/components/JSDocParagraph.js +0 -23
- package/dist/src/components/JSDocParagraph.js.map +0 -1
- package/src/components/JSDocParagraph.tsx +0 -35
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Output, render } from "@alloy-js/core";
|
|
2
|
+
import "@alloy-js/core/testing";
|
|
3
|
+
import { it } from "vitest";
|
|
4
|
+
import { PackageJsonFile } from "../src/components/PackageJson.jsx";
|
|
5
|
+
import { assertFileContents } from "./utils.js";
|
|
6
|
+
|
|
7
|
+
it("creates a simple package.json", () => {
|
|
8
|
+
const res = render(
|
|
9
|
+
<Output>
|
|
10
|
+
<PackageJsonFile name="test" version="1.0.0" />
|
|
11
|
+
</Output>,
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
assertFileContents(res, {
|
|
15
|
+
"package.json": `
|
|
16
|
+
{
|
|
17
|
+
"name": "test",
|
|
18
|
+
"version": "1.0.0",
|
|
19
|
+
"type": "module"
|
|
20
|
+
}
|
|
21
|
+
`,
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("makes a complex package.json", () => {
|
|
26
|
+
const res = render(
|
|
27
|
+
<Output>
|
|
28
|
+
<PackageJsonFile
|
|
29
|
+
name="test"
|
|
30
|
+
version="1.0.0"
|
|
31
|
+
author="Brian Terlson"
|
|
32
|
+
license="MIT"
|
|
33
|
+
description="A test package!"
|
|
34
|
+
homepage="https://example.com"
|
|
35
|
+
repository="https://github.com/alloy-project/alloy"
|
|
36
|
+
keywords={["test", "package"]}
|
|
37
|
+
type="commonjs"
|
|
38
|
+
scripts={{
|
|
39
|
+
build: "tsc -p .",
|
|
40
|
+
test: "vitest run",
|
|
41
|
+
"test:watch": "vitest -w",
|
|
42
|
+
}}
|
|
43
|
+
dependencies={{
|
|
44
|
+
"@alloy-js/core": "^0.1.0",
|
|
45
|
+
"@alloy-js/typescript": "^0.1.0",
|
|
46
|
+
}}
|
|
47
|
+
devDependencies={{
|
|
48
|
+
typescript: "^5.5.2",
|
|
49
|
+
}}
|
|
50
|
+
exports={{
|
|
51
|
+
".": "./lib/index.js",
|
|
52
|
+
"./complex": {
|
|
53
|
+
main: "./lib/index.js",
|
|
54
|
+
export: "./lib/index.mjs",
|
|
55
|
+
},
|
|
56
|
+
}}
|
|
57
|
+
/>
|
|
58
|
+
</Output>,
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
assertFileContents(res, {
|
|
62
|
+
"package.json": `
|
|
63
|
+
{
|
|
64
|
+
"name": "test",
|
|
65
|
+
"version": "1.0.0",
|
|
66
|
+
"author": "Brian Terlson",
|
|
67
|
+
"description": "A test package!",
|
|
68
|
+
"license": "MIT",
|
|
69
|
+
"homepage": "https://example.com",
|
|
70
|
+
"type": "commonjs",
|
|
71
|
+
"dependencies": {
|
|
72
|
+
"@alloy-js/core": "^0.1.0",
|
|
73
|
+
"@alloy-js/typescript": "^0.1.0"
|
|
74
|
+
},
|
|
75
|
+
"devDependencies": {
|
|
76
|
+
"typescript": "^5.5.2"
|
|
77
|
+
},
|
|
78
|
+
"scripts": {
|
|
79
|
+
"build": "tsc -p .",
|
|
80
|
+
"test": "vitest run",
|
|
81
|
+
"test:watch": "vitest -w"
|
|
82
|
+
},
|
|
83
|
+
"exports": {
|
|
84
|
+
".": "./lib/index.js",
|
|
85
|
+
"./complex": {
|
|
86
|
+
"main": "./lib/index.js",
|
|
87
|
+
"export": "./lib/index.mjs"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
`,
|
|
92
|
+
});
|
|
93
|
+
});
|
package/test/reference.test.tsx
CHANGED
|
@@ -9,7 +9,9 @@ it("works with back references", () => {
|
|
|
9
9
|
const res = render(
|
|
10
10
|
<Output>
|
|
11
11
|
<ts.SourceFile path="test1.ts">
|
|
12
|
-
<Declaration name="foo"
|
|
12
|
+
<Declaration name="foo" refkey={refkey("foo")}>
|
|
13
|
+
const foo = 1;
|
|
14
|
+
</Declaration>
|
|
13
15
|
</ts.SourceFile>
|
|
14
16
|
|
|
15
17
|
<ts.SourceFile path="test2.ts">
|
|
@@ -37,7 +39,9 @@ it("works with forward references", () => {
|
|
|
37
39
|
const v = <Reference refkey={refkey("foo")} />;
|
|
38
40
|
</ts.SourceFile>
|
|
39
41
|
<ts.SourceFile path="test1.ts">
|
|
40
|
-
<Declaration name="foo"
|
|
42
|
+
<Declaration name="foo" refkey={refkey("foo")}>
|
|
43
|
+
const foo = 1;
|
|
44
|
+
</Declaration>
|
|
41
45
|
</ts.SourceFile>
|
|
42
46
|
</Output>,
|
|
43
47
|
);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Output, render } from "@alloy-js/core";
|
|
2
|
+
import { d } from "@alloy-js/core/testing";
|
|
3
|
+
import { expect, it } from "vitest";
|
|
4
|
+
import { SourceFile } from "../src/components/SourceFile.jsx";
|
|
5
|
+
|
|
6
|
+
it("Includes header", () => {
|
|
7
|
+
const tree = render(
|
|
8
|
+
<Output>
|
|
9
|
+
<SourceFile path="hi.ts" headerComment="This is a header">
|
|
10
|
+
hello!
|
|
11
|
+
</SourceFile>
|
|
12
|
+
</Output>,
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
expect(tree.contents[0].contents).toEqual(d`
|
|
16
|
+
// This is a header
|
|
17
|
+
|
|
18
|
+
hello!`);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("Line wraps a header", () => {
|
|
22
|
+
const tree = render(
|
|
23
|
+
<Output>
|
|
24
|
+
<SourceFile
|
|
25
|
+
path="hi.ts"
|
|
26
|
+
headerComment="This is a very long header that is very long and should be wrapped. Meaning, it should be split into multiple lines."
|
|
27
|
+
>
|
|
28
|
+
hello!
|
|
29
|
+
</SourceFile>
|
|
30
|
+
</Output>,
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
expect(tree.contents[0].contents).toEqual(d`
|
|
34
|
+
// This is a very long header that is very long and should be wrapped. Meaning,
|
|
35
|
+
// it should be split into multiple lines.
|
|
36
|
+
|
|
37
|
+
hello!`);
|
|
38
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { List } from "@alloy-js/core";
|
|
2
|
+
import { d } from "@alloy-js/core/testing";
|
|
3
|
+
import { expect, it } from "vitest";
|
|
4
|
+
import {
|
|
5
|
+
CaseClause,
|
|
6
|
+
SwitchStatement,
|
|
7
|
+
} from "../src/components/SwitchStatement.jsx";
|
|
8
|
+
import { toSourceText } from "./utils.jsx";
|
|
9
|
+
|
|
10
|
+
it("handles various cases", () => {
|
|
11
|
+
const text = toSourceText(
|
|
12
|
+
<SwitchStatement expression="x">
|
|
13
|
+
<List hardline>
|
|
14
|
+
<CaseClause expression={'"test"'}>// expression</CaseClause>
|
|
15
|
+
<CaseClause jsValue={"test"}>// jsValue</CaseClause>
|
|
16
|
+
<CaseClause expression={"'break'"} break>
|
|
17
|
+
// break
|
|
18
|
+
</CaseClause>
|
|
19
|
+
<CaseClause expression={"'block'"} block>
|
|
20
|
+
// block
|
|
21
|
+
</CaseClause>
|
|
22
|
+
<CaseClause expression={"'breakblock'"} break block>
|
|
23
|
+
// block
|
|
24
|
+
</CaseClause>
|
|
25
|
+
<CaseClause default>// default</CaseClause>
|
|
26
|
+
</List>
|
|
27
|
+
</SwitchStatement>,
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
expect(text).toBe(d`
|
|
31
|
+
switch (x) {
|
|
32
|
+
case "test":
|
|
33
|
+
// expression
|
|
34
|
+
case "test":
|
|
35
|
+
// jsValue
|
|
36
|
+
case 'break':
|
|
37
|
+
// break
|
|
38
|
+
break;
|
|
39
|
+
case 'block': {
|
|
40
|
+
// block
|
|
41
|
+
}
|
|
42
|
+
case 'breakblock': {
|
|
43
|
+
// block
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
default :
|
|
47
|
+
// default
|
|
48
|
+
}
|
|
49
|
+
`);
|
|
50
|
+
});
|
|
@@ -28,6 +28,15 @@ it.each([
|
|
|
28
28
|
}
|
|
29
29
|
`,
|
|
30
30
|
],
|
|
31
|
+
[
|
|
32
|
+
{ "mangled-name": 1, "@pagination": 2 },
|
|
33
|
+
d`
|
|
34
|
+
{
|
|
35
|
+
"mangled-name": 1,
|
|
36
|
+
"@pagination": 2,
|
|
37
|
+
}
|
|
38
|
+
`,
|
|
39
|
+
],
|
|
31
40
|
])("works - %o => %s", (jsValue, expectedSource) => {
|
|
32
41
|
expect(toSourceText(<ValueExpression jsValue={jsValue} />)).toBe(
|
|
33
42
|
expectedSource,
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { d } from "@alloy-js/core/testing";
|
|
2
|
+
import { expect, it } from "vitest";
|
|
3
|
+
import * as ts from "../src/index.js";
|
|
4
|
+
import { toSourceText } from "./utils.js";
|
|
5
|
+
|
|
6
|
+
it("renders a variable declaration with documentation", () => {
|
|
7
|
+
const res = toSourceText(
|
|
8
|
+
<>
|
|
9
|
+
<ts.VarDeclaration
|
|
10
|
+
name="myVar"
|
|
11
|
+
const
|
|
12
|
+
doc="This is a variable documentation"
|
|
13
|
+
>
|
|
14
|
+
123
|
|
15
|
+
</ts.VarDeclaration>
|
|
16
|
+
;
|
|
17
|
+
</>,
|
|
18
|
+
);
|
|
19
|
+
expect(res).toEqual(d`
|
|
20
|
+
/**
|
|
21
|
+
* This is a variable documentation
|
|
22
|
+
**/
|
|
23
|
+
const myVar = 123;
|
|
24
|
+
`);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("renders a let declaration with documentation", () => {
|
|
28
|
+
const res = toSourceText(
|
|
29
|
+
<>
|
|
30
|
+
<ts.VarDeclaration
|
|
31
|
+
let
|
|
32
|
+
name="counter"
|
|
33
|
+
doc="A counter variable that can be changed"
|
|
34
|
+
type="number"
|
|
35
|
+
>
|
|
36
|
+
0
|
|
37
|
+
</ts.VarDeclaration>
|
|
38
|
+
;
|
|
39
|
+
</>,
|
|
40
|
+
);
|
|
41
|
+
expect(res).toEqual(d`
|
|
42
|
+
/**
|
|
43
|
+
* A counter variable that can be changed
|
|
44
|
+
**/
|
|
45
|
+
let counter: number = 0;
|
|
46
|
+
`);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("renders an exported variable declaration with documentation", () => {
|
|
50
|
+
const res = toSourceText(
|
|
51
|
+
<>
|
|
52
|
+
<ts.VarDeclaration
|
|
53
|
+
export
|
|
54
|
+
name="API_URL"
|
|
55
|
+
const
|
|
56
|
+
doc="The base URL for API calls"
|
|
57
|
+
type="string"
|
|
58
|
+
>
|
|
59
|
+
"https://api.example.com"
|
|
60
|
+
</ts.VarDeclaration>
|
|
61
|
+
;
|
|
62
|
+
</>,
|
|
63
|
+
);
|
|
64
|
+
expect(res).toEqual(d`
|
|
65
|
+
/**
|
|
66
|
+
* The base URL for API calls
|
|
67
|
+
**/
|
|
68
|
+
export const API_URL: string = "https://api.example.com";
|
|
69
|
+
`);
|
|
70
|
+
});
|
package/tsconfig.json
CHANGED
|
@@ -6,13 +6,6 @@
|
|
|
6
6
|
"outDir": "dist"
|
|
7
7
|
},
|
|
8
8
|
"references": [{ "path": "../core" }],
|
|
9
|
-
"include": [
|
|
10
|
-
"src/**/*.ts",
|
|
11
|
-
"src/**/*.tsx",
|
|
12
|
-
"test/**/*.ts",
|
|
13
|
-
"test/**/*.tsx",
|
|
14
|
-
"../core/src/components/Block.tsx",
|
|
15
|
-
"../core/src/components/StatementList.tsx"
|
|
16
|
-
],
|
|
9
|
+
"include": ["src/**/*.ts", "src/**/*.tsx", "test/**/*.ts", "test/**/*.tsx"],
|
|
17
10
|
"exclude": ["node_modules", "dist"]
|
|
18
11
|
}
|
package/vitest.config.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import alloyPlugin from "@alloy-js/rollup-plugin";
|
|
2
2
|
import { defineConfig } from "vitest/config";
|
|
3
3
|
|
|
4
4
|
export default defineConfig({
|
|
@@ -6,13 +6,5 @@ export default defineConfig({
|
|
|
6
6
|
jsx: "preserve",
|
|
7
7
|
sourcemap: "both",
|
|
8
8
|
},
|
|
9
|
-
plugins: [
|
|
10
|
-
babel({
|
|
11
|
-
inputSourceMap: true as any,
|
|
12
|
-
sourceMaps: "both",
|
|
13
|
-
babelHelpers: "bundled",
|
|
14
|
-
extensions: [".ts", ".tsx"],
|
|
15
|
-
presets: ["@babel/preset-typescript", "@alloy-js/babel-preset"],
|
|
16
|
-
}),
|
|
17
|
-
],
|
|
9
|
+
plugins: [alloyPlugin()],
|
|
18
10
|
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Children } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
export interface JSDocParagraphProps {
|
|
3
|
-
children: Children;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Create a paragraph in a JSDoc comment. The text of this component is word
|
|
7
|
-
* wrapped.
|
|
8
|
-
*/
|
|
9
|
-
export declare function JSDocParagraph(props: JSDocParagraphProps): Children;
|
|
10
|
-
//# sourceMappingURL=JSDocParagraph.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"JSDocParagraph.d.ts","sourceRoot":"","sources":["../../../src/components/JSDocParagraph.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,YAuBxD"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { childrenArray, computed } from "@alloy-js/core";
|
|
3
|
-
/**
|
|
4
|
-
* Create a paragraph in a JSDoc comment. The text of this component is word
|
|
5
|
-
* wrapped.
|
|
6
|
-
*/
|
|
7
|
-
export function JSDocParagraph(props) {
|
|
8
|
-
const brokenChildren = computed(() => {
|
|
9
|
-
const children = childrenArray(() => props.children);
|
|
10
|
-
return children.map(child => {
|
|
11
|
-
if (typeof child === "string") {
|
|
12
|
-
return child.trim().split(/\s+/).map(word => [word, _$createIntrinsic("br", {})]);
|
|
13
|
-
}
|
|
14
|
-
return child;
|
|
15
|
-
}).flat(2);
|
|
16
|
-
});
|
|
17
|
-
return _$createIntrinsic("fill", {
|
|
18
|
-
get children() {
|
|
19
|
-
return brokenChildren.value;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=JSDocParagraph.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"JSDocParagraph.js","names":["childrenArray","computed","JSDocParagraph","props","brokenChildren","children","map","child","trim","split","word","_$createIntrinsic","flat","value"],"sources":["../../../src/components/JSDocParagraph.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,gBAAgB;AAOxD;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACC,KAA0B,EAAE;EACzD,MAAMC,cAAc,GAAGH,QAAQ,CAAC,MAAM;IACpC,MAAMI,QAAQ,GAAGL,aAAa,CAAC,MAAMG,KAAK,CAACE,QAAQ,CAAC;IACpD,OAAOA,QAAQ,CACZC,GAAG,CAAEC,KAAK,IAAK;MACd,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAOA,KAAK,CACTC,IAAI,CAAC,CAAC,CACNC,KAAK,CAAC,KAAK,CAAC,CACZH,GAAG,CAAEI,IAAI,KAELA,IAAI,EAAAC,iBAAA,WAGR,CAAC;MACN;MAEA,OAAOJ,KAAK;IACd,CAAC,CAAC,CACDK,IAAI,CAAC,CAAC,CAAC;EACZ,CAAC,CAAC;EAEF,OAAAD,iBAAA;IAAA,IAAAN,SAAA;MAAA,OAAcD,cAAc,CAACS,KAAK;IAAA;EAAA;AACpC","ignoreList":[]}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { childrenArray, computed } from "@alloy-js/core";
|
|
2
|
-
import { Children } from "@alloy-js/core/jsx-runtime";
|
|
3
|
-
|
|
4
|
-
export interface JSDocParagraphProps {
|
|
5
|
-
children: Children;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Create a paragraph in a JSDoc comment. The text of this component is word
|
|
10
|
-
* wrapped.
|
|
11
|
-
*/
|
|
12
|
-
export function JSDocParagraph(props: JSDocParagraphProps) {
|
|
13
|
-
const brokenChildren = computed(() => {
|
|
14
|
-
const children = childrenArray(() => props.children);
|
|
15
|
-
return children
|
|
16
|
-
.map((child) => {
|
|
17
|
-
if (typeof child === "string") {
|
|
18
|
-
return child
|
|
19
|
-
.trim()
|
|
20
|
-
.split(/\s+/)
|
|
21
|
-
.map((word) => (
|
|
22
|
-
<>
|
|
23
|
-
{word}
|
|
24
|
-
<br />
|
|
25
|
-
</>
|
|
26
|
-
));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return child;
|
|
30
|
-
})
|
|
31
|
-
.flat(2);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
return <fill>{brokenChildren.value}</fill>;
|
|
35
|
-
}
|