lwc icon indicating copy to clipboard operation
lwc copied to clipboard

Components should not "inherit" `@api` from their superclasses

Open nolanlawson opened this issue 10 months ago • 1 comments

Follow-up to #3758

// superclass.js
export default class extends LightningElement {
  @api
  foo() {}
}
// subclass.js
export default class extends Superclass {
  foo() {}
}

Calling elm.foo() works fine in the above case, which is surprising since the subclass does not actually annotate the method with @api. However, any parent/grandparent/ancestor with an @api will cause it to become exposed.

nolanlawson avatar Oct 02 '23 16:10 nolanlawson

It might be worth reading the decorators spec to see if this behavior is actually consistent with how @api would work if we were using native decorators.

nolanlawson avatar Oct 03 '23 16:10 nolanlawson