-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First class support for Svelte 5's $inspect() method #361
Comments
I meant for the logs that update when a state changes (not inside functions). Example (Counter.svelte): <script>
let count = $state(0)
// this gets logged on terminal initially and when `count` changes
$inspect(count) // [want CN log here]
// this was possible in svelte 4 & below (not anymore)
$: console.log(count) // [CN output was here, but this errors in svelte 5]
</script>
<button type="button" onclick={() => count++}>
{count}
</button>
In Svelte 5, the This function is defined here in Svelte source code: https://github.com/sveltejs/svelte/blob/main/packages/svelte/src/internal/client/dev/inspect.js |
Thanks for the sample. For now, you may work around the limitation by using the <script>
let count = $state(0)
$inspect(count).with((_type, count) => {
console.log(count);
});
</script>
<button type="button" onclick={() => count++}>
{count}
</button> We’ll keep this issue open as a feature request. To help us prioritize it, please like the original issue comment. This helps us gauge interest and understand demand for the feature. |
$inspect(...)
)
Seems like about a few more people want this too 😄 |
In Svelte 5, we can't do
$: console.log(...)
anymore (invalid syntax). This used to work with Console Ninja before Svelte 5. It has changed to the$inspect
rune now.This means that
console.log
now needs to be chained with$inspect(...).with
. For example:Ideally, would like to be able to use
$inspect(...)
without having to nestconsole.log
inside thewith
function.Docs: https://svelte.dev/docs/svelte/$inspect
The text was updated successfully, but these errors were encountered: