svelte-intellij icon indicating copy to clipboard operation
svelte-intellij copied to clipboard

Generated types dir is not recognized in Svelte compoenents

Open TheOnlyTails opened this issue 2 years ago • 5 comments

When trying to use generated types for the load function in SvelteKit, as such:

<script context="module" lang="ts">
  import type { Load } from "./__types/index";
</script>

I get the following error: image

my tsconfig.json is the standard one from the template:

Details
{
	"extends": "./.svelte-kit/tsconfig.json",
	"compilerOptions": {
		"allowJs": true,
		"checkJs": true,
		"esModuleInterop": true,
		"forceConsistentCasingInFileNames": true,
		"resolveJsonModule": true,
		"skipLibCheck": true,
		"sourceMap": true,
		"strict": true
	}
}

And the generated types work as expected in regular typescript files.

(Note: the aliases declared in SvelteKit's generated tsconfig.json work just fine. It's just the generated typedefs themselves which don't work)

TheOnlyTails avatar Jun 08 '22 13:06 TheOnlyTails

Now that https://github.com/sveltejs/kit/pull/5778 is merged, all page data is now typed with these generated props, which makes this very vital to have. Could this please be implemented soon?

TheOnlyTails avatar Aug 15 '22 22:08 TheOnlyTails

For now, a possible hack is to specify the full URL, but this just looks extremely fugly:

<script lang="ts">
    import type { PageData } from ".svelte-kit/types/src/routes/$types";
</script>

TheOnlyTails avatar Aug 15 '22 22:08 TheOnlyTails

What exactly is the error you are getting / what is wrong? I don't see anything red in the screenshot.

dummdidumm avatar Aug 16 '22 07:08 dummdidumm

the __types directory is red. Here's a screenshot from the new $types file: image

TheOnlyTails avatar Aug 16 '22 12:08 TheOnlyTails

~I can't reproduce this given the instructions. Please provide a proper minimum reproducible.~ scratch that, I didn't realize we are in the svelte-intellij repository, which I have no control over, sry 😢

dummdidumm avatar Aug 17 '22 07:08 dummdidumm

Migrating to YouTrack... Kind of an old issue, it works in 2023.1/2023.2.

tomblachut avatar Jul 04 '23 16:07 tomblachut