Skip to content

Commit 07a03da

Browse files
committed
test(core): add parameter type test
1 parent 2b861fd commit 07a03da

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

packages/core/test/types.test-d.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,32 @@ describe("core types", () => {
176176
it("should infer parameters types", () => {
177177
Clerc.create()
178178
.command("test", "test", {
179-
parameters: [{ key: "<foo>", type: Types.Enum("a", "b") }],
179+
parameters: [
180+
{
181+
key: "<foo>",
182+
type: Types.Enum("a", "b"),
183+
},
184+
{
185+
key: "<bar>",
186+
type: Number,
187+
},
188+
{
189+
key: "[baz]",
190+
type: Boolean,
191+
},
192+
{
193+
key: "[qux]",
194+
type: Types.Range(1, 10),
195+
},
196+
],
180197
})
181198
.on("test", (ctx) => {
182-
expectTypeOf(ctx.parameters).toEqualTypeOf<{ foo: "a" | "b" }>();
199+
expectTypeOf(ctx.parameters).toEqualTypeOf<{
200+
foo: "a" | "b";
201+
bar: number;
202+
baz: boolean | undefined;
203+
qux: number | undefined;
204+
}>();
183205
});
184206
});
185207

0 commit comments

Comments
 (0)