@alloy-js/typescript 0.19.0-dev.5 → 0.19.0-dev.6
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/test/barrel.test.js +4 -3
- package/dist/test/class.test.js +2 -2
- package/dist/test/name-conflict.test.js +2 -1
- package/dist/test/name-policy.test.js +4 -3
- package/dist/test/new-expression.test.js +13 -10
- package/dist/test/source-file.test.js +3 -2
- package/dist/test/utils.d.ts +2 -2
- package/dist/test/utils.d.ts.map +1 -1
- package/dist/test/utils.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/test/barrel.test.tsx +4 -3
- package/test/class.test.tsx +2 -2
- package/test/name-conflict.test.tsx +2 -1
- package/test/name-policy.test.tsx +4 -3
- package/test/new-expression.test.tsx +13 -10
- package/test/source-file.test.tsx +3 -2
- package/test/utils.tsx +7 -3
package/dist/test/barrel.test.js
CHANGED
|
@@ -4,6 +4,7 @@ import "@alloy-js/core/testing";
|
|
|
4
4
|
import { d } from "@alloy-js/core/testing";
|
|
5
5
|
import { expect, it } from "vitest";
|
|
6
6
|
import * as ts from "../src/components/index.js";
|
|
7
|
+
import { findFile } from "./utils.js";
|
|
7
8
|
it("exports everything from source files within it", () => {
|
|
8
9
|
const res = render(_$createComponent(Output, {
|
|
9
10
|
get children() {
|
|
@@ -23,11 +24,11 @@ it("exports everything from source files within it", () => {
|
|
|
23
24
|
}), _$createComponent(ts.BarrelFile, {})];
|
|
24
25
|
}
|
|
25
26
|
}));
|
|
26
|
-
expect(res.
|
|
27
|
+
expect(findFile(res, "components/index.ts").contents).toBe(d`
|
|
27
28
|
export * from "./c1.js";
|
|
28
29
|
export * from "./c2.js";
|
|
29
30
|
`);
|
|
30
|
-
expect(res.
|
|
31
|
+
expect(findFile(res, "index.ts").contents).toBe(d`
|
|
31
32
|
export * from "./test1.js";
|
|
32
33
|
export * from "./test2.js";
|
|
33
34
|
export * from "./components/index.js";
|
|
@@ -46,7 +47,7 @@ it("ignores non-TS files", () => {
|
|
|
46
47
|
}), _$createComponent(ts.BarrelFile, {})];
|
|
47
48
|
}
|
|
48
49
|
}));
|
|
49
|
-
expect(res.
|
|
50
|
+
expect(findFile(res, "index.ts").contents).toBe(d`
|
|
50
51
|
export * from "./test1.js";
|
|
51
52
|
export * from "./test2.js";
|
|
52
53
|
`);
|
package/dist/test/class.test.js
CHANGED
|
@@ -4,7 +4,7 @@ import "@alloy-js/core/testing";
|
|
|
4
4
|
import { d } from "@alloy-js/core/testing";
|
|
5
5
|
import { describe, expect, it } from "vitest";
|
|
6
6
|
import * as ts from "../src/components/index.js";
|
|
7
|
-
import { toSourceText } from "./utils.js";
|
|
7
|
+
import { findFile, toSourceText } from "./utils.js";
|
|
8
8
|
it("declares classes", () => {
|
|
9
9
|
const res = toSourceText(_$createComponent(ts.ClassDeclaration, {
|
|
10
10
|
name: "Foo"
|
|
@@ -298,7 +298,7 @@ describe("instance members", () => {
|
|
|
298
298
|
})];
|
|
299
299
|
}
|
|
300
300
|
}));
|
|
301
|
-
expect(tree.
|
|
301
|
+
expect(findFile(tree, "ref.ts").contents).toEqual(d`
|
|
302
302
|
import { one, two } from "./decl.js";
|
|
303
303
|
|
|
304
304
|
class Foo {
|
|
@@ -4,6 +4,7 @@ import { d } from "@alloy-js/core/testing";
|
|
|
4
4
|
import { camelCase } from "change-case";
|
|
5
5
|
import { expect, it } from "vitest";
|
|
6
6
|
import { FunctionDeclaration, SourceFile, TSSymbolFlags } from "../src/index.js";
|
|
7
|
+
import { findFile } from "./utils.js";
|
|
7
8
|
it("handles custom name conflict resolver based on metadata", () => {
|
|
8
9
|
function resolver(name, symbols) {
|
|
9
10
|
const goodNamedSymbols = symbols.filter(s => ~s.tsFlags & TSSymbolFlags.LocalImportSymbol);
|
|
@@ -93,7 +94,7 @@ it("handles custom name conflict resolver based on metadata", () => {
|
|
|
93
94
|
});
|
|
94
95
|
}
|
|
95
96
|
}));
|
|
96
|
-
expect(res.
|
|
97
|
+
expect(findFile(res, "test.ts").contents).toBe(d`
|
|
97
98
|
export function conflicty(
|
|
98
99
|
foo,
|
|
99
100
|
foo1,
|
|
@@ -5,6 +5,7 @@ import { d } from "@alloy-js/core/testing";
|
|
|
5
5
|
import { expect, it } from "vitest";
|
|
6
6
|
import * as ts from "../src/components/index.js";
|
|
7
7
|
import { createTSNamePolicy } from "../src/name-policy.js";
|
|
8
|
+
import { findFile } from "./utils.js";
|
|
8
9
|
it("applies to functions and variables", () => {
|
|
9
10
|
const ref1 = refkey({});
|
|
10
11
|
const ref2 = refkey({});
|
|
@@ -35,7 +36,7 @@ it("applies to functions and variables", () => {
|
|
|
35
36
|
});
|
|
36
37
|
}
|
|
37
38
|
}));
|
|
38
|
-
expect(res.
|
|
39
|
+
expect(findFile(res, "test.ts").contents).toEqual(d`
|
|
39
40
|
function fooBar() {}
|
|
40
41
|
const oneTwo = "hello";
|
|
41
42
|
fooBar;
|
|
@@ -72,7 +73,7 @@ it("keeps _ and $ prefix", () => {
|
|
|
72
73
|
});
|
|
73
74
|
}
|
|
74
75
|
}));
|
|
75
|
-
expect(res.
|
|
76
|
+
expect(findFile(res, "test.ts").contents).toEqual(d`
|
|
76
77
|
function _fooBar() {}
|
|
77
78
|
const $oneTwo = "hello";
|
|
78
79
|
_fooBar;
|
|
@@ -113,7 +114,7 @@ it("appends _ to reserved words", () => {
|
|
|
113
114
|
});
|
|
114
115
|
}
|
|
115
116
|
}));
|
|
116
|
-
expect(res.
|
|
117
|
+
expect(findFile(res, "test.ts").contents).toEqual(d`
|
|
117
118
|
function default_(await_: any) {}
|
|
118
119
|
const super_ = "hello";
|
|
119
120
|
default_;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import { Output, refkey, render, StatementList } from "@alloy-js/core";
|
|
3
3
|
import { d } from "@alloy-js/core/testing";
|
|
4
|
-
import {
|
|
4
|
+
import { it } from "vitest";
|
|
5
5
|
import * as ts from "../src/index.js";
|
|
6
|
+
import { assertFileContents } from "./utils.js";
|
|
6
7
|
it("should instantiate classes", () => {
|
|
7
8
|
const varRk = refkey();
|
|
8
9
|
const classRk = refkey();
|
|
@@ -49,14 +50,16 @@ it("should instantiate classes", () => {
|
|
|
49
50
|
})];
|
|
50
51
|
}
|
|
51
52
|
}));
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
assertFileContents(tree, {
|
|
54
|
+
"inst.ts": d`
|
|
55
|
+
import { Foo } from "./decl.js";
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
export const one = new Foo();
|
|
58
|
+
`,
|
|
59
|
+
"decl.ts": d`
|
|
60
|
+
class Foo {
|
|
61
|
+
instanceProp = 42;
|
|
62
|
+
}
|
|
63
|
+
`
|
|
64
|
+
});
|
|
62
65
|
});
|
|
@@ -3,6 +3,7 @@ import { Output, render } from "@alloy-js/core";
|
|
|
3
3
|
import { d } from "@alloy-js/core/testing";
|
|
4
4
|
import { expect, it } from "vitest";
|
|
5
5
|
import { SourceFile } from "../src/components/SourceFile.js";
|
|
6
|
+
import { findFile } from "./utils.js";
|
|
6
7
|
it("Includes header", () => {
|
|
7
8
|
const tree = render(_$createComponent(Output, {
|
|
8
9
|
get children() {
|
|
@@ -13,7 +14,7 @@ it("Includes header", () => {
|
|
|
13
14
|
});
|
|
14
15
|
}
|
|
15
16
|
}));
|
|
16
|
-
expect(tree.
|
|
17
|
+
expect(findFile(tree, "hi.ts").contents).toEqual(d`
|
|
17
18
|
// This is a header
|
|
18
19
|
|
|
19
20
|
hello!`);
|
|
@@ -28,7 +29,7 @@ it("Line wraps a header", () => {
|
|
|
28
29
|
});
|
|
29
30
|
}
|
|
30
31
|
}));
|
|
31
|
-
expect(tree.
|
|
32
|
+
expect(findFile(tree, "hi.ts").contents).toEqual(d`
|
|
32
33
|
// This is a very long header that is very long and should be wrapped. Meaning,
|
|
33
34
|
// it should be split into multiple lines.
|
|
34
35
|
|
package/dist/test/utils.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Children,
|
|
1
|
+
import { Children, ContentOutputFile, OutputDirectory, PrintTreeOptions } from "@alloy-js/core";
|
|
2
2
|
export declare function TestFile(props: {
|
|
3
3
|
children?: Children;
|
|
4
4
|
}): Children;
|
|
5
5
|
export declare function toSourceText(c: Children, options?: PrintTreeOptions): string;
|
|
6
|
-
export declare function findFile(res: OutputDirectory, path: string):
|
|
6
|
+
export declare function findFile(res: OutputDirectory, path: string): ContentOutputFile;
|
|
7
7
|
export declare function assertFileContents(res: OutputDirectory, expectedFiles: Record<string, string>): void;
|
|
8
8
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/test/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../test/utils.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../test/utils.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,iBAAiB,EAEjB,eAAe,EAEf,gBAAgB,EAEjB,MAAM,gBAAgB,CAAC;AAKxB,wBAAgB,QAAQ,CAAC,KAAK,EAAE;IAAE,QAAQ,CAAC,EAAE,QAAQ,CAAA;CAAE,YAMtD;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAS5E;AAED,wBAAgB,QAAQ,CACtB,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,MAAM,GACX,iBAAiB,CA2BnB;AAED,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,eAAe,EACpB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAMtC"}
|
package/dist/test/utils.js
CHANGED