Public type definitions for packages exposed on the Salesforce Lightning platform.
First, install the package using your preferred package manager.
npm install @salesforce/lightning-types
# OR
yarn add @salesforce/lightning-types
Next, import the package once, from any TypeScript file in your project. For example, if you have a
types
directory, you may create a file called salesforce.d.ts
.
// types/salesforce.d.ts
import "@salesforce/lightning-types";
Lastly, ensure that the file with the import is included in your tsconfig.json
.
{
"compilerOptions": {
// ...
},
"include": ["src", "types"],
}
Now you can import Salesforce Lightning types!
import LightningInput from "lightning/input";
@salesforce/lightning-types
does not provide types for the lwc
package directly, but instead specifies the package as a peer dependency. This allows you to control which version of lwc
you are using. However, not all package managers automatically install peer dependencies; you may need to specify the lwc
dependency explicitly.
npm install @salesforce/lightning-types lwc
# OR
yarn add @salesforce/lightning-types lwc
Type definitions for the following modules are included in this package.
Module | Description |
---|---|
@salesforce/client/formFactor | Access the form factor of the hardware the browser is running on. |
@salesforce/community/basePath | Get the section of the site’s URL that comes after the domain. |
@salesforce/community/Id | Get the ID of the network part of the site for eg., import the ID to pass as a parameter to an API. |
@salesforce/site/activeLanguages | The list of active languages in your Experience Builder site. |
@salesforce/site/Id | Get the current Experience Builder site Id. |
@salesforce/user/Id | Get the current user's ID. |
@salesforce/user/isGuest | Identify whether the current user is a guest or not. |
lightning/industriesEducationPublicApi | The lightning/industriesEducationPublicApi module includes APIs to create Constituent Role and update Benefit Assignment records. |
lightning/logger | Logs the event data from the component. |
lightning/mobileCapabilities | Mobile capabilities are JavaScript APIs that make mobile hardware and platform (operating system) features available in JavaScript. They require access to device hardware, platform APIs, or both. Mobile capability APIs are available only when a Lightning web component runs in a supported mobile app on a mobile device. |
This package solely contains TypeScript type definitions; it is not responsible for the behavior of the APIs it documents. If you encounter any issues, you may post on Salesforce Stack Exchange or open a Salesforce case.
Please report any security issue to security@salesforce.com as soon as it is discovered. This library limits its runtime dependencies in order to reduce the total cost of ownership as much as can be, but all consumers should remain vigilant and have their security stakeholders review all third-party products (3PP) like this one and their dependencies.
All rights reserved. See the license in LICENSE.txt
for details.