@typespec/emitter-framework 0.6.0-dev.4 → 0.6.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/src/core/context/name-policy-context.js +1 -2
- package/dist/src/core/index.js +1 -2
- package/dist/src/core/transport-name-policy.js +1 -2
- package/dist/src/core/write-output.js +1 -2
- package/dist/src/lib.js +1 -2
- package/dist/src/testing/index.js +1 -2
- package/dist/src/testing/scenario-test/harness.js +1 -2
- package/dist/src/testing/scenario-test/index.js +1 -2
- package/dist/src/testing/scenario-test/snippet-extractor.js +1 -2
- package/dist/src/testing/scenario-test/test-host.js +1 -2
- package/dist/src/typescript/components/array-expression.js +1 -2
- package/dist/src/typescript/components/arrow-function.js +2 -5
- package/dist/src/typescript/components/class-method.js +2 -4
- package/dist/src/typescript/components/enum-declaration.js +2 -4
- package/dist/src/typescript/components/function-declaration.js +2 -4
- package/dist/src/typescript/components/function-expression.js +2 -5
- package/dist/src/typescript/components/function-type.js +2 -5
- package/dist/src/typescript/components/index.js +1 -2
- package/dist/src/typescript/components/interface-declaration.js +2 -5
- package/dist/src/typescript/components/interface-member.js +2 -4
- package/dist/src/typescript/components/interface-method.d.ts.map +1 -1
- package/dist/src/typescript/components/interface-method.js +5 -8
- package/dist/src/typescript/components/record-expression.js +1 -2
- package/dist/src/typescript/components/static-serializers.js +1 -2
- package/dist/src/typescript/components/type-alias-declaration.js +2 -5
- package/dist/src/typescript/components/type-declaration.js +2 -4
- package/dist/src/typescript/components/type-expression.js +2 -4
- package/dist/src/typescript/components/type-transform.js +2 -4
- package/dist/src/typescript/components/union-declaration.js +2 -4
- package/dist/src/typescript/components/union-expression.js +2 -4
- package/dist/src/typescript/components/value-expression.js +2 -4
- package/dist/src/typescript/index.js +1 -2
- package/dist/src/typescript/lib.js +1 -2
- package/dist/src/typescript/utils/operation.js +1 -2
- package/dist/test/testing/snippet-extractor-csharp.test.js +96 -0
- package/dist/test/testing/snippet-extractor-java.test.js +104 -0
- package/dist/test/testing/snippet-extractor-python.test.js +33 -0
- package/dist/test/testing/snippet-extractor-typescript.test.js +161 -0
- package/dist/test/typescript/components/arrow-function.test.js +88 -0
- package/dist/test/typescript/components/enum-declaration.test.js +118 -0
- package/dist/test/typescript/components/function-declaration.test.js +246 -0
- package/dist/test/typescript/components/function-expression.test.js +88 -0
- package/dist/test/typescript/components/function-type.test.js +85 -0
- package/dist/test/typescript/components/interface-declaration.test.js +775 -0
- package/dist/test/typescript/components/interface-method.test.js +272 -0
- package/dist/test/typescript/components/member-expression.test.js +155 -0
- package/dist/test/typescript/components/type-alias-declaration.test.js +155 -0
- package/dist/test/typescript/components/type-transform.test.js +682 -0
- package/dist/test/typescript/components/union-declaration.test.js +205 -0
- package/dist/test/typescript/components/value-expression.test.js +199 -0
- package/dist/test/typescript/test-host.js +40 -0
- package/dist/test/utils.js +18 -0
- package/package.json +5 -10
- package/src/typescript/components/interface-method.tsx +2 -4
- package/test/typescript/components/interface-method.test.tsx +167 -2
- package/vitest.config.ts +2 -9
- package/babel.config.js +0 -4
- package/dist/src/core/context/index.js.map +0 -1
- package/dist/src/core/context/name-policy-context.js.map +0 -1
- package/dist/src/core/index.js.map +0 -1
- package/dist/src/core/transport-name-policy.js.map +0 -1
- package/dist/src/core/write-output.js.map +0 -1
- package/dist/src/lib.js.map +0 -1
- package/dist/src/testing/index.js.map +0 -1
- package/dist/src/testing/scenario-test/harness.js.map +0 -1
- package/dist/src/testing/scenario-test/index.js.map +0 -1
- package/dist/src/testing/scenario-test/snippet-extractor.js.map +0 -1
- package/dist/src/testing/scenario-test/test-host.js.map +0 -1
- package/dist/src/typescript/components/array-expression.js.map +0 -1
- package/dist/src/typescript/components/arrow-function.js.map +0 -1
- package/dist/src/typescript/components/class-method.js.map +0 -1
- package/dist/src/typescript/components/enum-declaration.js.map +0 -1
- package/dist/src/typescript/components/function-declaration.js.map +0 -1
- package/dist/src/typescript/components/function-expression.js.map +0 -1
- package/dist/src/typescript/components/function-type.js.map +0 -1
- package/dist/src/typescript/components/index.js.map +0 -1
- package/dist/src/typescript/components/interface-declaration.js.map +0 -1
- package/dist/src/typescript/components/interface-member.js.map +0 -1
- package/dist/src/typescript/components/interface-method.js.map +0 -1
- package/dist/src/typescript/components/record-expression.js.map +0 -1
- package/dist/src/typescript/components/static-serializers.js.map +0 -1
- package/dist/src/typescript/components/type-alias-declaration.js.map +0 -1
- package/dist/src/typescript/components/type-declaration.js.map +0 -1
- package/dist/src/typescript/components/type-expression.js.map +0 -1
- package/dist/src/typescript/components/type-transform.js.map +0 -1
- package/dist/src/typescript/components/union-declaration.js.map +0 -1
- package/dist/src/typescript/components/union-expression.js.map +0 -1
- package/dist/src/typescript/components/value-expression.js.map +0 -1
- package/dist/src/typescript/index.js.map +0 -1
- package/dist/src/typescript/lib.js.map +0 -1
- package/dist/src/typescript/utils/index.js.map +0 -1
- package/dist/src/typescript/utils/operation.js.map +0 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { Output, render } from "@alloy-js/core";
|
|
3
|
+
import { d } from "@alloy-js/core/testing";
|
|
4
|
+
import { SourceFile } from "@alloy-js/typescript";
|
|
5
|
+
import { beforeEach, describe, it } from "vitest";
|
|
6
|
+
import { FunctionType } from "../../../src/typescript/index.js";
|
|
7
|
+
import { assertFileContents } from "../../utils.js";
|
|
8
|
+
import { createEmitterFrameworkTestRunner } from "../test-host.js";
|
|
9
|
+
describe("function types with a `type` prop", () => {
|
|
10
|
+
let runner;
|
|
11
|
+
beforeEach(async () => {
|
|
12
|
+
runner = await createEmitterFrameworkTestRunner();
|
|
13
|
+
});
|
|
14
|
+
it("creates a function type", async () => {
|
|
15
|
+
const {
|
|
16
|
+
getName
|
|
17
|
+
} = await runner.compile(`
|
|
18
|
+
@test op getName(id: string): string;
|
|
19
|
+
`);
|
|
20
|
+
const res = render(_$createComponent(Output, {
|
|
21
|
+
get children() {
|
|
22
|
+
return _$createComponent(SourceFile, {
|
|
23
|
+
path: "test.ts",
|
|
24
|
+
get children() {
|
|
25
|
+
return _$createComponent(FunctionType, {
|
|
26
|
+
type: getName
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}));
|
|
32
|
+
assertFileContents(res, d`
|
|
33
|
+
(id: string) => string
|
|
34
|
+
`);
|
|
35
|
+
});
|
|
36
|
+
it("creates an async function type", async () => {
|
|
37
|
+
const {
|
|
38
|
+
getName
|
|
39
|
+
} = await runner.compile(`
|
|
40
|
+
@test op getName(id: string): string;
|
|
41
|
+
`);
|
|
42
|
+
const res = render(_$createComponent(Output, {
|
|
43
|
+
get children() {
|
|
44
|
+
return _$createComponent(SourceFile, {
|
|
45
|
+
path: "test.ts",
|
|
46
|
+
get children() {
|
|
47
|
+
return _$createComponent(FunctionType, {
|
|
48
|
+
async: true,
|
|
49
|
+
type: getName
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}));
|
|
55
|
+
assertFileContents(res, d`
|
|
56
|
+
(id: string) => Promise<string>
|
|
57
|
+
`);
|
|
58
|
+
});
|
|
59
|
+
it("can append extra parameters with raw params provided", async () => {
|
|
60
|
+
const {
|
|
61
|
+
getName
|
|
62
|
+
} = await runner.compile(`
|
|
63
|
+
@test op getName(id: string): string;
|
|
64
|
+
`);
|
|
65
|
+
const res = render(_$createComponent(Output, {
|
|
66
|
+
get children() {
|
|
67
|
+
return _$createComponent(SourceFile, {
|
|
68
|
+
path: "test.ts",
|
|
69
|
+
get children() {
|
|
70
|
+
return _$createComponent(FunctionType, {
|
|
71
|
+
type: getName,
|
|
72
|
+
parameters: [{
|
|
73
|
+
name: "additionalParam",
|
|
74
|
+
type: "number"
|
|
75
|
+
}]
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}));
|
|
81
|
+
assertFileContents(res, d`
|
|
82
|
+
(additionalParam: number, id: string) => string
|
|
83
|
+
`);
|
|
84
|
+
});
|
|
85
|
+
});
|