salesforce / lwc

⚡️ LWC - A Blazing Fast, Enterprise-Grade Web Components Foundation
https://lwc.dev
Other
1.64k stars 393 forks source link

[SSR v2] Restrict invalid decorator usage #4886

Open wjhsf opened 1 week ago

wjhsf commented 1 week ago

In the regular compiler, we disallow various forms of invalid decorator usage. The following validation should be added to the SSR compiler:

  1. Only api, track, and wire can be used as decorators.
    • @foo prop is invalid.
  2. The decorators cannot be imported and renamed.
    • import { api as API } from "lwc" is invalid.
  3. Other functions called api, wire, or track cannot be used as decorators.
    • const api = () => {}; ... @api prop is invalid.
  4. The decorators cannot be called as regular functions.
    • import { api } from "lwc"; ... api() is invalid.
  5. Other functions called api, wire, or track can be used as regular functions.
    • const api = () => {}; api(); is valid.
git2gus[bot] commented 1 week ago

This issue has been linked to a new work item: W-17264833