Skip to content

Enum of strings #629

@piranna

Description

@piranna

It's usual to have places where you only can set a group of strings, for example names of events or types of media, and don't want to allow others. At this moment the only way to document them is creating a Javascript object and set it as an enum, but this forces to create an object for this enum that in other case is unnecesary. I propose three non-mutually incompatible solutions:

  • allow to use ad-hoc objects and reference them in a similar way as with callbacks
  • allow to set quoted strings as a type
/**
 * @param {('MP4'|'WEBM')} mediaType - Type of the media
 */
function foo(mediaType){};
/**
 * @param {MediaType} mediaType - Type of the media
 */
function foo(mediaType){};
/**
 * @type {('MP4'|'WEBM')} MediaType - Allowed media types
 */
  • allow to set quoted strings on the enum statement

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy