Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] add explicit types to examples #2657

Merged
merged 7 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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` for TypeScript and ESLint integration example
ignatiusmb marked this conversation as resolved.
Show resolved Hide resolved
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