Skip to content

Commit 16efe7d

Browse files
committed
refactor: rename to DetailUnit
1 parent 308038b commit 16efe7d

12 files changed

+33
-33
lines changed

action.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Denops } from "@denops/std";
22

33
import type { Promish } from "./_typeutil.ts";
4-
import type { Detail, IdItem, UnitDetail } from "./item.ts";
4+
import type { Detail, DetailUnit, IdItem } from "./item.ts";
55

66
/**
77
* Parameters for invoking an action.
@@ -28,7 +28,7 @@ export type InvokeParams<T extends Detail> = {
2828
/**
2929
* An action that can be invoked from the picker.
3030
*/
31-
export type Action<T extends Detail = UnitDetail> = {
31+
export type Action<T extends Detail = DetailUnit> = {
3232
/**
3333
* Invoke the action.
3434
*

action_test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { assertType, type IsExact } from "@std/testing/types";
22
import { DenopsStub } from "@denops/test/stub";
3-
import type { Detail, UnitDetail } from "./item.ts";
3+
import type { Detail, DetailUnit } from "./item.ts";
44
import type { Action, InvokeParams } from "./action.ts";
55

66
Deno.test("Action", async (t) => {
77
const denops = new DenopsStub();
88

99
await t.step("without type constraint is equal to UnitDetail", () => {
10-
assertType<IsExact<Action, Action<UnitDetail>>>(true);
10+
assertType<IsExact<Action, Action<DetailUnit>>>(true);
1111
});
1212

1313
await t.step("invoke follows the type constraint", () => {
@@ -19,6 +19,6 @@ Deno.test("Action", async (t) => {
1919
// @ts-expect-error: 'a' is missing
2020
action.invoke(denops, {} as InvokeParams<Detail>, {});
2121
// @ts-expect-error: 'a' is missing
22-
action.invoke(denops, {} as InvokeParams<UnitDetail>, {});
22+
action.invoke(denops, {} as InvokeParams<DetailUnit>, {});
2323
});
2424
});

item.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export type Detail = Record<PropertyKey, unknown>;
66
/**
77
* An unit of Detail.
88
*/
9-
export type UnitDetail = Record<never, never>;
9+
export type DetailUnit = Record<never, never>;
1010

1111
/**
1212
* An item processed by the picker.

item_test.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { assertType, type IsExact } from "@std/testing/types";
2-
import type { Detail, UnitDetail } from "./item.ts";
2+
import type { Detail, DetailUnit } from "./item.ts";
33

44
Deno.test("Detail", async (t) => {
55
await t.step("is usable as a type constraint", () => {
@@ -30,9 +30,9 @@ Deno.test("Detail", async (t) => {
3030
});
3131
});
3232

33-
Deno.test("UnitDetail", async (t) => {
33+
Deno.test("DetailUnit", async (t) => {
3434
await t.step("is NOT usable as a type constraint", () => {
35-
function constraint<T extends UnitDetail>(_: T) {}
35+
function constraint<T extends DetailUnit>(_: T) {}
3636
constraint({});
3737
constraint({ a: "" });
3838
constraint({ a: "", b: "" });
@@ -51,10 +51,10 @@ Deno.test("UnitDetail", async (t) => {
5151
});
5252

5353
await t.step("is an unit of Detail", () => {
54-
assertType<IsExact<UnitDetail & { a: string }, { a: string }>>(true);
54+
assertType<IsExact<DetailUnit & { a: string }, { a: string }>>(true);
5555
// misc
56-
assertType<IsExact<UnitDetail, UnitDetail>>(true);
57-
assertType<IsExact<UnitDetail & UnitDetail, UnitDetail>>(true);
58-
assertType<IsExact<UnitDetail & Detail, Detail>>(true);
56+
assertType<IsExact<DetailUnit, DetailUnit>>(true);
57+
assertType<IsExact<DetailUnit & DetailUnit, DetailUnit>>(true);
58+
assertType<IsExact<DetailUnit & Detail, Detail>>(true);
5959
});
6060
});

matcher.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Denops } from "@denops/std";
22

3-
import type { Detail, IdItem, UnitDetail } from "./item.ts";
3+
import type { Detail, DetailUnit, IdItem } from "./item.ts";
44

55
/**
66
* Parameters for matching items.
@@ -19,7 +19,7 @@ export type MatchParams<T extends Detail> = {
1919
/**
2020
* Matcher that filters items based on user input.
2121
*/
22-
export type Matcher<T extends Detail = UnitDetail> = {
22+
export type Matcher<T extends Detail = DetailUnit> = {
2323
__phantom?: (_: T) => void; // This is required for type constraint.
2424

2525
/**

matcher_test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { assertType, type IsExact } from "@std/testing/types";
22
import { DenopsStub } from "@denops/test/stub";
3-
import type { UnitDetail } from "./item.ts";
3+
import type { DetailUnit } from "./item.ts";
44
import type { Matcher, MatchParams } from "./matcher.ts";
55

66
Deno.test("Matcher", async (t) => {
77
const denops = new DenopsStub();
88

99
await t.step("without type constraint is equal to UnitDetail", () => {
10-
assertType<IsExact<Matcher, Matcher<UnitDetail>>>(true);
10+
assertType<IsExact<Matcher, Matcher<DetailUnit>>>(true);
1111
});
1212

1313
await t.step("match follows the type constraint", () => {
@@ -19,6 +19,6 @@ Deno.test("Matcher", async (t) => {
1919
// @ts-expect-error: 'a' is missing
2020
matcher.match(denops, {} as MatchParams<Detail>, {});
2121
// @ts-expect-error: 'a' is missing
22-
matcher.match(denops, {} as MatchParams<UnitDetail>, {});
22+
matcher.match(denops, {} as MatchParams<DetailUnit>, {});
2323
});
2424
});

previewer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Denops } from "@denops/std";
22
import type { Promish } from "./_typeutil.ts";
3-
import type { Detail, IdItem, PreviewItem, UnitDetail } from "./item.ts";
3+
import type { Detail, DetailUnit, IdItem, PreviewItem } from "./item.ts";
44

55
/**
66
* Parameters for previewing an item.
@@ -15,7 +15,7 @@ export type PreviewParams<T extends Detail> = {
1515
/**
1616
* Previewer that generates a preview for an item.
1717
*/
18-
export type Previewer<T extends Detail = UnitDetail> = {
18+
export type Previewer<T extends Detail = DetailUnit> = {
1919
/**
2020
* Generates a preview for the specified item.
2121
*

previewer_test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { assertType, type IsExact } from "@std/testing/types";
22
import { DenopsStub } from "@denops/test/stub";
3-
import type { UnitDetail } from "./item.ts";
3+
import type { DetailUnit } from "./item.ts";
44
import type { Previewer, PreviewParams } from "./previewer.ts";
55

66
Deno.test("Previewer", async (t) => {
77
const denops = new DenopsStub();
88

99
await t.step("without type constraint is equal to UnitDetail", () => {
10-
assertType<IsExact<Previewer, Previewer<UnitDetail>>>(true);
10+
assertType<IsExact<Previewer, Previewer<DetailUnit>>>(true);
1111
});
1212

1313
await t.step("preview follows the type constraint", () => {
@@ -23,6 +23,6 @@ Deno.test("Previewer", async (t) => {
2323
// @ts-expect-error: 'a' is missing
2424
previewer.preview(denops, {} as PreviewParams<Detail>, {});
2525
// @ts-expect-error: 'a' is missing
26-
previewer.preview(denops, {} as PreviewParams<UnitDetail>, {});
26+
previewer.preview(denops, {} as PreviewParams<DetailUnit>, {});
2727
});
2828
});

renderer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Denops } from "@denops/std";
22
import type { Promish } from "./_typeutil.ts";
3-
import type { Detail, DisplayItem, UnitDetail } from "./item.ts";
3+
import type { Detail, DetailUnit, DisplayItem } from "./item.ts";
44

55
/**
66
* Parameters for rendering items.
@@ -15,7 +15,7 @@ export type RenderParams<T extends Detail> = {
1515
/**
1616
* Renderer responsible for rendering items.
1717
*/
18-
export type Renderer<T extends Detail = UnitDetail> = {
18+
export type Renderer<T extends Detail = DetailUnit> = {
1919
/**
2020
* Renders items in place.
2121
*

renderer_test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { assertType, type IsExact } from "@std/testing/types";
22
import { DenopsStub } from "@denops/test/stub";
3-
import type { UnitDetail } from "./item.ts";
3+
import type { DetailUnit } from "./item.ts";
44
import type { Renderer, RenderParams } from "./renderer.ts";
55

66
Deno.test("Renderer", async (t) => {
77
const denops = new DenopsStub();
88

99
await t.step("without type constraint is equal to UnitDetail", () => {
10-
assertType<IsExact<Renderer, Renderer<UnitDetail>>>(true);
10+
assertType<IsExact<Renderer, Renderer<DetailUnit>>>(true);
1111
});
1212

1313
await t.step("render follows the type constraint", () => {
@@ -19,6 +19,6 @@ Deno.test("Renderer", async (t) => {
1919
// @ts-expect-error: 'a' is missing
2020
renderer.render(denops, {} as RenderParams<Detail>, {});
2121
// @ts-expect-error: 'a' is missing
22-
renderer.render(denops, {} as RenderParams<UnitDetail>, {});
22+
renderer.render(denops, {} as RenderParams<DetailUnit>, {});
2323
});
2424
});

sorter.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Denops } from "@denops/std";
22
import type { Promish } from "./_typeutil.ts";
3-
import type { Detail, IdItem, UnitDetail } from "./item.ts";
3+
import type { Detail, DetailUnit, IdItem } from "./item.ts";
44

55
/**
66
* Parameters for sorting items.
@@ -15,7 +15,7 @@ export type SortParams<T extends Detail> = {
1515
/**
1616
* Sorter that arranges items in order.
1717
*/
18-
export type Sorter<T extends Detail = UnitDetail> = {
18+
export type Sorter<T extends Detail = DetailUnit> = {
1919
/**
2020
* Sorts items in place.
2121
*

sorter_test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { assertType, type IsExact } from "@std/testing/types";
22
import { DenopsStub } from "@denops/test/stub";
3-
import type { UnitDetail } from "./item.ts";
3+
import type { DetailUnit } from "./item.ts";
44
import type { Sorter, SortParams } from "./sorter.ts";
55

66
Deno.test("Sorter", async (t) => {
77
const denops = new DenopsStub();
88

99
await t.step("without type constraint is equal to UnitDetail", () => {
10-
assertType<IsExact<Sorter, Sorter<UnitDetail>>>(true);
10+
assertType<IsExact<Sorter, Sorter<DetailUnit>>>(true);
1111
});
1212

1313
await t.step("sort follows the type constraint", () => {
@@ -19,6 +19,6 @@ Deno.test("Sorter", async (t) => {
1919
// @ts-expect-error: 'a' is missing
2020
sorter.sort(denops, {} as SortParams<Detail>, {});
2121
// @ts-expect-error: 'a' is missing
22-
sorter.sort(denops, {} as SortParams<UnitDetail>, {});
22+
sorter.sort(denops, {} as SortParams<DetailUnit>, {});
2323
});
2424
});

0 commit comments

Comments
 (0)