Skip to content

Commit bd5e3c2

Browse files
authored
fix: make defaultHandler required argument of onwarn (#895)
1 parent 6853630 commit bd5e3c2

File tree

5 files changed

+29
-4
lines changed

5 files changed

+29
-4
lines changed

.changeset/friendly-actors-relate.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/vite-plugin-svelte': patch
3+
---
4+
5+
fix: make defaultHandler a required argument for onwarn in plugin options

docs/config.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ These options are specific to the Svelte compiler and are generally shared acros
126126

127127
### onwarn
128128

129-
- **Type:** `(warning: Warning, defaultHandler?: (warning: Warning) => void) => void` - See [Warning](https://github.com/sveltejs/svelte/blob/ce550adef65a7e04c381b11c24f07a2ae1c25783/src/compiler/interfaces.ts#L121-L130)
129+
- **Type:** `(warning: Warning, defaultHandler: (warning: Warning) => void) => void` - See [Warning](https://github.com/sveltejs/svelte/blob/ce550adef65a7e04c381b11c24f07a2ae1c25783/src/compiler/interfaces.ts#L121-L130)
130130

131131
Handles warning emitted from the Svelte compiler. Useful to suppress warning messages.
132132

packages/vite-plugin-svelte/src/public.d.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,18 @@ export interface SvelteConfig {
137137

138138
/**
139139
* Handles warning emitted from the Svelte compiler
140+
*
141+
* @example
142+
* ```
143+
* (warning, defaultHandler) => {
144+
* // ignore some warnings
145+
* if (!['foo','bar'].includes(warning.code)) {
146+
* defaultHandler(warning);
147+
* }
148+
* }
149+
* ```
140150
*/
141-
onwarn?: (warning: Warning, defaultHandler?: (warning: Warning) => void) => void;
151+
onwarn?: (warning: Warning, defaultHandler: (warning: Warning) => void) => void;
142152
/**
143153
* Options for vite-plugin-svelte
144154
*/

packages/vite-plugin-svelte/types/index.d.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,18 @@ declare module '@sveltejs/vite-plugin-svelte' {
135135

136136
/**
137137
* Handles warning emitted from the Svelte compiler
138+
*
139+
* @example
140+
* ```
141+
* (warning, defaultHandler) => {
142+
* // ignore some warnings
143+
* if (!['foo','bar'].includes(warning.code)) {
144+
* defaultHandler(warning);
145+
* }
146+
* }
147+
* ```
138148
*/
139-
onwarn?: (warning: Warning, defaultHandler?: (warning: Warning) => void) => void;
149+
onwarn?: (warning: Warning, defaultHandler: (warning: Warning) => void) => void;
140150
/**
141151
* Options for vite-plugin-svelte
142152
*/

packages/vite-plugin-svelte/types/index.d.ts.map

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@
2121
null,
2222
null
2323
],
24-
"mappings": ";;;;aAMYA,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA6GFC,YAAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA2DZC,qBAAqBA;;;;;;;;;;;;;iBCtJtBC,MAAMA;iBCTNC,cAAcA;iBCgBRC,gBAAgBA"
24+
"mappings": ";;;;aAMYA,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA6GFC,YAAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAqEZC,qBAAqBA;;;;;;;;;;;;;iBChKtBC,MAAMA;iBCTNC,cAAcA;iBCgBRC,gBAAgBA"
2525
}

0 commit comments

Comments
 (0)