Skip to content

Commit

Permalink
[fix] add explicit types to examples (#2657)
Browse files Browse the repository at this point in the history
Fixes ESLint and TypeScript integration in _api.ts and form.ts example files

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
  • Loading branch information
ignatiusmb and dummdidumm authored Oct 21, 2021
1 parent 2db01fb commit a575544
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/poor-cameras-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-svelte': patch
---

Add explicit types in `_api.ts` and `form.ts` for TypeScript and ESLint integration example
4 changes: 2 additions & 2 deletions packages/create-svelte/templates/default/src/lib/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export function enhance(
error?: (res: Response, error: Error, form: HTMLFormElement) => void;
result: (res: Response, form: HTMLFormElement) => void;
}
) {
let current_token: {};
): { destroy: () => void } {
let current_token: unknown;

async function handle_submit(e: Event) {
const token = (current_token = {});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Request } from '@sveltejs/kit';
import type { EndpointOutput, Request } from '@sveltejs/kit';
import type { Locals } from '$lib/types';

/*
Expand All @@ -14,7 +14,11 @@ import type { Locals } from '$lib/types';

const base = 'https://api.svelte.dev';

export async function api(request: Request<Locals>, resource: string, data?: {}) {
export async function api(
request: Request<Locals>,
resource: string,
data?: Record<string, unknown>
): Promise<EndpointOutput> {
// user must have a cookie set
if (!request.locals.userid) {
return { status: 401 };
Expand Down

0 comments on commit a575544

Please sign in to comment.