unused-class-members FP: methods called only from Svelte <template> member expressions…
- User
unused-class-members FP: methods called only from Svelte member expressions False positive on 2.84.0. Class methods called only from a Svelte
<template>via a member expression (for exampleresultState.pin(...)in markup) are reported asunused-class-member. Fallow tracks template-visible identifiers but not member-expression method calls on a bound instance inside Svelte markup.Repro (2.84.0): asciimoo/hister.
ResultState.onOpen,.pin,.updateLabel, and.addSkipRuleare each invoked from.sveltetemplates (resultState.pin(...)inResultActionsMenu.svelte) yet reported unused. The repo currently setsrules.unused-class-members: "off"to work around it.Expected: credit a method called as
<local>.<method>(...)inside a Svelte<template>when<local>resolves to an instance of the class, parallel to the existing Vue/Angular template member-access tracking.Interface
No new interfaces are introduced.
- Assistant
I'll trace how Vue/Angular template member calls are credited today, then compare that to Svelte template extraction so we can add the same member-expression handling.
- Assistant
Running tests to reproduce the issue with direct member method calls in Svelte templates.
- Assistant
Implementing Svelte 5
$props()destructuring: map typed props likeresultState: ResultStateintobinding_target_namesso template member calls are credited. - Assistant
Implementing the fix: adding helpers and visitor logic, then tests.
- Assistant
Fixed. Svelte 5 typed
$props()destructuring wasn’t feeding the template member-access pipeline.Root cause
In patterns like hister’s
ResultActionsMenu.svelte, props come from:interface Props { resultState: ResultState; } let { resultState }: Props = $props();resultState.pin(...)in markup is a member call on a prop local, not onconst resultState = new ResultState(). Fallow already creditedcounter.bump()whencounterwas bound vianew Counter(), but it didn’t map Svelte/Vue prop destructuring to class types, sobinding_target_namesnever gotresultState → ResultState.Fix
In the extract visitor:
- Record prop type shapes from local
interface/ type-literal aliases (Props.resultState: ResultState).
- Record prop type shapes from local
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.