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
Copy file name to clipboardExpand all lines: docs/data-loaders/error-handling.md
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -148,3 +148,29 @@ When you use both, global and local error handling, the local error handling has
148
148
- if local `errors` is `false`: abort the navigation -> `data` is not `undefined`
149
149
- if local `errors` is `true`: rely on the globally defined `errors` option -> `data` is possibly `undefined`
150
150
- else: rely on the local `errors` option -> `data` is possibly `undefined`
151
+
152
+
## TypeScript
153
+
154
+
You will notice that the type of `error` is `Error | null` even when you specify the `errors` option. This is because if we call the `reload()` method (meaning we are outside of a navigation), the error isn't discarded, it appears in the `error` property **without being filtered** by the `errors` option.
155
+
156
+
In practice, depending on how you handle the error, you will add a [type guard](https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards) inside the component responsible for displaying an error or directly in a `v-if` in the template.
If you want to be even stricter, you can override the default `Error` type with `unknown` (or anything else) by augmenting the `TypesConfig` interface.
0 commit comments