NullBitMeN
Deno15mo ago
NullBitMe

SvelteKit ./$types can't be found in +page.server.ts

VSCode: 1.94.2
OS: MacOS Sequoia 15.0.1
Deno: 2.0.2
Deno Extension: 3.42.0
Typescript: 5.6.3

After some research/testing I can't get Deno 2.0.2 to find ./$types for sveltekit. I'm not sure if i need to explicitly reference the generated
tsconfig.json
or I'm missing something else. A current workaround is to import from a much longer relative path (ie import type { PageServerLoad } from "../../.svelte-kit/types/src/routes/$types.d.ts";) but of course ./$types) would be preferred.

This is the exact error vscode intellisense is giving me:
Unable to load a local module: file:///Users/USERNAME/projects/deno-deno/src/routes/$types  
Please check the file path.deno(no-local)

**Resolved Dependency**

**Code**: file​:///Users/USERNAME/projects/deno-deno/src/routes/$types

module "/Users/USERNAME/projects/deno-deno/.svelte-kit/types/src/routes/$types"



This is the smallest reproduction I could create:

$: deno --version
deno 2.0.2 (stable, release, aarch64-apple-darwin)
v8 12.9.202.13-rusty
typescript 5.6.2

$: deno run -A npm:create-svelte@latest
> Skeleton project
> Use TypeScript syntax
> 0 additional options selected


Run "Deno: Enable" in vscode command palette to create .vscode/settings.json with this content:

{
  "deno.enable": true
}


$: deno add -D npm:@deno/vite-plugin


Use the deno vite plugin in vite.config.ts:
import deno from "@deno/vite-plugin";
import { sveltekit } from "@sveltejs/kit/vite";
import { defineConfig } from "vite";

export default defineConfig({
  plugins: [deno(), sveltekit()],
});


$: deno install --allow-scripts


I create a src/routes/+page.server.ts file with the following data

import { type PageServerLoad } from "./$types"; // Type error here

export const load: PageServerLoad = () => {
  return { test: 123 };
};


Thanks for any help you can offer!
Was this page helpful?