-
Notifications
You must be signed in to change notification settings - Fork 3
Using typings for apex
Ziemniakoss edited this page Jul 5, 2022
·
2 revisions
sfdx typings:lwc:apex
or
sfdx typings:lwc
import { LightningElement, wire } from "lwc";
import methodReturningAccount from "@salesforce/apex/TestClass.methodReturningAccouts"
export default class Test extends LightningElement {
/**
* Property that has value wired from TestClass.methodReturningAccouts method (it reutrns list of Accounts).
* Make sure to use typeof keyword in type definintion bellow.
*
* @type {Wired<typeof methodReturningAccount>}
*/
wiredProperty
/**
* Method that has wired value from same method
* @param {Wired<typeof methodReturningAccount>} wiredValue
*/
@wire(methodReturningAccount)
wiredMethodStandard(wiredValue) {
if (wiredValue.data) {
//TODO
}
}
/**
* Same as above, but now we are using deconstruction mechanism.
* Param in jsdocs can be named whatever you want (here I called wiredValue)
*
* @param {Wired<typeof methodReturningAccount>} wiredValue
*/
@wire(methodReturningAccount)
wiredMethodDeconstructed({ data, error }) {
if (data) {
//TODO
}
}
/**
* @type {apex.TestClass}
*/
propertyWithSamePropertiesAsApexClass;
/**
* @type {apex.TestClass.InnerClass}
*/
propertyWithSamePropertiesAsInnerClass
}