Types presentation
Edit this page on GitHubBrainstorming ideas for better presentation of types.
Compare the (WIP) examples below with https://kit.svelte.dev/docs/types#sveltejs-kit-cookies, https://kit.svelte.dev/docs/types#sveltejs-kit-config, https://kit.svelte.dev/docs/types#sveltejs-kit-kitconfig and https://kit.svelte.dev/docs/configuration.
The idea is that we'd generate this automatically from types/index.d.ts etc (including @example and @default tags), and configuration would be documented this way rather than via the hand-written https://kit.svelte.dev/docs/configuration.
@sveltejs/kitpermalink
Cookiespermalink
An interface for interacting with cookies during a request.
tsget (name ,opts ):string |undefined
name: stringThe name of the cookieopts?: import('cookie').CookieParseOptionsAn object containing an optionaldecodefunction
Gets a cookie that was previously set with cookies.set, or from the request headers.
tsset (name ,value ,opts ): void;
name: stringThe name of the cookievalue: stringThe cookie valueopts?: import('cookie').CookieSerializeOptionsTODO Cookie options
Sets a cookie. This will add a set-cookie header to the response, but also make the cookie available via cookies.get during the current request.
The httpOnly and secure options are true by default, and must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP. The sameSite option defaults to lax.
By default, the path of a cookie is the 'directory' of the current pathname. In most cases you should explicitly set path: '/' to make the cookie available throughout your app.
tsdelete(name ,opts ): void;
name: stringThe name of the cookievalue: stringThe cookie valueopts?: import('cookie').CookieSerializeOptionsTODO Cookie options
Deletes a cookie by setting its value to an empty string and setting the expiry date in the past.
tsserialize (name ,value ,opts ):string ;
name: stringthe name for the cookievalue: stringvalue to set the cookie toopts?: import('cookie').CookieSerializeOptionsTODO Cookie options
Serialize a cookie name-value pair into a Set-Cookie header string.
The httpOnly and secure options are true by default, and must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP. The sameSite option defaults to lax.
By default, the path of a cookie is the current pathname. In most cases you should explicitly set path: '/' to make the cookie available throughout your app.
Configpermalink
Your project's configuration, exported from svelte.config.js.
tscompilerOptions ?: CompileOptions
Svelte compiler options.
tsextensions ?: string []
An array of file extensions that should be treated as Svelte components.
Default value: ['.svelte']
ts
SvelteKit-specific configuration.
tspackage ?: {...}
source?: string"src/lib"Path to the source folder.dir?: string"package"Path to write the package toemitTypes?: booleantrueWhether to generate.d.tsfilesexports?: (filepath: string) => boolean() => trueWhether to include a file inpkg.exportsfiles?: (filepath: string) => boolean() => trueWhether to include a file in the package
Configuration for svelte-package
tspreprocess ?: any
Preprocessing options.
ts[key :string ]:any ;
Any additional options required by other tooling.
KitConfigpermalink
Your SvelteKit-specific configuration.
ts
Run when executing vite build and determines how the output is converted for different platforms. See Adapters.
Default value: undefined
tsalias ?: Record<string, string>
An object containing zero or more aliases used to replace values in import statements. These aliases are automatically passed to Vite and TypeScript.
svelte.config.js
tsconstconfig = {kit : {alias : {// this will match a file'my-file': 'path/to/my-file.js',// this will match a directory and its contents// (`my-directory/x` resolves to `path/to/my-directory/x`)'my-directory': 'path/to/my-directory',// an alias ending /* will only match// the contents of a directory, not the directory itself'my-directory/*': 'path/to/my-directory/*'}}};
svelte.config.ts
tskit : {alias : {// this will match a file'my-file': 'path/to/my-file.js',// this will match a directory and its contents// (`my-directory/x` resolves to `path/to/my-directory/x`)'my-directory': 'path/to/my-directory',// an alias ending /* will only match// the contents of a directory, not the directory itself'my-directory/*': 'path/to/my-directory/*'}}};
The built-in
$libalias is controlled byconfig.kit.files.libas it is used for packaging.
You will need to run
npm run devto have SvelteKit automatically generate the required alias configuration injsconfig.jsonortsconfig.json.
Default value: {}
tsappDir ?: string
Default value: '_app'
tscsp ?: {...}
mode?: 'hash' | 'nonce' | 'auto''auto'-directives?: CspDirectivesTODOreportOnly?: CspDirectivesTODO