Skip to content

bug: custom decorators are not invoked for state properties #3831

@jgroth

Description

@jgroth

Prerequisites

Stencil Version

2.19.0

Current Behavior

If a property is decorated with both @State and another decorator, the code for the other decorator will never be invoked.

In the following component nothing will be logged to the console with Stencil 2.19.0. It works perfectly in 2.18.1. Probably introduced in #3614

const MyDecorator: () => PropertyDecorator = () => {
  return (target: Object, propertyKey: string) => {
    console.log({target, propertyKey});
  };
};

@Component({
  tag: 'my-component',
  shadow: true,
})
export class MyComponent {
  @State()
  @MyDecorator()
  decoratedProp: any;
}

After inspecting the compiled javascript files, the TypeScript __decorate helper function is missing for the component in 2.19.0, and is present in 2.18.1

Expected Behavior

Decorators added to properties also decorated with @State should be invoked

Steps to Reproduce

Create a new component with a property decorated with both @State and something else. The other decorator will not work

Code Reproduction URL

https://github.com/jgroth/stencil-decorator-bug

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug: ValidatedThis PR or Issue is verified to be a bug within Stencil

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions