Skip to content

+page.(server.)ts files cannot import types when reference exists with no .d.ts files #2786

Closed
@MarlonH1

Description

@MarlonH1

Describe the bug

I already made an Issue but it turns out, it may be the LSP, not Svelte Kit.

The Situation

We have SvelteKit as frontend only, (for SSR)
A seperate typescript backend using trpc (the issue is not with trpc itself)

I noticed by only importing directly from backend, I can freely use the types in normal .ts, +page.server.ts and svelte.ts. But this is limited, since the moment I want to use path alias in my backend project, the frontend project fails to resolve the files. So to fix that, I want to add a project reference to the tsconfig.json. Doing that succesfully resolves my types, in both normal .ts files and +page.svelte files, but now importing trpc in +page.server.ts does not work, the type is any.

You can test for yourselves with the reproduction I uploaded, and it should also present the a real world use case.

Reproduction

reproduction.zip

Expected behaviour

I should be able to specify a project reference in the tsconfig, and my types should resolve in +page.svelte.ts

System Info

  • OS: [e.g. Windows]
  • IDE: [e.g. VSCode, Cursor]

Which package is the issue about?

svelte-language-server, Svelte for VS Code extension

Additional Information, eg. Screenshots

With reference:
+page.server.ts
Image
+page.svelte
Image

Without reference (Using path alias in backend will break it)
+page.server.ts
Image
+page.svelte
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedFixed in master branch. Pending production release.bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions