ProjectEvergreen / ProjectEvergreen/wcc

Literal `this` Evaluation and Derivative References (e.g. destructuring)

Open
#88 1 comment 0 reactions 1 assignee View on GitHub

@thescientist13 is already working on this.

Since Jan 4, 2023.

  • #272 by @thescientist13 — merged
documentation expirement feature InferredObservability JSX
Dominant language
JavaScript
Stars
126
Forks
17
PR merge metrics
No merged PRs in 30d

Description

Type of Change

  • New Feature Request

Summary

Coming from #84 , wanted to track support for having something like this

render() {  
  return (
    <h1>You have {this.todos.length} TODOs left to complete</h1>
  )
} 

Would also want to make sure this works with inferredObservability too, e.g.

<span>The count is {this.count.get()}</span>

Based on some initial testing in #233 , was seeing this issue where rootNode().host was not resolving as expected (at least with Shadow Roots)

Image Image

Details

I think I was getting this error though when I tried

ReferenceError: __this__ is not defined

I think this would also handle other cases like this, but will need to double check

render() {
  const { user } = this;
  
  return (
    <button onclick={(e) => { this.deleteUser(user.id) }}>Delete User</button>
  )
}

Also would be good handle derivative this references as well, but also make sure we don't track them for observability either. Just make sure we are looking for this in all possible places, e.g.

render() {
  const { count, predicate } = this;
  const conditionClass = predicate ? 'met' : 'unmet';

  return (
    <span class={conditionClass}>{count}</span>
  )
}

Also, this usage for standardizing onclick in TypeScript land - #266

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.