Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Public properties with duplicate getter/setter should be an error #3436

Open
Tracked by #2964
nolanlawson opened this issue Mar 31, 2023 · 0 comments
Open
Tracked by #2964

Public properties with duplicate getter/setter should be an error #3436

nolanlawson opened this issue Mar 31, 2023 · 0 comments

Comments

@nolanlawson
Copy link
Collaborator

In #2501, we had to revert an unintended breaking change due to duplicate getter/setters. For instance:

export default class Text {
    @api foo = 1;
    
    get foo() {}
    set foo(value) {}
}

This is clearly a mistake, and should be treated as an error (ideally by the compiler). But today, we are allowing this syntax, to preserve backwards compatibility:

// [W-9927596] If a component has both a public property and a private setter/getter
// with the same name, the property is defined as a public accessor. This branch is
// only here for backward compatibility reasons.
if (!isUndefined(descriptor) && !isUndefined(descriptor.get)) {
descriptor = createPublicAccessorDescriptor(fieldName, descriptor);
} else {
descriptor = createPublicPropertyDescriptor(fieldName);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant