Skip to content

The no-assignment-of-untracked-properties-used-in-tracking-contexts rule gives false positive if the tracked property is in the super class but the computed getter is in the sub class #2291

@adc-mhaugen

Description

@adc-mhaugen

Given the following class hierarchy:

import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { service } from '@ember/service';

import type { Registry as ServiceRegistry } from '@ember/service';

export default class Foo extends Component {
    @service declare store: ServiceRegistry['store'];

    /** I'm in the super class. */
    @tracked page = 1;
}
import { computed } from '@ember/object';
import Foo from './foo';

export default class Bar extends Foo {
    @computed('page')
    get pageInfo(): string {
        return this.page > 1 ? `Page ${this.page}` : 'First Page';
    }

    setPage(newPage: number): void {
        console.log(this.store.findAll);
        this.page = newPage;
    }
}

The no-assignment-of-untracked-properties-used-in-tracking-contexts rule flags this.page = newPage; as an error because we don't use set. The IDE clearly knows the page field exists, and if you move the getPageInfo getter to the super class lint does not complain.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions