Skip to content

Commit

Permalink
fix: make defaultHandler required argument of onwarn (#895)
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikg committed May 5, 2024
1 parent 6853630 commit bd5e3c2
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/friendly-actors-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/vite-plugin-svelte': patch
---

fix: make defaultHandler a required argument for onwarn in plugin options
2 changes: 1 addition & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ These options are specific to the Svelte compiler and are generally shared acros

### onwarn

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

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

Expand Down
12 changes: 11 additions & 1 deletion packages/vite-plugin-svelte/src/public.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,18 @@ export interface SvelteConfig {

/**
* Handles warning emitted from the Svelte compiler
*
* @example
* ```
* (warning, defaultHandler) => {
* // ignore some warnings
* if (!['foo','bar'].includes(warning.code)) {
* defaultHandler(warning);
* }
* }
* ```
*/
onwarn?: (warning: Warning, defaultHandler?: (warning: Warning) => void) => void;
onwarn?: (warning: Warning, defaultHandler: (warning: Warning) => void) => void;
/**
* Options for vite-plugin-svelte
*/
Expand Down
12 changes: 11 additions & 1 deletion packages/vite-plugin-svelte/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,18 @@ declare module '@sveltejs/vite-plugin-svelte' {

/**
* Handles warning emitted from the Svelte compiler
*
* @example
* ```
* (warning, defaultHandler) => {
* // ignore some warnings
* if (!['foo','bar'].includes(warning.code)) {
* defaultHandler(warning);
* }
* }
* ```
*/
onwarn?: (warning: Warning, defaultHandler?: (warning: Warning) => void) => void;
onwarn?: (warning: Warning, defaultHandler: (warning: Warning) => void) => void;
/**
* Options for vite-plugin-svelte
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/vite-plugin-svelte/types/index.d.ts.map
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
null,
null
],
"mappings": ";;;;aAMYA,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA6GFC,YAAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA2DZC,qBAAqBA;;;;;;;;;;;;;iBCtJtBC,MAAMA;iBCTNC,cAAcA;iBCgBRC,gBAAgBA"
"mappings": ";;;;aAMYA,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA6GFC,YAAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAqEZC,qBAAqBA;;;;;;;;;;;;;iBChKtBC,MAAMA;iBCTNC,cAAcA;iBCgBRC,gBAAgBA"
}

0 comments on commit bd5e3c2

Please sign in to comment.