You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks to the automatic type generation we get advanced type safety. Wouldn't it be great though if we could just omit writing the types at all? As of today you can do exactly that:
Copy file name to clipboardExpand all lines: apps/svelte.dev/content/docs/kit/20-core-concepts/60-remote-functions.md
+21-2Lines changed: 21 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -524,7 +524,14 @@ In addition to declarative schema validation, you can programmatically mark fiel
524
524
- It accepts multiple arguments that can be strings (for issues relating to the form as a whole — these will only show up in `fields.allIssues()`) or standard-schema-compliant issues (for those relating to a specific field). Use the `issue` parameter for type-safe creation of such issues:
525
525
526
526
```js
527
+
// @errors: 18046
527
528
/// file: src/routes/shop/data.remote.js
529
+
// @filename: ambient.d.ts
530
+
declare module'$lib/server/database' {
531
+
exportfunctionbuy(qty:number): Promise<void>
532
+
}
533
+
// @filename: index.js
534
+
// ---cut---
528
535
import*asvfrom'valibot';
529
536
import { invalid } from'@sveltejs/kit';
530
537
import { form } from'$app/server';
@@ -1166,7 +1173,7 @@ As long as _you're_ not passing invalid data to your remote functions, there are
1166
1173
In the second case, we don't want to give the attacker any help, so SvelteKit will generate a generic [400 Bad Request](https://http.dog/400) response. You can control the message by implementing the [`handleValidationError`](hooks#Server-hooks-handleValidationError) server hook, which, like [`handleError`](hooks#Shared-hooks-handleError), must return an [`App.Error`](errors#Type-safety) (which defaults to `{ message: string }`):
Copy file name to clipboardExpand all lines: apps/svelte.dev/content/docs/kit/25-build-and-deploy/50-adapter-static.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,7 @@ This will prerender your entire site as a collection of static files. If you'd l
12
12
Install with `npm i -D @sveltejs/adapter-static`, then add the adapter to your `svelte.config.js`:
13
13
14
14
```js
15
+
// @errors: 2307
15
16
/// file: svelte.config.js
16
17
importadapterfrom'@sveltejs/adapter-static';
17
18
@@ -56,6 +57,7 @@ Some platforms have zero-config support (more to come in future):
56
57
On these platforms, you should omit the adapter options so that `adapter-static` can provide the optimal configuration:
57
58
58
59
```js
60
+
// @errors: 2307
59
61
/// file: svelte.config.js
60
62
importadapterfrom'@sveltejs/adapter-static';
61
63
@@ -81,7 +83,7 @@ The directory to write static assets (the contents of `static`, plus client-side
81
83
82
84
### fallback
83
85
84
-
To create a [single page app (SPA)](single-page-apps) you must specify the name of the fallback page to be generated by SvelteKit, which is used as the entry point for URLs that have not been prerendered. This is commonly `200.html`, but can vary depending on your deployment platform. You should avoid `index.html` where possible to avoid conflicting with a prerendered homepage.
86
+
To create a [single page app (SPA)](single-page-apps) you must specify the name of the fallback page to be generated by SvelteKit, which is used as the entry point for URLs that have not been prerendered. This is commonly `200.html`, but can vary depending on your deployment platform. You should avoid `index.html` where possible to avoid conflicting with a prerendered homepage.
85
87
86
88
> This option has large negative performance and SEO impacts. It is only recommended in certain circumstances such as wrapping the site in a mobile app. See the [single page apps](single-page-apps) documentation for more details and alternatives.
87
89
@@ -102,7 +104,7 @@ You'll also want to generate a fallback `404.html` page to replace the default 4
102
104
A config for GitHub Pages might look like the following:
Copy file name to clipboardExpand all lines: apps/svelte.dev/content/docs/kit/25-build-and-deploy/55-single-page-apps.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,7 @@ export const ssr = false;
20
20
If you don't have any server-side logic (i.e. `+page.server.js`, `+layout.server.js` or `+server.js` files) you can use [`adapter-static`](adapter-static) to create your SPA. Install `adapter-static` with `npm i -D @sveltejs/adapter-static` and add it to your `svelte.config.js` with the `fallback` option:
Copy file name to clipboardExpand all lines: apps/svelte.dev/content/docs/kit/25-build-and-deploy/80-adapter-netlify.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,7 @@ This adapter will be installed by default when you use [`adapter-auto`](adapter-
12
12
Install with `npm i -D @sveltejs/adapter-netlify`, then add the adapter to your `svelte.config.js`:
13
13
14
14
```js
15
+
// @errors: 2307
15
16
/// file: svelte.config.js
16
17
importadapterfrom'@sveltejs/adapter-netlify';
17
18
@@ -54,6 +55,7 @@ New projects will use the current Node LTS version by default. However, if you'r
54
55
SvelteKit supports [Netlify Edge Functions](https://docs.netlify.com/build/edge-functions/overview/). If you pass the option `edge: true` to the `adapter` function, server-side rendering will happen in a Deno-based edge function that's deployed close to the site visitor. If set to `false` (the default), the site will deploy to Node-based Netlify Functions.
@@ -98,4 +99,4 @@ Now, server-side requests will begin generating traces, which you can view in Ja
98
99
99
100
## `@opentelemetry/api`
100
101
101
-
SvelteKit uses `@opentelemetry/api` to generate its spans. This is declared as an optional peer dependency so that users not needing traces see no impact on install size or runtime performance. In most cases, if you're configuring your application to collect SvelteKit's spans, you'll end up installing a library like `@opentelemetry/sdk-node` or `@vercel/otel`, which in turn depend on `@opentelemetry/api`, which will satisfy SvelteKit's dependency as well. If you see an error from SvelteKit telling you it can't find `@opentelemetry/api`, it may just be because you haven't set up your trace collection yet. If you _have_ done that and are still seeing the error, you can install `@opentelemetry/api` yourself.
102
+
SvelteKit uses `@opentelemetry/api` to generate its spans. This is declared as an optional peer dependency so that users not needing traces see no impact on install size or runtime performance. In most cases, if you're configuring your application to collect SvelteKit's spans, you'll end up installing a library like `@opentelemetry/sdk-node` or `@vercel/otel`, which in turn depend on `@opentelemetry/api`, which will satisfy SvelteKit's dependency as well. If you see an error from SvelteKit telling you it can't find `@opentelemetry/api`, it may just be because you haven't set up your trace collection yet. If you _have_ done that and are still seeing the error, you can install `@opentelemetry/api` yourself.
0 commit comments