AlexDaSoul / nestjs-proto-gen-ts

Generate TypeScript interfaces for Nest.js gRPC from Protobuf files
MIT License
74 stars 28 forks source link

TypeScript enum definition #29

Closed Ryu36 closed 2 years ago

Ryu36 commented 2 years ago

Bug Report

Current behavior

Can't run NestJs in dev mode while using enum in proto definition. Proto-gen-ts creates a wrong TypeScript export for enums. Based on this discussion I've changed the template locally, what fixed it for me.

Input Code

export enum Test{...}

should be

export const enum Test{...}

Possible Solution

change the template for enums

AlexDaSoul commented 2 years ago

Hi! export const enum Test{...} is the incorrect notation.

enum is the enumerable type const is the const

When you do const enum you change the type enumerable to const with name "enum"

Just settings your eslint and ts