@alloy-js/typescript 0.19.0-dev.5 → 0.19.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alloy-js/typescript",
3
- "version": "0.19.0-dev.5",
3
+ "version": "0.19.0",
4
4
  "description": "",
5
5
  "exports": {
6
6
  ".": {
@@ -14,18 +14,18 @@
14
14
  "author": "brian.terlson@microsoft.com",
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
- "@alloy-js/core": "~0.18.2 || >= 0.19.0-dev.3",
18
17
  "change-case": "^5.4.4",
19
- "pathe": "^2.0.3"
18
+ "pathe": "^2.0.3",
19
+ "@alloy-js/core": "~0.19.0"
20
20
  },
21
21
  "devDependencies": {
22
- "@alloy-js/cli": "~0.18.0 || >= 0.19.0-dev.0",
23
- "@alloy-js/rollup-plugin": "~0.1.0 || >= 0.1.1-dev.0",
24
22
  "@microsoft/api-extractor": "~7.52.8",
25
23
  "@rollup/plugin-typescript": "^12.1.2",
26
24
  "concurrently": "^9.1.2",
27
25
  "typescript": "^5.8.3",
28
- "vitest": "^3.2.4"
26
+ "vitest": "^3.2.4",
27
+ "@alloy-js/cli": "~0.19.0",
28
+ "@alloy-js/rollup-plugin": "~0.1.0"
29
29
  },
30
30
  "type": "module",
31
31
  "scripts": {
@@ -3,6 +3,7 @@ import "@alloy-js/core/testing";
3
3
  import { d } from "@alloy-js/core/testing";
4
4
  import { expect, it } from "vitest";
5
5
  import * as ts from "../src/components/index.js";
6
+ import { findFile } from "./utils.jsx";
6
7
 
7
8
  it("exports everything from source files within it", () => {
8
9
  const res = render(
@@ -17,12 +18,12 @@ it("exports everything from source files within it", () => {
17
18
  <ts.BarrelFile />
18
19
  </Output>,
19
20
  );
20
- expect((res.contents[2].contents[2] as any).contents).toBe(d`
21
+ expect(findFile(res, "components/index.ts").contents).toBe(d`
21
22
  export * from "./c1.js";
22
23
  export * from "./c2.js";
23
24
  `);
24
25
 
25
- expect(res.contents[3].contents).toBe(d`
26
+ expect(findFile(res, "index.ts").contents).toBe(d`
26
27
  export * from "./test1.js";
27
28
  export * from "./test2.js";
28
29
  export * from "./components/index.js";
@@ -39,7 +40,7 @@ it("ignores non-TS files", () => {
39
40
  </Output>,
40
41
  );
41
42
 
42
- expect(res.contents[3].contents).toBe(d`
43
+ expect(findFile(res, "index.ts").contents).toBe(d`
43
44
  export * from "./test1.js";
44
45
  export * from "./test2.js";
45
46
  `);
@@ -3,7 +3,7 @@ import "@alloy-js/core/testing";
3
3
  import { d } from "@alloy-js/core/testing";
4
4
  import { describe, expect, it } from "vitest";
5
5
  import * as ts from "../src/components/index.js";
6
- import { toSourceText } from "./utils.js";
6
+ import { findFile, toSourceText } from "./utils.js";
7
7
 
8
8
  it("declares classes", () => {
9
9
  const res = toSourceText(<ts.ClassDeclaration name="Foo" />);
@@ -222,7 +222,7 @@ describe("instance members", () => {
222
222
  </Output>,
223
223
  );
224
224
 
225
- expect(tree.contents[1].contents).toEqual(d`
225
+ expect(findFile(tree, "ref.ts").contents).toEqual(d`
226
226
  import { one, two } from "./decl.js";
227
227
 
228
228
  class Foo {
@@ -9,6 +9,7 @@ import {
9
9
  TSSymbolFlags,
10
10
  } from "../src/index.js";
11
11
  import { ParameterDescriptor } from "../src/parameter-descriptor.js";
12
+ import { findFile } from "./utils.jsx";
12
13
  it("handles custom name conflict resolver based on metadata", () => {
13
14
  function resolver(name: string, symbols: TSOutputSymbol[]) {
14
15
  const goodNamedSymbols = symbols.filter(
@@ -90,7 +91,7 @@ it("handles custom name conflict resolver based on metadata", () => {
90
91
  </Output>,
91
92
  );
92
93
 
93
- expect(res.contents[0].contents).toBe(d`
94
+ expect(findFile(res, "test.ts").contents).toBe(d`
94
95
  export function conflicty(
95
96
  foo,
96
97
  foo1,
@@ -4,6 +4,7 @@ import { d } from "@alloy-js/core/testing";
4
4
  import { expect, it } from "vitest";
5
5
  import * as ts from "../src/components/index.js";
6
6
  import { createTSNamePolicy } from "../src/name-policy.js";
7
+ import { findFile } from "./utils.jsx";
7
8
 
8
9
  it("applies to functions and variables", () => {
9
10
  const ref1 = refkey({});
@@ -26,7 +27,7 @@ it("applies to functions and variables", () => {
26
27
  </Output>,
27
28
  );
28
29
 
29
- expect(res.contents[0].contents).toEqual(d`
30
+ expect(findFile(res, "test.ts").contents).toEqual(d`
30
31
  function fooBar() {}
31
32
  const oneTwo = "hello";
32
33
  fooBar;
@@ -55,7 +56,7 @@ it("keeps _ and $ prefix", () => {
55
56
  </Output>,
56
57
  );
57
58
 
58
- expect(res.contents[0].contents).toEqual(d`
59
+ expect(findFile(res, "test.ts").contents).toEqual(d`
59
60
  function _fooBar() {}
60
61
  const $oneTwo = "hello";
61
62
  _fooBar;
@@ -88,7 +89,7 @@ it("appends _ to reserved words", () => {
88
89
  </Output>,
89
90
  );
90
91
 
91
- expect(res.contents[0].contents).toEqual(d`
92
+ expect(findFile(res, "test.ts").contents).toEqual(d`
92
93
  function default_(await_: any) {}
93
94
  const super_ = "hello";
94
95
  default_;
@@ -1,7 +1,8 @@
1
1
  import { Output, refkey, render, StatementList } from "@alloy-js/core";
2
2
  import { d } from "@alloy-js/core/testing";
3
- import { expect, it } from "vitest";
3
+ import { it } from "vitest";
4
4
  import * as ts from "../src/index.js";
5
+ import { assertFileContents } from "./utils.jsx";
5
6
 
6
7
  it("should instantiate classes", () => {
7
8
  const varRk = refkey();
@@ -29,14 +30,16 @@ it("should instantiate classes", () => {
29
30
  </Output>,
30
31
  );
31
32
 
32
- expect(tree.contents[0].contents).toEqual(d`
33
- import { Foo } from "./decl.js";
33
+ assertFileContents(tree, {
34
+ "inst.ts": d`
35
+ import { Foo } from "./decl.js";
34
36
 
35
- export const one = new Foo();
36
- `);
37
- expect(tree.contents[1].contents).toEqual(d`
38
- class Foo {
39
- instanceProp = 42;
40
- }
41
- `);
37
+ export const one = new Foo();
38
+ `,
39
+ "decl.ts": d`
40
+ class Foo {
41
+ instanceProp = 42;
42
+ }
43
+ `,
44
+ });
42
45
  });
@@ -2,6 +2,7 @@ import { Output, render } from "@alloy-js/core";
2
2
  import { d } from "@alloy-js/core/testing";
3
3
  import { expect, it } from "vitest";
4
4
  import { SourceFile } from "../src/components/SourceFile.jsx";
5
+ import { findFile } from "./utils.jsx";
5
6
 
6
7
  it("Includes header", () => {
7
8
  const tree = render(
@@ -12,7 +13,7 @@ it("Includes header", () => {
12
13
  </Output>,
13
14
  );
14
15
 
15
- expect(tree.contents[0].contents).toEqual(d`
16
+ expect(findFile(tree, "hi.ts").contents).toEqual(d`
16
17
  // This is a header
17
18
 
18
19
  hello!`);
@@ -30,7 +31,7 @@ it("Line wraps a header", () => {
30
31
  </Output>,
31
32
  );
32
33
 
33
- expect(tree.contents[0].contents).toEqual(d`
34
+ expect(findFile(tree, "hi.ts").contents).toEqual(d`
34
35
  // This is a very long header that is very long and should be wrapped. Meaning,
35
36
  // it should be split into multiple lines.
36
37
 
package/test/utils.tsx CHANGED
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  Children,
3
+ ContentOutputFile,
3
4
  Output,
4
5
  OutputDirectory,
5
6
  OutputFile,
@@ -26,16 +27,19 @@ export function toSourceText(c: Children, options?: PrintTreeOptions): string {
26
27
  options,
27
28
  );
28
29
 
29
- return res.contents[0].contents as string;
30
+ return findFile(res, "test.ts").contents;
30
31
  }
31
32
 
32
- export function findFile(res: OutputDirectory, path: string): OutputFile {
33
+ export function findFile(
34
+ res: OutputDirectory,
35
+ path: string,
36
+ ): ContentOutputFile {
33
37
  const result = findFileWorker(res, path);
34
38
 
35
39
  if (!result) {
36
40
  throw new Error("Expected to find file " + path);
37
41
  }
38
- return result;
42
+ return result as ContentOutputFile;
39
43
 
40
44
  function findFileWorker(
41
45
  res: OutputDirectory,