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

Decorated static props are treated as instance props #5161

Open
wjhsf opened this issue Jan 22, 2025 · 0 comments
Open

Decorated static props are treated as instance props #5161

wjhsf opened this issue Jan 22, 2025 · 0 comments

Comments

@wjhsf
Copy link
Collaborator

wjhsf commented Jan 22, 2025

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.

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

No branches or pull requests

1 participant