Skip to content

Commit

Permalink
fix: fix type error
Browse files Browse the repository at this point in the history
  • Loading branch information
SegaraRai committed Jul 16, 2024
1 parent 2d2306a commit 62c067c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions app/components/NatureApplianceControlAC.vue
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ const getSwipeByData = (offset: SwipeByOffset): SwipeByData | null => {
availableTemperatures.length - 1
);
const newTemperature = availableTemperatures[index];
const newTemperature = availableTemperatures[index]!;
const diff10 = Math.round(
Number(newTemperature) * 10 - Number(currentTemperature) * 10
);
Expand Down Expand Up @@ -454,7 +454,7 @@ const swipingTemperature = computed((): NatureApplianceACTemperature | null => {
Math.max(currentIndex + offset, 0),
availableTemperatures.length - 1
);
return availableTemperatures[index];
return availableTemperatures[index]!;
});
/**
Expand Down
4 changes: 2 additions & 2 deletions app/components/ThemeSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ const items = computed(() => [
const current = computed(
() =>
items.value.find((item) => item.value === colorMode.preference) ??
items.value[0]
items.value[0]!
);
const toggle = (): void => {
const currentIndex = items.value.findIndex(
(item) => item.value === colorMode.preference
);
colorMode.preference =
items.value[(currentIndex + 1) % items.value.length].value;
items.value[(currentIndex + 1) % items.value.length]!.value;
};
</script>
2 changes: 1 addition & 1 deletion nitroSWPreset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const collectHashes = async (nitro: object, html: string): Promise<void> => {
}

for (const match of html.matchAll(/<script([^>]*)>([\s\S]*?)<\/script>/g)) {
if (!match[2] || match[1].includes("application/json")) {
if (!match[2] || match[1]!.includes("application/json")) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion server/utils/natureAPICache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const natureAPICache = new LRUCache<string, CacheValue, FetchContext>({
{ signal, context: { timestamp, token, waitUntil } }
): Promise<CacheValue> => {
try {
const [userId, method, url] = key.split("\0");
const [userId, method, url] = key.split("\0") as [string, string, string];
const res = await fetch(url, {
method,
headers: createNatureAPIRequestHeaderInit(token),
Expand Down
22 changes: 11 additions & 11 deletions server/utils/serial.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function createPromise(): [Promise<void>, () => void] {
}

test("should return function that executes specified function", () => {
const fn = vi.fn<[], Promise<void>>().mockResolvedValue(undefined);
const fn = vi.fn<() => Promise<void>>().mockResolvedValue(undefined);
const serial = createSerial(fn);
expectTypeOf(serial).toBeFunction();
serial();
Expand All @@ -31,18 +31,18 @@ test("should not call next one until running one finishes", async () => {
});

expect(resolves).toHaveLength(1);
expect(promises[0][1]).not.toHaveBeenCalled();
expect(promises[1][1]).not.toHaveBeenCalled();
resolves[0]();
await promises[0][0];
expect(promises[0][1]).toHaveBeenCalled();
expect(promises[1][1]).not.toHaveBeenCalled();
expect(promises[0]![1]).not.toHaveBeenCalled();
expect(promises[1]![1]).not.toHaveBeenCalled();
resolves[0]!();
await promises[0]![0];
expect(promises[0]![1]).toHaveBeenCalled();
expect(promises[1]![1]).not.toHaveBeenCalled();

expect(resolves).toHaveLength(2);
resolves[1]();
await promises[1][0];
expect(promises[1][1]).toHaveBeenCalled();
expect(promises[19][1]).toHaveBeenCalled();
resolves[1]!();
await promises[1]![0];
expect(promises[1]![1]).toHaveBeenCalled();
expect(promises[19]![1]).toHaveBeenCalled();

expect(resolves).toHaveLength(2);
});

0 comments on commit 62c067c

Please sign in to comment.