Make all Svelte events type-safe

Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
Rūdolfs Ošiņš
2022-11-07 18:00:24 +01:00
parent 83d943177b
commit bc43fc4fef
20 changed files with 59 additions and 49 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
<script lang="ts">
<script lang="ts" strictEvents>
import { onMount, createEventDispatcher } from "svelte";
import { setRecords } from "./resolver";
import type { EnsRecord } from "./resolver";
@@ -15,7 +15,7 @@
export let records: EnsRecord[];
export let registration: Registration;
const dispatch = createEventDispatcher();
const dispatch = createEventDispatcher<{ close: never }>();
let state: State = {
status: Status.Failed,
+5 -9
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import type { EnsRecord } from "./resolver";
import type { Field } from "@app/Form.svelte";
import type { Field, RegistrationRecord } from "@app/Form.svelte";
import type { Registration } from "./registrar";
import type { Wallet } from "@app/wallet";
import type { ethers } from "ethers";
@@ -169,16 +169,12 @@
});
});
const onSave = async (event: {
detail: { name: string; value: string | null }[];
}) => {
const onSave = async (event: { detail: RegistrationRecord[] }) => {
assert(state.status === Status.Found, "registration must be found");
updateRecords = event.detail
.filter(f => f.value !== null)
.map(f => {
return { name: f.name, value: f.value as string };
});
updateRecords = event.detail.map(f => {
return { name: f.name, value: f.value };
});
};
$: if (retry && state.status === Status.NotFound && retries > 0) {