-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
error: "Cannot use keyword 'await' outside an async function", why? #941
Comments
Why not just
|
Because I think is the same. I have double I would like to have only one How do you call that in components? |
The top-level await proposal hasn't reached stage 4 (accepted) and isn't supported by Acorn, the parser we're using. |
@Conduitry I read here that there is an option for acorn: How can I set this option in my svelte kit environment? |
I think with this I can write this code: const playerService = await player();
const { response } = await playerService.queryPlayers({ playerId: "1" });
if (response) {
players = response.players;
} instead of: (async () => {
const playerService = await player();
const { response } = await playerService.queryPlayers({ playerId: "1" });
if (response) {
players = response.players;
}
})(); Right? |
Describe the bug
In
./generated/index.ts
I'm using this code:Logs
Cannot use keyword 'await' outside an async function
Expected behavior
I would like to use this because I need lazy load of many files and I would like to use it like this in my components:
Information about your SvelteKit Installation:
Diagnostics
The output of
npx envinfo --system --npmPackages svelte,@sveltejs/kit,vite --binaries --browsers
:System:
OS: Windows 10 10.0.19042
Binaries:
Node: 14.16.1 - C:\Program Files\nodejs\node.EXE
npm: 7.8.0 - C:\Program Files\nodejs\npm.CMD
npmPackages:
@sveltejs/kit: 1.0.0-next.71 => 1.0.0-next.71
svelte: 3.37.0 => 3.37.0
vite: 2.1.5 => 2.1.5
Your browser: Chrome
Your adapter: static
The text was updated successfully, but these errors were encountered: