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

fix: Implicit underscore-prefixed observable properties in fast-element #6824

Open
albertor24 opened this issue Aug 24, 2023 · 1 comment
Open
Labels
area:fast-element Pertains to fast-element status:needs-investigation Needs additional investigation

Comments

@albertor24
Copy link

🐛 Bug Report

When creating an @observable property, an implicit property with the same name prefixed with underscore will be created.
Moreover, if an explicit underscore-prefixed property is declared alongside a non-prefixed property, they will overwrite each other

💻 Repro or Code Sample

https://stackblitz.com/edit/typescript-j2eqbm?file=index.ts

const template = html`
  <h1>${x => x.myProp}</h1>
`;

class MyElement extends FASTElement {
  @observable myProp = "Just my prop";
  private _myProp = "My prop with underscore";
}

🤔 Expected Behavior

The template should show Just my prop

😯 Current Behavior

The template shows My prop with underscore

💁 Possible Solution

If it's necessary to create these implicit properties, an error should be raised if a property with underscore is explicitly defined.

🔦 Context

🌍 Your Environment

  • OS & Device: [e.g. MacOS, iOS, Windows, Linux] on [iPhone 7, PC]
  • Browser [e.g. Microsoft Edge, Google Chrome, Apple Safari, Mozilla FireFox]
  • Version [e.g. 1.8.0]
@albertor24 albertor24 added the status:triage New Issue - needs triage label Aug 24, 2023
@janechu janechu added docs:example Tutorial and example work and removed status:triage New Issue - needs triage labels May 29, 2024
@janechu
Copy link
Collaborator

janechu commented May 29, 2024

I don't think we want to add overhead to runtime checking, so I'm marking this as a documentation issue, we should explicitly state that we are creating private underscore properties and that they should not be overwritten.

After some discussion with maintainers it seems that a potential solution is to use Symbol this may however have perf implications.

@janechu janechu added status:needs-investigation Needs additional investigation area:fast-element Pertains to fast-element and removed docs:example Tutorial and example work labels May 29, 2024
@janechu janechu added this to the FAST Element Future milestone May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:fast-element Pertains to fast-element status:needs-investigation Needs additional investigation
Projects
Status: Backlog
Development

No branches or pull requests

2 participants