-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
Describe the bug
For this code:
class Linked<T> {
#source = $state() as () => T;
#derived = $derived.by(() => {
let val = $state(this.#source());
return {
get current() {
return val;
},
set current(b) {
val = b;
},
};
});
constructor(source: () => T) {
this.#source = source;
}
get current() {
return this.#derived.current;
}
set current(value: T) {
this.#derived.current = value;
}
}The line this.#derived.current = value errors saying cannot assign to derived, whereas this works completely fine in a regular component, outside of a class.
Reproduction
Logs
System Info
System:
OS: macOS 15.3
CPU: (10) arm64 Apple M1 Pro
Memory: 127.20 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.3.0 - ~/.volta/tools/image/node/22.3.0/bin/node
Yarn: 4.3.1 - ~/.volta/tools/image/yarn/4.3.1/bin/yarn
npm: 10.8.1 - ~/.volta/tools/image/node/22.3.0/bin/npm
pnpm: 9.14.2 - ~/.volta/bin/pnpm
bun: 1.1.38 - ~/.bun/bin/bun
Watchman: 2024.11.18.00 - /opt/homebrew/bin/watchman
Browsers:
Edge: 132.0.2957.140
Safari: 18.3Severity
annoyance
brunnerh and rChaoz
Metadata
Metadata
Assignees
Labels
No labels