mirror of https://github.com/sveltejs/svelte
correctly inspect derived values (#9731)
Co-authored-by: Rich Harris <rich.harris@vercel.com>pull/9736/head
parent
1108587f1b
commit
765d01d76c
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: improve `$inspect` type definition
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: correctly inspect derived values
|
@ -0,0 +1,31 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
/**
|
||||
* @type {any[]}
|
||||
*/
|
||||
let log;
|
||||
|
||||
export default test({
|
||||
compileOptions: {
|
||||
dev: true
|
||||
},
|
||||
|
||||
get props() {
|
||||
log = [];
|
||||
return {
|
||||
push: (/** @type {any} */ ...v) => log.push(...v)
|
||||
};
|
||||
},
|
||||
|
||||
async test({ assert, target }) {
|
||||
const button = target.querySelector('button');
|
||||
|
||||
button?.click();
|
||||
await Promise.resolve();
|
||||
|
||||
button?.click();
|
||||
await Promise.resolve();
|
||||
|
||||
assert.deepEqual(log, ['X', 'init', 'XX', 'update', 'XXX', 'update']);
|
||||
}
|
||||
});
|
@ -0,0 +1,11 @@
|
||||
<script>
|
||||
/** @type {{ push: (v: any) => void }} */
|
||||
let { push } = $props();
|
||||
|
||||
let x = $state('x');
|
||||
let y = $derived(x.toUpperCase());
|
||||
|
||||
$inspect(y, push);
|
||||
</script>
|
||||
|
||||
<button on:click={() => x += 'x'}>{x}</button>
|
Loading…
Reference in new issue