Include acceptable value hints in inline help for LWC attributes when using JSDoc

Issue #2222 resolved
John De Santiago created an issue

It would be nice to have acceptable values, documented using JSDoc, for LWC @api properties to be displayed in the inline help and likely validated when utilizing said component from a hosted component.

An example of the JSDoc property:

  /** @type {"base"|"error"|"warning"} */
  @api variant = 'base';

Currently, when using F1 on that attribute from a parent/host component, the type information is displayed as illustrated in the attached screenshot.

Comments (4)

  1. Scott Wells repo owner

    Fix committed for the next build. The following:

    import {api, LightningElement} from 'lwc';
    
    export default class Issue2222 extends LightningElement {
    
        /** @type {"base"|"error"|"warning"} */
        @api unionTypeProperty;
    
        /** @type {10|(20|30)} */
        @api unionTypeProperty2;
    
        /** @type {10|"StringValue"|false} */
        @api unionTypeProperty3;
    
        /** @type {"First"|"Last"|number|boolean} */
        @api unionTypeProperty4;
    }
    

    behaves as follows:

    Documentation

    Completion

    Validation

  2. Log in to comment