@typespec/emitter-framework 0.11.0-dev.8 → 0.11.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/src/csharp/components/class/declaration.js +1 -1
  3. package/dist/src/csharp/components/class/declaration.js.map +1 -1
  4. package/dist/src/csharp/components/class/declaration.test.js +3 -0
  5. package/dist/src/csharp/components/class/declaration.test.js.map +1 -1
  6. package/dist/src/csharp/components/type-expression.test.js +13 -9
  7. package/dist/src/csharp/components/type-expression.test.js.map +1 -1
  8. package/dist/test/typescript/components/arrow-function.test.js +9 -8
  9. package/dist/test/typescript/components/arrow-function.test.js.map +1 -1
  10. package/dist/test/typescript/components/component-override.test.js +1 -1
  11. package/dist/test/typescript/components/component-override.test.js.map +1 -1
  12. package/dist/test/typescript/components/function-declaration.test.js +1 -1
  13. package/dist/test/typescript/components/function-declaration.test.js.map +1 -1
  14. package/dist/test/typescript/components/function-expression.test.js +9 -8
  15. package/dist/test/typescript/components/function-expression.test.js.map +1 -1
  16. package/dist/test/typescript/components/function-type.test.js +9 -8
  17. package/dist/test/typescript/components/function-type.test.js.map +1 -1
  18. package/dist/test/typescript/components/interface-declaration.test.js +1 -1
  19. package/dist/test/typescript/components/interface-declaration.test.js.map +1 -1
  20. package/dist/test/typescript/components/interface-method.test.js +18 -16
  21. package/dist/test/typescript/components/interface-method.test.js.map +1 -1
  22. package/dist/test/typescript/components/type-alias-declaration.test.js +6 -4
  23. package/dist/test/typescript/components/type-alias-declaration.test.js.map +1 -1
  24. package/dist/test/typescript/components/type-transform.test.js +27 -26
  25. package/dist/test/typescript/components/type-transform.test.js.map +1 -1
  26. package/dist/test/typescript/components/value-expression.test.js +1 -1
  27. package/dist/test/typescript/components/value-expression.test.js.map +1 -1
  28. package/dist/test/utils.d.ts +1 -0
  29. package/dist/test/utils.d.ts.map +1 -1
  30. package/dist/test/utils.js +8 -1
  31. package/dist/test/utils.js.map +1 -1
  32. package/package.json +4 -5
  33. package/src/csharp/components/class/declaration.test.tsx +3 -0
  34. package/src/csharp/components/class/declaration.tsx +1 -1
  35. package/src/csharp/components/type-expression.test.tsx +18 -15
  36. package/test/typescript/components/arrow-function.test.tsx +13 -14
  37. package/test/typescript/components/component-override.test.tsx +1 -1
  38. package/test/typescript/components/function-declaration.test.tsx +2 -1
  39. package/test/typescript/components/function-expression.test.tsx +13 -14
  40. package/test/typescript/components/function-type.test.tsx +12 -12
  41. package/test/typescript/components/interface-declaration.test.tsx +1 -1
  42. package/test/typescript/components/interface-method.test.tsx +25 -24
  43. package/test/typescript/components/type-alias-declaration.test.tsx +8 -6
  44. package/test/typescript/components/type-transform.test.tsx +37 -37
  45. package/test/typescript/components/value-expression.test.tsx +1 -1
  46. package/test/utils.ts +7 -2
  47. package/dist/test/typescript/test-host.d.ts +0 -12
  48. package/dist/test/typescript/test-host.d.ts.map +0 -1
  49. package/dist/test/typescript/test-host.js +0 -30
  50. package/dist/test/typescript/test-host.js.map +0 -1
  51. package/test/typescript/test-host.ts +0 -37
package/test/utils.ts CHANGED
@@ -1,13 +1,12 @@
1
+ import { Tester } from "#test/test-host.js";
1
2
  import { type Children, type OutputDirectory, render } from "@alloy-js/core";
2
3
  import { Output } from "@alloy-js/core/stc";
3
4
  import { SourceFile } from "@alloy-js/typescript/stc";
4
5
  import type { Program } from "@typespec/compiler";
5
6
  import { assert } from "vitest";
6
- import { getProgram } from "./typescript/test-host.js";
7
7
 
8
8
  export async function getEmitOutput(tspCode: string, cb: (program: Program) => Children) {
9
9
  const program = await getProgram(tspCode);
10
-
11
10
  const res = render(Output().children(SourceFile({ path: "test.ts" }).children(cb(program))), {
12
11
  insertFinalNewLine: false,
13
12
  });
@@ -16,6 +15,12 @@ export async function getEmitOutput(tspCode: string, cb: (program: Program) => C
16
15
  return testFile.contents;
17
16
  }
18
17
 
18
+ export async function getProgram(tspCode: string) {
19
+ const runner = await Tester.createInstance();
20
+ const { program } = await runner.compile(tspCode);
21
+ return program;
22
+ }
23
+
19
24
  export function assertFileContents(res: OutputDirectory, contents: string) {
20
25
  const testFile = res.contents.find((file) => file.path === "test.ts")!;
21
26
  assert(testFile, "test.ts file not rendered");
@@ -1,12 +0,0 @@
1
- import type { Program } from "@typespec/compiler";
2
- export declare function createTypespecCliTestHost(): Promise<import("@typespec/compiler/testing").TestHost>;
3
- export declare function createEmitterFrameworkTestRunner(options?: {
4
- autoUsings?: string[];
5
- }): Promise<import("@typespec/compiler/testing").BasicTestRunner>;
6
- export declare function getProgram(code: string): Promise<Program>;
7
- /**
8
- * Initializes an empty program in the compiler.
9
- * This is useful when you want to initialize the default TypeKits without any code.
10
- */
11
- export declare function initEmptyProgram(): Promise<void>;
12
- //# sourceMappingURL=test-host.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-host.d.ts","sourceRoot":"","sources":["../../../test/typescript/test-host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAOlD,wBAAsB,yBAAyB,2DAE9C;AAED,wBAAsB,gCAAgC,CAAC,OAAO,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;CAAO,iEAK7F;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAU/D;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAEtD"}
@@ -1,30 +0,0 @@
1
- import { createTestHost, createTestWrapper, expectDiagnosticEmpty } from "@typespec/compiler/testing";
2
- export async function createTypespecCliTestHost() {
3
- return createTestHost({});
4
- }
5
- export async function createEmitterFrameworkTestRunner(options = {}) {
6
- const host = await createTypespecCliTestHost();
7
- return createTestWrapper(host, {
8
- autoUsings: options.autoUsings
9
- });
10
- }
11
- export async function getProgram(code) {
12
- const host = await createTypespecCliTestHost();
13
- const wrapper = createTestWrapper(host, {
14
- compilerOptions: {
15
- noEmit: true
16
- }
17
- });
18
- const [_, diagnostics] = await wrapper.compileAndDiagnose(code);
19
- expectDiagnosticEmpty(diagnostics);
20
- return wrapper.program;
21
- }
22
-
23
- /**
24
- * Initializes an empty program in the compiler.
25
- * This is useful when you want to initialize the default TypeKits without any code.
26
- */
27
- export async function initEmptyProgram() {
28
- await getProgram("");
29
- }
30
- //# sourceMappingURL=test-host.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["createTestHost","createTestWrapper","expectDiagnosticEmpty","createTypespecCliTestHost","createEmitterFrameworkTestRunner","options","host","autoUsings","getProgram","code","wrapper","compilerOptions","noEmit","_","diagnostics","compileAndDiagnose","program","initEmptyProgram"],"sources":["../../../test/typescript/test-host.ts"],"sourcesContent":[null],"mappings":"AACA,SACEA,cAAc,EACdC,iBAAiB,EACjBC,qBAAqB,QAChB,4BAA4B;AAEnC,OAAO,eAAeC,yBAAyBA,CAAA,EAAG;EAChD,OAAOH,cAAc,CAAC,CAAC,CAAC,CAAC;AAC3B;AAEA,OAAO,eAAeI,gCAAgCA,CAACC,OAAkC,GAAG,CAAC,CAAC,EAAE;EAC9F,MAAMC,IAAI,GAAG,MAAMH,yBAAyB,CAAC,CAAC;EAC9C,OAAOF,iBAAiB,CAACK,IAAI,EAAE;IAC7BC,UAAU,EAAEF,OAAO,CAACE;EACtB,CAAC,CAAC;AACJ;AAEA,OAAO,eAAeC,UAAUA,CAACC,IAAY,EAAoB;EAC/D,MAAMH,IAAI,GAAG,MAAMH,yBAAyB,CAAC,CAAC;EAC9C,MAAMO,OAAO,GAAGT,iBAAiB,CAACK,IAAI,EAAE;IACtCK,eAAe,EAAE;MACfC,MAAM,EAAE;IACV;EACF,CAAC,CAAC;EACF,MAAM,CAACC,CAAC,EAAEC,WAAW,CAAC,GAAG,MAAMJ,OAAO,CAACK,kBAAkB,CAACN,IAAI,CAAC;EAC/DP,qBAAqB,CAACY,WAAW,CAAC;EAClC,OAAOJ,OAAO,CAACM,OAAO;AACxB;;AAEA;AACA;AACA;AACA;AACA,OAAO,eAAeC,gBAAgBA,CAAA,EAAkB;EACtD,MAAMT,UAAU,CAAC,EAAE,CAAC;AACtB","ignoreList":[]}
@@ -1,37 +0,0 @@
1
- import type { Program } from "@typespec/compiler";
2
- import {
3
- createTestHost,
4
- createTestWrapper,
5
- expectDiagnosticEmpty,
6
- } from "@typespec/compiler/testing";
7
-
8
- export async function createTypespecCliTestHost() {
9
- return createTestHost({});
10
- }
11
-
12
- export async function createEmitterFrameworkTestRunner(options: { autoUsings?: string[] } = {}) {
13
- const host = await createTypespecCliTestHost();
14
- return createTestWrapper(host, {
15
- autoUsings: options.autoUsings,
16
- });
17
- }
18
-
19
- export async function getProgram(code: string): Promise<Program> {
20
- const host = await createTypespecCliTestHost();
21
- const wrapper = createTestWrapper(host, {
22
- compilerOptions: {
23
- noEmit: true,
24
- },
25
- });
26
- const [_, diagnostics] = await wrapper.compileAndDiagnose(code);
27
- expectDiagnosticEmpty(diagnostics);
28
- return wrapper.program;
29
- }
30
-
31
- /**
32
- * Initializes an empty program in the compiler.
33
- * This is useful when you want to initialize the default TypeKits without any code.
34
- */
35
- export async function initEmptyProgram(): Promise<void> {
36
- await getProgram("");
37
- }