Skip to content

Decorated static props are treated as instance props #5161

Open
@wjhsf

Description

@wjhsf

Description

Using @api on a static property will result in the property being parsed as an instance prop. @api static foo is treated as if it were the same as @api foo, although any initial values are preserved on the static prop.

Steps to Reproduce

Child component:

export default class Child extends LightningElement {
  @api static foo = 'hello'
  get staticFoo() {
    // expose static prop via the instance
    return Child.foo
  }
}
<template>
<div>{staticFoo} {foo}</div>
</template>

Parent component:

<template>
<x-child foo="world"></x-child>
</template>

Expected Results

Using @api, @wire, or @track on a static property should be a compiler error, because the decorators only make sense to use on component instances.

Actual Results

The example above will render <div>hello world</div>. @wire and @track behave similarly.

Activity

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

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