Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐞] loader$ yields TS4023: Exported variable has or is using name 'ServerLoader' from external module #2783

Closed
adaliszk opened this issue Feb 2, 2023 · 3 comments · Fixed by #5141
Labels
STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working

Comments

@adaliszk
Copy link
Contributor

adaliszk commented Feb 2, 2023

Which component is affected?

Qwik City (routing)

Describe the bug

When using the new loader$ like:

import { loader$ } from '@builder.io/qwik-city'

export const myContent = loader$(() => myData)

The exported data loader is yielding a typescript warning:

TS4023: Exported variable 'myContent' has or is using name 'ServerLoader' from external module

The cure for this is usually straightforward; it just needs the type declared:

export const myContent: ServerLoader<MyType> = loader$(() => myData)

However, this is impossible because ServerLoader is not exported out.

Reproduction

https://stackblitz.com/edit/qwik-starter-5zm2al?file=src/routes/index.tsx

Steps to reproduce

To see the error, you need to enable declarations in your tsconfig.

System Info

System (WSL):
- OS: Linux 5.15 Alpine Linux
- CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
- Memory: 12.72 GB / 15.57 GB
- Container: Yes
- Shell: 5.9 - /bin/zsh

Binaries:
- Node: 18.12.1 - /usr/bin/node
- Yarn: 3.3.1 - /usr/bin/yarn
- npm: 9.1.2 - /usr/bin/npm

Additional Information

The missing type does not break the build but is reported as an error in Jetbrains and Vscode. A quick solution for this would be to export out the ServerLoader so that it is available to be used as a type.

@adaliszk adaliszk added TYPE: bug Something isn't working STATUS-1: needs triage New issue which needs to be triaged labels Feb 2, 2023
@stackblitz
Copy link

stackblitz bot commented Feb 2, 2023

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@adaliszk
Copy link
Contributor Author

adaliszk commented Feb 2, 2023

For a potential use-case, with the declarations, one could create or potentially generate the loader$'s as a client and share it as a package with types pre-compiled to minimise the compilation burden.

@manucorporat
Copy link
Contributor

Fixed in latest QwikCity beta!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants