joysofcode/sveltekit-markdown-blog

Binding problems

Closed this issue ยท 1 comments

walking through your fabulous post... using sveltekit@latest

when I got through to /src/routes/+page.server.ts (which doesn't appear to exist in the current repo ๐Ÿค”, even though it is documented in your article)

getting a typescript error on fetch

import type { Post } from '$lib/types'

export async function load({ fetch }){
    const response = await fetch('api/posts')
    const posts: Post[] = await response.json()
    return { posts }
}

Binding element 'fetch' implicitly has an 'any' type.

continuing on through to /src/routes/[slug]/+page.ts

getting a similar typescript error, this time on params

import { error } from '@sveltejs/kit'

export async function load({ params }){
    try {
        const post = await import(`../../posts/${params.slug}.md`)

        return {
            content: post.default,
            meta: post.metadata
        }

    } catch (e) {
        error(404, 'Could not find ${parms.slug}')
    }
}

Binding element 'params' implicitly has an 'any' type.

Later came again across typescript error on fetch in /src/routes/rss.xml/+server.ts

import * as config from '$lib/config'
import type { Post } from '$lib/types'

export async function GET({ fetch }) {
	const response = await fetch('api/posts')
	const posts: Post[] = await response.json()

	// ...
}

Binding element 'fetch' implicitly has an 'any' type.

For reference, npm ls of packages and versions:
โ”œโ”€โ”€ @fontsource/jetbrains-mono@5.0.19
โ”œโ”€โ”€ @fontsource/manrope@5.0.19
โ”œโ”€โ”€ @sveltejs/adapter-auto@3.2.0
โ”œโ”€โ”€ @sveltejs/kit@2.5.5
โ”œโ”€โ”€ @sveltejs/vite-plugin-svelte@3.0.2
โ”œโ”€โ”€ @types/eslint@8.56.7
โ”œโ”€โ”€ @typescript-eslint/eslint-plugin@7.5.0
โ”œโ”€โ”€ @typescript-eslint/parser@7.5.0
โ”œโ”€โ”€ eslint-config-prettier@9.1.0
โ”œโ”€โ”€ eslint-plugin-svelte@2.35.1
โ”œโ”€โ”€ eslint@8.57.0
โ”œโ”€โ”€ lucide-svelte@0.364.0
โ”œโ”€โ”€ mdsvex@0.11.0
โ”œโ”€โ”€ open-props@1.7.0
โ”œโ”€โ”€ prettier-plugin-svelte@3.2.2
โ”œโ”€โ”€ prettier@3.2.5
โ”œโ”€โ”€ rehype-slug@6.0.0
โ”œโ”€โ”€ remark-toc@9.0.0
โ”œโ”€โ”€ remark-unwrap-images@4.0.0
โ”œโ”€โ”€ shiki@1.2.4
โ”œโ”€โ”€ svelte-check@3.6.9
โ”œโ”€โ”€ svelte@4.2.12
โ”œโ”€โ”€ tslib@2.6.2
โ”œโ”€โ”€ typescript@5.4.3
โ””โ”€โ”€ vite@5.2.8

Started over with

npm init svelte@2.5

and after some struggles, it is working, but gonna start adapting for svelte@latest (shown in previous post)