intermediate
Build the tool: find the watcher that watched a value
Implement this from the stub. Hidden tests grade the behaviour you write, not the comments you leave.
This exercise is real. This platform's Vue track ships a search composable whose original sin was one line: `watch(state.query, …)`. The expression evaluates immediately — to a plain string — and a string carries no subscription, so the watcher never fired. Not once. Vue does log a warning, but a warning at runtime on a code path nobody exercises is a message to no one.
export interface ValueWatcher {
/** The file the watcher is in, as given. */
file: string
/** 1-based line of the watch call. */
line: number
/** The member expression that was handed to watch, e.g. "state.query". */
source: string
}
export interface SourceFile {
path: string
contents: string
}
/**
* Reports every watch() whose first argument is a member expression —
* a value read once, where a source read every time was needed.
*/
export function findValueWatchers(files: SourceFile[]): ValueWatcher[] {
// Your implementation here
return []
}challenge — implement from scratchCtrl+↵ submits · Ctrl+Shift+↵ runsstarter code