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: MIGRATION.md
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,3 +50,20 @@ These types are no longer re-exported from `@vitejs/devtools-kit`. Import them f
50
50
```
51
51
52
52
The `@vitejs/devtools-kit/utils/when` subpath remains and re-exports these types alongside `evaluateWhen` and `resolveContextValue`.
53
+
54
+
#### Diagnostic handles are callable
55
+
56
+
`nostics` 0.2 (pulled in via devframe 0.4) drops the `.report()` / `.throw()` methods on diagnostic handles. Each handle is now a callable that builds and emits a diagnostic; prefix with `throw` to raise.
57
+
58
+
```diff
59
+
- throw ctx.diagnostics.logger.MYP0001.throw({ name })
60
+
+ throw ctx.diagnostics.logger.MYP0001({ name })
61
+
62
+
- ctx.diagnostics.logger.MYP0002.report()
63
+
+ ctx.diagnostics.logger.MYP0002()
64
+
65
+
- ctx.diagnostics.logger.MYP0002.report({ name }, { method: 'error' })
66
+
+ ctx.diagnostics.logger.MYP0002({ name }, { method: 'error' })
67
+
```
68
+
69
+
The payload shape (including `cause`) and the optional reporter-options second argument are unchanged. Apply the same rewrite to typed handles returned from `ctx.diagnostics.defineDiagnostics()`.
Copy file name to clipboardExpand all lines: docs/kit/diagnostics.md
+15-11Lines changed: 15 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,8 @@
13
13
interfaceDevToolsDiagnosticsHost {
14
14
/**
15
15
* Proxy-backed lookup of every registered code by name. Each entry is a
16
-
* `nostics` handle with `.report()` and `.throw()` methods.
16
+
* `nostics` `DiagnosticHandle` — a callable that builds a diagnostic and
17
+
* routes it through registered reporters; prefix with `throw` to raise.
17
18
*/
18
19
readonly logger:Record<string, any>
19
20
@@ -56,7 +57,7 @@ export function MyPlugin(): PluginWithDevTools {
56
57
ctx.diagnostics.register(diagnostics)
57
58
58
59
// Emit codes through the shared lookup:
59
-
ctx.diagnostics.logger.MYP0002.report()
60
+
ctx.diagnostics.logger.MYP0002()
60
61
},
61
62
},
62
63
}
@@ -80,23 +81,26 @@ Each definition supports `why` (string or function returning a string) and an op
80
81
81
82
## Emit a diagnostic
82
83
83
-
Each registered code is reachable as a property on `ctx.diagnostics.logger`. Every handle exposes `.throw(params)` and `.report(params)`.
84
+
Each registered code is reachable as a property on `ctx.diagnostics.logger`. Every handle is a callable — invoke it to report (returns the `Diagnostic`), or prefix with `throw` to raise.
-**[`ctx.messages`](./messages)** — user-facing activity surfaces in the DevTools UI: progress indicators, audit results, "URL copied" toasts. Just a message and a level.
140
144
141
145
Diagnostics target tool authors and CI; messages target the human in front of the DevTools panel.
0 commit comments