Skip to content

VSCode allowedValues Output string literal Union type - Asking for enum #642

@damntrecky

Description

@damntrecky

Is your feature request related to a problem? Please describe.
The current VSCode allowedValues outputs a string literal union type in Typescript:

export type LambdaRuntime = 'dotnetcore2.1' | 'nodejs12.x'

The other implementations for Kotlin and C# output an enum type. The Typescript code standard in PR's keep asking for Enums as the preferred implementation, so we are converting the String literal Union types output from this package to hardcoded Enums... This process seems backwards.

Describe the solution you'd like
I would like the Typescript allowedValues to ouput an Enum type

export  enum LambdaRuntime{
    Dotnetcore21 = 'dotnetcore2.1',
    Nodejs12x = 'nodejs12.x'
}

Describe alternatives you've considered
I have not

Additional context

Kotlin output for enum

/**
 * The lambda runtime
 */
public enum class LambdaRuntime(
    private val `value`: String,
) {
    Dotnetcore21("dotnetcore2.1"),
    Nodejs12x("nodejs12.x"),
    Unknown("unknown"),
    ;

    public override fun toString(): String = value

    public companion object {
        public fun from(type: String): LambdaRuntime = values().firstOrNull { it.value == type }
                ?: Unknown
    }
}

All code snippets referenced from test files generatorOutput.ts and testGeneratorOutput for Kotlin and Typescript within this package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions