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

wire Decorator doesn't accept WireAdapterConstructor on a adapter property #5082

Open
aheber opened this issue Dec 26, 2024 · 3 comments
Open
Labels
enhancement typescript Typescript related bugs

Comments

@aheber
Copy link

aheber commented Dec 26, 2024

Description

wire should accept both a direct WireAdapterConstructor and an "indirect" constructor, typically a function that has an adapter property.

This is used on the Salesforce platform when Apex @AuraEnabled(cacheable=true) methods are exposed to LWC. They are a function that can be imperatively invoked but have a property of adapter which carries the WireAdapterConstructor. The LWC engine knows to look for this property and give it preference.

The typings for wire don't account for this.

Steps to Reproduce

Typescript Playground for LWC Wire Adapter Typings

Expected Results

If I'm passing an imported Apex method to wire then I expect it to get the typings correct and use the adapter's config values to validate the parameters passed in the wire decorator's second parameter.

Actual Results

There is no way for me to correctly type the imported Apex method that will be compatible with the current LWC wire typings.

Version

  • LWC: 8.12.2

Possible Solution

I have a comprehensive typing update for wire. It fixes this problem but also fixes several other problems mostly related to how config params are type checked. We can break this up into multiple issues or deal with it all here.

The linked Typescript Playground includes everything. I can create a separate trimmed down version just for this issue if you'd prefer.

@aheber
Copy link
Author

aheber commented Dec 26, 2024

Happy to submit a PR with my requested changes.

@cardoso
Copy link
Contributor

cardoso commented Dec 27, 2024

problems mostly related to how config params are type checked

Does this cover all or some of that? #5073

Edit: just checked the playground, looks nice! I would submit the PR so it can be tested against the current type test suite https://github.com/salesforce/lwc/tree/master/packages/%40lwc/integration-types

@aheber
Copy link
Author

aheber commented Dec 27, 2024

@cardoso thank you for taking a look! I think this does cover some of #5073, not sure about everything but the cited problem seems to behave as expected with my new typings.

I've created the PR here: #5084

I added a lot of lines of tests but most of them are to try things against the wire adapter hanging on a prop. Most of the existing tests I changed were because they weren't valid and my changes flagged them. Some of them were fixes that were also needed for #5073 to pass.

I didn't bring in all the new tests from #5073 and there is probably still values in capturing those tests.

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

No branches or pull requests

3 participants