Skip to content

Commit 06e1d2c

Browse files
authored
fix: extend Svelte Config type (#13982)
* extend svelte config type * changeset * format * add link to vite-plugin-svelte config options
1 parent d4c0a81 commit 06e1d2c

File tree

3 files changed

+21
-32
lines changed

3 files changed

+21
-32
lines changed

.changeset/mean-horses-divide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
fix: extend `vite-plugin-svelte`'s `Config` type instead of duplicating it

packages/kit/src/exports/public.d.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'svelte'; // pick up `declare module "*.svelte"`
22
import 'vite/client'; // pick up `declare module "*.jpg"`, etc.
33
import '../types/ambient.js';
44

5-
import { CompileOptions } from 'svelte/compiler';
65
import {
76
AdapterEntry,
87
CspDirectives,
@@ -18,7 +17,7 @@ import {
1817
RouteSegment
1918
} from '../types/private.js';
2019
import { BuildData, SSRNodeLoader, SSRRoute, ValidatedConfig } from 'types';
21-
import type { PluginOptions } from '@sveltejs/vite-plugin-svelte';
20+
import type { SvelteConfig } from '@sveltejs/vite-plugin-svelte';
2221

2322
export { PrerenderOption } from '../types/private.js';
2423

@@ -188,23 +187,16 @@ export interface Builder {
188187
compress: (directory: string) => Promise<void>;
189188
}
190189

191-
export interface Config {
192-
/**
193-
* Options passed to [`svelte.compile`](https://svelte.dev/docs/svelte/svelte-compiler#CompileOptions).
194-
* @default {}
195-
*/
196-
compilerOptions?: CompileOptions;
190+
/**
191+
* An extension of [`vite-plugin-svelte`'s options](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#svelte-options).
192+
*/
193+
export interface Config extends SvelteConfig {
197194
/**
198-
* List of file extensions that should be treated as Svelte files.
199-
* @default [".svelte"]
195+
* SvelteKit options.
196+
*
197+
* @see https://svelte.dev/docs/kit/configuration
200198
*/
201-
extensions?: string[];
202-
/** SvelteKit options */
203199
kit?: KitConfig;
204-
/** Preprocessor options, if any. Preprocessing can alternatively also be done through Vite's preprocessor capabilities. */
205-
preprocess?: any;
206-
/** `vite-plugin-svelte` plugin options. */
207-
vitePlugin?: PluginOptions;
208200
/** Any additional options required by tooling that integrates with Svelte. */
209201
[key: string]: any;
210202
}

packages/kit/types/index.d.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
/// <reference types="vite/client" />
33

44
declare module '@sveltejs/kit' {
5-
import type { CompileOptions } from 'svelte/compiler';
6-
import type { PluginOptions } from '@sveltejs/vite-plugin-svelte';
5+
import type { SvelteConfig } from '@sveltejs/vite-plugin-svelte';
76
/**
87
* [Adapters](https://svelte.dev/docs/kit/adapters) are responsible for taking the production build and turning it into something that can be deployed to a platform of your choosing.
98
*/
@@ -170,23 +169,16 @@ declare module '@sveltejs/kit' {
170169
compress: (directory: string) => Promise<void>;
171170
}
172171

173-
export interface Config {
174-
/**
175-
* Options passed to [`svelte.compile`](https://svelte.dev/docs/svelte/svelte-compiler#CompileOptions).
176-
* @default {}
177-
*/
178-
compilerOptions?: CompileOptions;
172+
/**
173+
* An extension of [`vite-plugin-svelte`'s options](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#svelte-options).
174+
*/
175+
export interface Config extends SvelteConfig {
179176
/**
180-
* List of file extensions that should be treated as Svelte files.
181-
* @default [".svelte"]
177+
* SvelteKit options.
178+
*
179+
* @see https://svelte.dev/docs/kit/configuration
182180
*/
183-
extensions?: string[];
184-
/** SvelteKit options */
185181
kit?: KitConfig;
186-
/** Preprocessor options, if any. Preprocessing can alternatively also be done through Vite's preprocessor capabilities. */
187-
preprocess?: any;
188-
/** `vite-plugin-svelte` plugin options. */
189-
vitePlugin?: PluginOptions;
190182
/** Any additional options required by tooling that integrates with Svelte. */
191183
[key: string]: any;
192184
}

0 commit comments

Comments
 (0)