@alloy-js/typescript 0.20.0-dev.1 → 0.20.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/builtins/index.js +2 -1
- package/dist/src/builtins/index.js.map +1 -0
- package/dist/src/builtins/node.js +2 -1
- package/dist/src/builtins/node.js.map +1 -0
- package/dist/src/components/ArrayExpression.js +2 -1
- package/dist/src/components/ArrayExpression.js.map +1 -0
- package/dist/src/components/ArrowFunction.js +2 -1
- package/dist/src/components/ArrowFunction.js.map +1 -0
- package/dist/src/components/BarrelFile.js +2 -1
- package/dist/src/components/BarrelFile.js.map +1 -0
- package/dist/src/components/BlockScope.js +2 -1
- package/dist/src/components/BlockScope.js.map +1 -0
- package/dist/src/components/CallSignature.js +2 -1
- package/dist/src/components/CallSignature.js.map +1 -0
- package/dist/src/components/ClassDeclaration.js +2 -1
- package/dist/src/components/ClassDeclaration.js.map +1 -0
- package/dist/src/components/CommaList.js +2 -1
- package/dist/src/components/CommaList.js.map +1 -0
- package/dist/src/components/Declaration.js +2 -1
- package/dist/src/components/Declaration.js.map +1 -0
- package/dist/src/components/EnumDeclaration.js +2 -1
- package/dist/src/components/EnumDeclaration.js.map +1 -0
- package/dist/src/components/EnumMember.js +2 -1
- package/dist/src/components/EnumMember.js.map +1 -0
- package/dist/src/components/ExportStatement.js +2 -1
- package/dist/src/components/ExportStatement.js.map +1 -0
- package/dist/src/components/FunctionBase.js +2 -1
- package/dist/src/components/FunctionBase.js.map +1 -0
- package/dist/src/components/FunctionCallExpression.js +2 -1
- package/dist/src/components/FunctionCallExpression.js.map +1 -0
- package/dist/src/components/FunctionDeclaration.js +2 -1
- package/dist/src/components/FunctionDeclaration.js.map +1 -0
- package/dist/src/components/FunctionExpression.js +2 -1
- package/dist/src/components/FunctionExpression.js.map +1 -0
- package/dist/src/components/FunctionType.js +2 -1
- package/dist/src/components/FunctionType.js.map +1 -0
- package/dist/src/components/IfStatement.js +2 -1
- package/dist/src/components/IfStatement.js.map +1 -0
- package/dist/src/components/ImportStatement.js +2 -1
- package/dist/src/components/ImportStatement.js.map +1 -0
- package/dist/src/components/Interface.js +2 -1
- package/dist/src/components/Interface.js.map +1 -0
- package/dist/src/components/InterfaceMethod.js +2 -1
- package/dist/src/components/InterfaceMethod.js.map +1 -0
- package/dist/src/components/JSDoc.js +2 -1
- package/dist/src/components/JSDoc.js.map +1 -0
- package/dist/src/components/JSDocComment.js +2 -1
- package/dist/src/components/JSDocComment.js.map +1 -0
- package/dist/src/components/JSDocExample.js +2 -1
- package/dist/src/components/JSDocExample.js.map +1 -0
- package/dist/src/components/JSDocParam.js +2 -1
- package/dist/src/components/JSDocParam.js.map +1 -0
- package/dist/src/components/LexicalScope.js +2 -1
- package/dist/src/components/LexicalScope.js.map +1 -0
- package/dist/src/components/MemberDeclaration.js +2 -1
- package/dist/src/components/MemberDeclaration.js.map +1 -0
- package/dist/src/components/MemberExpression.js +2 -1
- package/dist/src/components/MemberExpression.js.map +1 -0
- package/dist/src/components/MemberScope.js +2 -1
- package/dist/src/components/MemberScope.js.map +1 -0
- package/dist/src/components/NewExpression.js +2 -1
- package/dist/src/components/NewExpression.js.map +1 -0
- package/dist/src/components/ObjectExpression.js +2 -1
- package/dist/src/components/ObjectExpression.js.map +1 -0
- package/dist/src/components/PackageDirectory.js +2 -1
- package/dist/src/components/PackageDirectory.js.map +1 -0
- package/dist/src/components/PackageJson.js +2 -1
- package/dist/src/components/PackageJson.js.map +1 -0
- package/dist/src/components/PropertyName.js +2 -1
- package/dist/src/components/PropertyName.js.map +1 -0
- package/dist/src/components/Reference.js +2 -1
- package/dist/src/components/Reference.js.map +1 -0
- package/dist/src/components/SingleLineCommentBlock.js +2 -1
- package/dist/src/components/SingleLineCommentBlock.js.map +1 -0
- package/dist/src/components/SourceFile.js +2 -1
- package/dist/src/components/SourceFile.js.map +1 -0
- package/dist/src/components/SwitchStatement.js +2 -1
- package/dist/src/components/SwitchStatement.js.map +1 -0
- package/dist/src/components/TsConfigJson.js +2 -1
- package/dist/src/components/TsConfigJson.js.map +1 -0
- package/dist/src/components/TypeDeclaration.js +2 -1
- package/dist/src/components/TypeDeclaration.js.map +1 -0
- package/dist/src/components/TypeRefContext.js +2 -1
- package/dist/src/components/TypeRefContext.js.map +1 -0
- package/dist/src/components/ValueExpression.js +2 -1
- package/dist/src/components/ValueExpression.js.map +1 -0
- package/dist/src/components/VarDeclaration.js +2 -1
- package/dist/src/components/VarDeclaration.js.map +1 -0
- package/dist/src/components/index.js +2 -1
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/components/interface/expression.test.js +2 -1
- package/dist/src/components/interface/expression.test.js.map +1 -0
- package/dist/src/components/stc/index.js +2 -1
- package/dist/src/components/stc/index.js.map +1 -0
- package/dist/src/context/index.js +2 -1
- package/dist/src/context/index.js.map +1 -0
- package/dist/src/context/type-ref-context.js +2 -1
- package/dist/src/context/type-ref-context.js.map +1 -0
- package/dist/src/create-package.js +2 -1
- package/dist/src/create-package.js.map +1 -0
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -0
- package/dist/src/name-conflict-resolver.js +2 -1
- package/dist/src/name-conflict-resolver.js.map +1 -0
- package/dist/src/name-policy.js +2 -1
- package/dist/src/name-policy.js.map +1 -0
- package/dist/src/parameter-descriptor.js +2 -1
- package/dist/src/parameter-descriptor.js.map +1 -0
- package/dist/src/source-directory-data.js +2 -1
- package/dist/src/source-directory-data.js.map +1 -0
- package/dist/src/symbols/index.js +2 -1
- package/dist/src/symbols/index.js.map +1 -0
- package/dist/src/symbols/reference.js +2 -1
- package/dist/src/symbols/reference.js.map +1 -0
- package/dist/src/symbols/scopes.js +2 -1
- package/dist/src/symbols/scopes.js.map +1 -0
- package/dist/src/symbols/ts-lexical-scope.js +2 -1
- package/dist/src/symbols/ts-lexical-scope.js.map +1 -0
- package/dist/src/symbols/ts-member-scope.js +2 -1
- package/dist/src/symbols/ts-member-scope.js.map +1 -0
- package/dist/src/symbols/ts-module-scope.js +2 -1
- package/dist/src/symbols/ts-module-scope.js.map +1 -0
- package/dist/src/symbols/ts-output-symbol.js +2 -1
- package/dist/src/symbols/ts-output-symbol.js.map +1 -0
- package/dist/src/symbols/ts-package-scope.js +2 -1
- package/dist/src/symbols/ts-package-scope.js.map +1 -0
- package/dist/src/utils.js +2 -1
- package/dist/src/utils.js.map +1 -0
- package/dist/test/array.test.js +2 -1
- package/dist/test/array.test.js.map +1 -0
- package/dist/test/arrow-function.test.js +2 -1
- package/dist/test/arrow-function.test.js.map +1 -0
- package/dist/test/barrel.test.js +26 -17
- package/dist/test/barrel.test.js.map +1 -0
- package/dist/test/basic.test.js +22 -26
- package/dist/test/basic.test.js.map +1 -0
- package/dist/test/block-scope.test.js +2 -1
- package/dist/test/block-scope.test.js.map +1 -0
- package/dist/test/class.test.js +20 -14
- package/dist/test/class.test.js.map +1 -0
- package/dist/test/enum-jsdoc.test.js +2 -1
- package/dist/test/enum-jsdoc.test.js.map +1 -0
- package/dist/test/enum.test.js +2 -1
- package/dist/test/enum.test.js.map +1 -0
- package/dist/test/externals.test.js +13 -16
- package/dist/test/externals.test.js.map +1 -0
- package/dist/test/function-call-expression.test.js +9 -8
- package/dist/test/function-call-expression.test.js.map +1 -0
- package/dist/test/function-declaration-jsdoc.test.js +2 -1
- package/dist/test/function-declaration-jsdoc.test.js.map +1 -0
- package/dist/test/function-declaration.test.js +2 -1
- package/dist/test/function-declaration.test.js.map +1 -0
- package/dist/test/function-expression.test.js +2 -1
- package/dist/test/function-expression.test.js.map +1 -0
- package/dist/test/function-type.test.js +2 -1
- package/dist/test/function-type.test.js.map +1 -0
- package/dist/test/if-statement.test.js +2 -1
- package/dist/test/if-statement.test.js.map +1 -0
- package/dist/test/imports.test.d.ts.map +1 -1
- package/dist/test/imports.test.js +62 -60
- package/dist/test/imports.test.js.map +1 -0
- package/dist/test/interface-jsdoc.test.js +2 -1
- package/dist/test/interface-jsdoc.test.js.map +1 -0
- package/dist/test/interface.test.js +2 -1
- package/dist/test/interface.test.js.map +1 -0
- package/dist/test/jscomment.test.js +2 -1
- package/dist/test/jscomment.test.js.map +1 -0
- package/dist/test/jsdoc.test.js +2 -1
- package/dist/test/jsdoc.test.js.map +1 -0
- package/dist/test/jsdocparam.test.js +2 -1
- package/dist/test/jsdocparam.test.js.map +1 -0
- package/dist/test/member-expression.test.js +8 -7
- package/dist/test/member-expression.test.js.map +1 -0
- package/dist/test/name-conflict.test.js +5 -7
- package/dist/test/name-conflict.test.js.map +1 -0
- package/dist/test/name-policy.test.js +9 -13
- package/dist/test/name-policy.test.js.map +1 -0
- package/dist/test/new-expression.test.js +6 -7
- package/dist/test/new-expression.test.js.map +1 -0
- package/dist/test/object.test.js +2 -1
- package/dist/test/object.test.js.map +1 -0
- package/dist/test/package-external.test.js +71 -66
- package/dist/test/package-external.test.js.map +1 -0
- package/dist/test/package-json.test.js +8 -10
- package/dist/test/package-json.test.js.map +1 -0
- package/dist/test/package.test.js +12 -12
- package/dist/test/package.test.js.map +1 -0
- package/dist/test/reference.test.js +8 -10
- package/dist/test/reference.test.js.map +1 -0
- package/dist/test/source-file.test.js +7 -10
- package/dist/test/source-file.test.js.map +1 -0
- package/dist/test/switch-statement.test.js +2 -1
- package/dist/test/switch-statement.test.js.map +1 -0
- package/dist/test/utils.js +6 -2
- package/dist/test/utils.js.map +1 -0
- package/dist/test/value-expression.test.js +2 -1
- package/dist/test/value-expression.test.js.map +1 -0
- package/dist/test/values.test.d.ts.map +1 -1
- package/dist/test/values.test.js +11 -8
- package/dist/test/values.test.js.map +1 -0
- package/dist/test/var-declaration-jsdoc.test.js +2 -1
- package/dist/test/var-declaration-jsdoc.test.js.map +1 -0
- package/dist/test/var-declaration.test.d.ts.map +1 -1
- package/dist/test/var-declaration.test.js +21 -12
- package/dist/test/var-declaration.test.js.map +1 -0
- package/dist/test/vitest.setup.js +2 -1
- package/dist/test/vitest.setup.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/test/barrel.test.tsx +24 -18
- package/test/basic.test.tsx +20 -29
- package/test/class.test.tsx +18 -14
- package/test/externals.test.tsx +11 -19
- package/test/function-call-expression.test.tsx +6 -7
- package/test/imports.test.tsx +57 -74
- package/test/member-expression.test.tsx +5 -13
- package/test/name-conflict.test.tsx +4 -7
- package/test/name-policy.test.tsx +7 -15
- package/test/new-expression.test.tsx +4 -7
- package/test/package-external.test.tsx +69 -73
- package/test/package-json.test.tsx +6 -11
- package/test/package.test.tsx +8 -11
- package/test/reference.test.tsx +6 -11
- package/test/source-file.test.tsx +5 -11
- package/test/utils.tsx +1 -1
- package/test/values.test.tsx +8 -8
- package/test/var-declaration.test.tsx +19 -20
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { Output, refkey
|
|
2
|
-
import { d } from "@alloy-js/core/testing";
|
|
1
|
+
import { Output, refkey } from "@alloy-js/core";
|
|
3
2
|
import { expect, it } from "vitest";
|
|
4
3
|
import * as ts from "../src/index.js";
|
|
5
|
-
import { findFile } from "./utils.js";
|
|
6
4
|
|
|
7
5
|
it("imports external packages", () => {
|
|
8
|
-
|
|
6
|
+
expect(
|
|
9
7
|
<Output>
|
|
10
8
|
<ts.PackageDirectory
|
|
11
9
|
name="greeting-lib"
|
|
@@ -41,52 +39,51 @@ it("imports external packages", () => {
|
|
|
41
39
|
</ts.SourceFile>
|
|
42
40
|
</ts.PackageDirectory>
|
|
43
41
|
</Output>,
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"typescript": "^5.5.2"
|
|
60
|
-
},
|
|
61
|
-
"exports": {
|
|
62
|
-
".": "./dist/ref.js"
|
|
42
|
+
).toRenderTo({
|
|
43
|
+
"consumer/package.json": `
|
|
44
|
+
{
|
|
45
|
+
"name": "consumer",
|
|
46
|
+
"version": "1.0.0",
|
|
47
|
+
"type": "module",
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"greeting-lib": "1.0.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"typescript": "^5.5.2"
|
|
53
|
+
},
|
|
54
|
+
"exports": {
|
|
55
|
+
".": "./dist/ref.js"
|
|
56
|
+
}
|
|
63
57
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
58
|
+
`,
|
|
59
|
+
"consumer/tsconfig.json": expect.anything(),
|
|
60
|
+
"greeting-lib/package.json": `
|
|
61
|
+
{
|
|
62
|
+
"name": "greeting-lib",
|
|
63
|
+
"version": "1.0.0",
|
|
64
|
+
"type": "module",
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"typescript": "^5.5.2"
|
|
67
|
+
},
|
|
68
|
+
"exports": {
|
|
69
|
+
".": "./dist/index.js"
|
|
70
|
+
}
|
|
77
71
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
72
|
+
`,
|
|
73
|
+
"greeting-lib/tsconfig.json": expect.anything(),
|
|
74
|
+
"greeting-lib/index.ts": expect.anything(),
|
|
75
|
+
"greeting-lib/greetings.ts": expect.anything(),
|
|
76
|
+
"greeting-lib/logGreetings.ts": expect.anything(),
|
|
77
|
+
"consumer/ref.ts": `
|
|
78
|
+
import { getGreeting } from "greeting-lib";
|
|
79
|
+
|
|
80
|
+
getGreeting();
|
|
81
|
+
`,
|
|
82
|
+
});
|
|
86
83
|
});
|
|
87
84
|
|
|
88
85
|
it("combines explicit dependencies with referenced dependencies", () => {
|
|
89
|
-
|
|
86
|
+
expect(
|
|
90
87
|
<Output>
|
|
91
88
|
<ts.PackageDirectory
|
|
92
89
|
name="greeting-lib"
|
|
@@ -129,31 +126,26 @@ it("combines explicit dependencies with referenced dependencies", () => {
|
|
|
129
126
|
</ts.SourceFile>
|
|
130
127
|
</ts.PackageDirectory>
|
|
131
128
|
</Output>,
|
|
132
|
-
)
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
"
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
"typescript": "^5.5.2"
|
|
149
|
-
},
|
|
150
|
-
"exports": {
|
|
151
|
-
".": "./dist/ref.js"
|
|
129
|
+
).toRenderTo({
|
|
130
|
+
"consumer/package.json": `
|
|
131
|
+
{
|
|
132
|
+
"name": "consumer",
|
|
133
|
+
"version": "1.0.0",
|
|
134
|
+
"type": "module",
|
|
135
|
+
"dependencies": {
|
|
136
|
+
"foo": "bar",
|
|
137
|
+
"greeting-lib": "1.0.0"
|
|
138
|
+
},
|
|
139
|
+
"devDependencies": {
|
|
140
|
+
"typescript": "^5.5.2"
|
|
141
|
+
},
|
|
142
|
+
"exports": {
|
|
143
|
+
".": "./dist/ref.js"
|
|
144
|
+
}
|
|
152
145
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
expect(greetingPkgJson.contents).toEqual(d`
|
|
146
|
+
`,
|
|
147
|
+
"consumer/tsconfig.json": expect.anything(),
|
|
148
|
+
"greeting-lib/package.json": `
|
|
157
149
|
{
|
|
158
150
|
"name": "greeting-lib",
|
|
159
151
|
"version": "1.0.0",
|
|
@@ -165,11 +157,15 @@ it("combines explicit dependencies with referenced dependencies", () => {
|
|
|
165
157
|
".": "./dist/index.js"
|
|
166
158
|
}
|
|
167
159
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
160
|
+
`,
|
|
161
|
+
"greeting-lib/tsconfig.json": expect.anything(),
|
|
162
|
+
"greeting-lib/index.ts": expect.anything(),
|
|
163
|
+
"greeting-lib/greetings.ts": expect.anything(),
|
|
164
|
+
"greeting-lib/logGreetings.ts": expect.anything(),
|
|
165
|
+
"consumer/ref.ts": `
|
|
171
166
|
import { getGreeting } from "greeting-lib";
|
|
172
167
|
|
|
173
168
|
getGreeting();
|
|
174
|
-
|
|
169
|
+
`,
|
|
170
|
+
});
|
|
175
171
|
});
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { Output
|
|
1
|
+
import { Output } from "@alloy-js/core";
|
|
2
2
|
import "@alloy-js/core/testing";
|
|
3
|
-
import { it } from "vitest";
|
|
3
|
+
import { expect, it } from "vitest";
|
|
4
4
|
import { PackageJsonFile } from "../src/components/PackageJson.jsx";
|
|
5
|
-
import { assertFileContents } from "./utils.js";
|
|
6
5
|
|
|
7
6
|
it("creates a simple package.json", () => {
|
|
8
|
-
|
|
7
|
+
expect(
|
|
9
8
|
<Output>
|
|
10
9
|
<PackageJsonFile name="test" version="1.0.0" />
|
|
11
10
|
</Output>,
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
assertFileContents(res, {
|
|
11
|
+
).toRenderTo({
|
|
15
12
|
"package.json": `
|
|
16
13
|
{
|
|
17
14
|
"name": "test",
|
|
@@ -23,7 +20,7 @@ it("creates a simple package.json", () => {
|
|
|
23
20
|
});
|
|
24
21
|
|
|
25
22
|
it("makes a complex package.json", () => {
|
|
26
|
-
|
|
23
|
+
expect(
|
|
27
24
|
<Output>
|
|
28
25
|
<PackageJsonFile
|
|
29
26
|
name="test"
|
|
@@ -56,9 +53,7 @@ it("makes a complex package.json", () => {
|
|
|
56
53
|
}}
|
|
57
54
|
/>
|
|
58
55
|
</Output>,
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
assertFileContents(res, {
|
|
56
|
+
).toRenderTo({
|
|
62
57
|
"package.json": `
|
|
63
58
|
{
|
|
64
59
|
"name": "test",
|
package/test/package.test.tsx
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { Output, refkey
|
|
1
|
+
import { Output, refkey } from "@alloy-js/core";
|
|
2
2
|
import "@alloy-js/core/testing";
|
|
3
|
-
import { it } from "vitest";
|
|
3
|
+
import { expect, it } from "vitest";
|
|
4
4
|
import * as ts from "../src/components/index.js";
|
|
5
5
|
import { PackageDirectory } from "../src/components/PackageDirectory.js";
|
|
6
|
-
import { assertFileContents } from "./utils.js";
|
|
7
6
|
|
|
8
7
|
it("exports source files", () => {
|
|
9
|
-
|
|
8
|
+
expect(
|
|
10
9
|
<Output>
|
|
11
10
|
<PackageDirectory name="greeting-js" path="." version="1.0.0">
|
|
12
11
|
<ts.SourceFile path="greeting.ts">
|
|
@@ -35,9 +34,7 @@ it("exports source files", () => {
|
|
|
35
34
|
<ts.BarrelFile export="." />
|
|
36
35
|
</PackageDirectory>
|
|
37
36
|
</Output>,
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
assertFileContents(res, {
|
|
37
|
+
).toRenderTo({
|
|
41
38
|
"greeting.ts": `
|
|
42
39
|
function getGreeting() {
|
|
43
40
|
return "Hello world!";
|
|
@@ -69,11 +66,12 @@ it("exports source files", () => {
|
|
|
69
66
|
}
|
|
70
67
|
}
|
|
71
68
|
`,
|
|
69
|
+
"tsconfig.json": expect.anything(),
|
|
72
70
|
});
|
|
73
71
|
});
|
|
74
72
|
|
|
75
73
|
it("combines ref'd exports with explicit exports", () => {
|
|
76
|
-
|
|
74
|
+
expect(
|
|
77
75
|
<Output>
|
|
78
76
|
<PackageDirectory
|
|
79
77
|
name="greeting-js"
|
|
@@ -94,9 +92,7 @@ it("combines ref'd exports with explicit exports", () => {
|
|
|
94
92
|
</ts.SourceFile>
|
|
95
93
|
</PackageDirectory>
|
|
96
94
|
</Output>,
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
assertFileContents(res, {
|
|
95
|
+
).toRenderTo({
|
|
100
96
|
"index.ts": `
|
|
101
97
|
export function printGreeting() {
|
|
102
98
|
console.log(greeting);
|
|
@@ -116,5 +112,6 @@ it("combines ref'd exports with explicit exports", () => {
|
|
|
116
112
|
}
|
|
117
113
|
}
|
|
118
114
|
`,
|
|
115
|
+
"tsconfig.json": expect.anything(),
|
|
119
116
|
});
|
|
120
117
|
});
|
package/test/reference.test.tsx
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { Output, refkey
|
|
1
|
+
import { Output, refkey } from "@alloy-js/core";
|
|
2
2
|
import "@alloy-js/core/testing";
|
|
3
|
-
import { it } from "vitest";
|
|
3
|
+
import { expect, it } from "vitest";
|
|
4
4
|
import * as ts from "../src/components/index.js";
|
|
5
5
|
import { Reference } from "../src/components/Reference.js";
|
|
6
|
-
import { assertFileContents } from "./utils.js";
|
|
7
6
|
|
|
8
7
|
it("works with back references", () => {
|
|
9
|
-
|
|
8
|
+
expect(
|
|
10
9
|
<Output>
|
|
11
10
|
<ts.SourceFile path="test1.ts">
|
|
12
11
|
<ts.Declaration name="foo" refkey={refkey("foo")}>
|
|
@@ -18,9 +17,7 @@ it("works with back references", () => {
|
|
|
18
17
|
const v = <Reference refkey={refkey("foo")} />;
|
|
19
18
|
</ts.SourceFile>
|
|
20
19
|
</Output>,
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
assertFileContents(res, {
|
|
20
|
+
).toRenderTo({
|
|
24
21
|
"test1.ts": `
|
|
25
22
|
const foo = 1;
|
|
26
23
|
`,
|
|
@@ -33,7 +30,7 @@ it("works with back references", () => {
|
|
|
33
30
|
});
|
|
34
31
|
|
|
35
32
|
it("works with forward references", () => {
|
|
36
|
-
|
|
33
|
+
expect(
|
|
37
34
|
<Output>
|
|
38
35
|
<ts.SourceFile path="test2.ts">
|
|
39
36
|
const v = <Reference refkey={refkey("foo")} />;
|
|
@@ -44,9 +41,7 @@ it("works with forward references", () => {
|
|
|
44
41
|
</ts.Declaration>
|
|
45
42
|
</ts.SourceFile>
|
|
46
43
|
</Output>,
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
assertFileContents(res, {
|
|
44
|
+
).toRenderTo({
|
|
50
45
|
"test1.ts": `
|
|
51
46
|
const foo = 1;
|
|
52
47
|
`,
|
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
import { Output
|
|
2
|
-
import { d } from "@alloy-js/core/testing";
|
|
1
|
+
import { Output } from "@alloy-js/core";
|
|
3
2
|
import { expect, it } from "vitest";
|
|
4
3
|
import { SourceFile } from "../src/components/SourceFile.jsx";
|
|
5
|
-
import { findFile } from "./utils.jsx";
|
|
6
4
|
|
|
7
5
|
it("Includes header", () => {
|
|
8
|
-
|
|
6
|
+
expect(
|
|
9
7
|
<Output>
|
|
10
8
|
<SourceFile path="hi.ts" headerComment="This is a header">
|
|
11
9
|
hello!
|
|
12
10
|
</SourceFile>
|
|
13
11
|
</Output>,
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
expect(findFile(tree, "hi.ts").contents).toEqual(d`
|
|
12
|
+
).toRenderTo(`
|
|
17
13
|
// This is a header
|
|
18
14
|
|
|
19
15
|
hello!`);
|
|
20
16
|
});
|
|
21
17
|
|
|
22
18
|
it("Line wraps a header", () => {
|
|
23
|
-
|
|
19
|
+
expect(
|
|
24
20
|
<Output>
|
|
25
21
|
<SourceFile
|
|
26
22
|
path="hi.ts"
|
|
@@ -29,9 +25,7 @@ it("Line wraps a header", () => {
|
|
|
29
25
|
hello!
|
|
30
26
|
</SourceFile>
|
|
31
27
|
</Output>,
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
expect(findFile(tree, "hi.ts").contents).toEqual(d`
|
|
28
|
+
).toRenderTo(`
|
|
35
29
|
// This is a very long header that is very long and should be wrapped. Meaning,
|
|
36
30
|
// it should be split into multiple lines.
|
|
37
31
|
|
package/test/utils.tsx
CHANGED
|
@@ -24,7 +24,7 @@ export function toSourceText(c: Children, options?: PrintTreeOptions): string {
|
|
|
24
24
|
<Output>
|
|
25
25
|
<ts.SourceFile path="test.ts">{c}</ts.SourceFile>
|
|
26
26
|
</Output>,
|
|
27
|
-
options,
|
|
27
|
+
{ insertFinalNewLine: false, ...options },
|
|
28
28
|
);
|
|
29
29
|
|
|
30
30
|
return findFile(res, "test.ts").contents;
|
package/test/values.test.tsx
CHANGED
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
printTree,
|
|
6
6
|
reactive,
|
|
7
7
|
refkey,
|
|
8
|
-
render,
|
|
9
8
|
renderTree,
|
|
10
9
|
StatementList,
|
|
11
10
|
} from "@alloy-js/core";
|
|
@@ -14,7 +13,6 @@ import { describe, expect, it } from "vitest";
|
|
|
14
13
|
|
|
15
14
|
import { d } from "@alloy-js/core/testing";
|
|
16
15
|
import * as ts from "../src/index.js";
|
|
17
|
-
import { assertFileContents } from "./utils.jsx";
|
|
18
16
|
|
|
19
17
|
it("renders an object", () => {
|
|
20
18
|
expect(<ts.ObjectExpression />).toRenderTo("{}");
|
|
@@ -281,8 +279,12 @@ describe("symbols", () => {
|
|
|
281
279
|
</ts.PackageDirectory>
|
|
282
280
|
</Output>
|
|
283
281
|
);
|
|
284
|
-
|
|
285
|
-
|
|
282
|
+
expect(decl).toRenderTo({
|
|
283
|
+
"sp/package.json": expect.anything(),
|
|
284
|
+
"dp/tsconfig.json": expect.anything(),
|
|
285
|
+
"dp/package.json": expect.anything(),
|
|
286
|
+
"sp/tsconfig.json": expect.anything(),
|
|
287
|
+
"sp/foo.ts": expect.anything(),
|
|
286
288
|
"dp/bar.ts": `
|
|
287
289
|
import { refme } from "SourcePackage";
|
|
288
290
|
|
|
@@ -293,7 +295,7 @@ describe("symbols", () => {
|
|
|
293
295
|
|
|
294
296
|
it("uses name policy", () => {
|
|
295
297
|
const key1 = refkey();
|
|
296
|
-
|
|
298
|
+
expect(
|
|
297
299
|
<Output namePolicy={ts.createTSNamePolicy()}>
|
|
298
300
|
<ts.SourceFile path="test.ts">
|
|
299
301
|
<ts.VarDeclaration const name="dispatcher">
|
|
@@ -311,9 +313,7 @@ describe("symbols", () => {
|
|
|
311
313
|
<ts.FunctionCallExpression target={key1} args={["data"]} />
|
|
312
314
|
</ts.SourceFile>
|
|
313
315
|
</Output>,
|
|
314
|
-
)
|
|
315
|
-
|
|
316
|
-
assertFileContents(res, {
|
|
316
|
+
).toRenderTo({
|
|
317
317
|
"test.ts": `
|
|
318
318
|
const dispatcher = {
|
|
319
319
|
fooBar: null,
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
memberRefkey,
|
|
3
|
-
Output,
|
|
4
|
-
refkey,
|
|
5
|
-
render,
|
|
6
|
-
StatementList,
|
|
7
|
-
} from "@alloy-js/core";
|
|
1
|
+
import { memberRefkey, Output, refkey, StatementList } from "@alloy-js/core";
|
|
8
2
|
import "@alloy-js/core/testing";
|
|
9
3
|
import { expect, it } from "vitest";
|
|
10
4
|
import * as ts from "../src/index.js";
|
|
11
|
-
import { assertFileContents } from "./utils.js";
|
|
12
5
|
|
|
13
6
|
it("works", () => {
|
|
14
7
|
expect(
|
|
@@ -23,7 +16,7 @@ it("works", () => {
|
|
|
23
16
|
it("works end-to-end", () => {
|
|
24
17
|
const TestType = refkey("TestType");
|
|
25
18
|
|
|
26
|
-
|
|
19
|
+
expect(
|
|
27
20
|
<Output>
|
|
28
21
|
<ts.SourceFile path="types.ts">
|
|
29
22
|
<ts.TypeDeclaration name="TestType" refkey={TestType}>
|
|
@@ -42,9 +35,7 @@ it("works end-to-end", () => {
|
|
|
42
35
|
;
|
|
43
36
|
</ts.SourceFile>
|
|
44
37
|
</Output>,
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
assertFileContents(res, {
|
|
38
|
+
).toRenderTo({
|
|
48
39
|
"types.ts": `
|
|
49
40
|
type TestType = "hello" | "goodbye";
|
|
50
41
|
`,
|
|
@@ -64,7 +55,7 @@ it("instantiates symbols from its type", () => {
|
|
|
64
55
|
const v1Rk = refkey();
|
|
65
56
|
const v2Rk = refkey();
|
|
66
57
|
|
|
67
|
-
|
|
58
|
+
expect(
|
|
68
59
|
<Output>
|
|
69
60
|
<ts.SourceFile path="inst.ts">
|
|
70
61
|
<StatementList>
|
|
@@ -95,9 +86,14 @@ it("instantiates symbols from its type", () => {
|
|
|
95
86
|
</ts.ClassDeclaration>
|
|
96
87
|
</ts.SourceFile>
|
|
97
88
|
</Output>,
|
|
98
|
-
)
|
|
99
|
-
|
|
100
|
-
|
|
89
|
+
).toRenderTo({
|
|
90
|
+
"decl.ts": `
|
|
91
|
+
interface Foo {
|
|
92
|
+
instanceProp: 42;
|
|
93
|
+
}class Bar {
|
|
94
|
+
instanceProp = 42;
|
|
95
|
+
}
|
|
96
|
+
`,
|
|
101
97
|
"inst.ts": `
|
|
102
98
|
import type { Bar, Foo } from "./decl.js";
|
|
103
99
|
|
|
@@ -114,7 +110,7 @@ it("instantiates symbols from type even when an expression is passed", () => {
|
|
|
114
110
|
const classMemberRk = refkey();
|
|
115
111
|
const v1Rk = refkey();
|
|
116
112
|
|
|
117
|
-
|
|
113
|
+
expect(
|
|
118
114
|
<Output>
|
|
119
115
|
<ts.SourceFile path="inst.ts">
|
|
120
116
|
<StatementList>
|
|
@@ -136,9 +132,12 @@ it("instantiates symbols from type even when an expression is passed", () => {
|
|
|
136
132
|
</ts.ClassDeclaration>
|
|
137
133
|
</ts.SourceFile>
|
|
138
134
|
</Output>,
|
|
139
|
-
)
|
|
140
|
-
|
|
141
|
-
|
|
135
|
+
).toRenderTo({
|
|
136
|
+
"decl.ts": `
|
|
137
|
+
class Bar {
|
|
138
|
+
instanceProp = 42;
|
|
139
|
+
}
|
|
140
|
+
`,
|
|
142
141
|
"inst.ts": `
|
|
143
142
|
import type { Bar } from "./decl.js";
|
|
144
143
|
|