denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
98k stars 5.39k forks source link

rootDirs and SvelteKit #26871

Open nshiab opened 1 week ago

nshiab commented 1 week ago

deno 2.0.6 (stable, release, aarch64-apple-darwin) v8 12.9.202.13-rusty typescript 5.6.2

Hi,

I am using SvelteKit and I am trying to reproduce this example:

import type { PageLoad } from './$types';

export const load: PageLoad = async ({ fetch, params }) => {
    const res = await fetch(`/api/items/${params.id}`);
    const item = await res.json();

    return { item };
};

But I have this error:

Screenshot 2024-11-14 at 9 53 54 AM

From what I understand, it's maybe because the default SvelteKit tsconfig.json has the rootDirs options set to ["..", "./types"] but this is not supported by Deno and/or the Deno VSCode extension.

{
  "extends": "./.svelte-kit/tsconfig.json",
  "compilerOptions": {
    "allowJs": true,
    "checkJs": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "sourceMap": true,
    "strict": true,
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "rootDirs": ["..", "./types"]
  }
  // Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
  // except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
  //
  // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
  // from the referenced tsconfig.json - TypeScript does not merge them in
}

Thank you!

bartlomieju commented 1 week ago

@nayeemrmn is already working on this