Download Latest Version v8.20.1 source code.tar.gz (1.9 MB)
Email in envelope

Get an email when there's a new version of Lightning Web Components

Home / v8.19.0
Name Modified Size InfoDownloads / Week
Parent folder
README.md 2025-05-07 2.5 kB
v8.19.0 source code.tar.gz 2025-05-07 1.8 MB
v8.19.0 source code.zip 2025-05-07 7.7 MB
Totals: 3 Items   9.6 MB 0

Better types for template elements

TypeScript component authors can now specify a new property, __lwc_public_property_types__, to indicate to TypeScript which properties are available on the element created by a component. This prevents erroneous property definitions, which are otherwise unavoidable due to the way that TypeScript implements decorators.

Example

:::ts
// <c-inferred-props>
class InferredProps extends LightningElement {
  @api exposed = 'hello'
  internal = 'secret'
}

// <c-explicit-props>
class ExplicitProps extends InferredProps {
  __lwc_public_property_types__?: {
    exposed: string
  }
}

class Container extends LightningElement {
  checkInferred() {
    const inferred = this.querySelector<LightningHTMLElement<InferredProps>>('c-inferred-props')!
    inferred.exposed // ✅ Valid, no type error
    inferred.internal // ❌ Invalid, but no type error!
  }

  checkExplicit() {
    const explicit = this.querySelector<LightningHTMLElement<ExplicitProps>>('c-explicit-props')!
    explicit.exposed // ✅ Valid, no type error
    explicit.internal // ✅ Invalid, and a type error occurs!
  }
}

In this example, the element interface for c-inferred-props is defined by LightningHTMLElement<InferredProps>. That interface has an erroneous property definition, internal. The internal property is part of the component interface, but is not decorated with @api, so it should not be part of the element interface.

The element interface for c-explicit-props is defined by LightningHTMLElement<ExplicitProps>. Because ExplicitProps defines __lwc_public_property_types__, the element interface does not include the internal property, which is the correct behavior.

What else changed?

Full Changelog: https://github.com/salesforce/lwc/compare/v8.18.2...v8.19.0

Source: README.md, updated 2025-05-07