question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enum is not generated

See original GitHub issue

Hi,

I like this tool a lot, but I hit a limitation I can’t work around. My interfaces are generated from other service and I can’t refactor them to avoid enums. And, as header says, enums are not generated properly by ts-interface-builder.

interface and enum source:

export interface LimitInput {
  amount: number;
  period?: Period | null;
  periodEnds?: string | null;
}
export enum Period {
  MONTH = "MONTH",
  WEEK = "WEEK",
}

generated checkers:

export const LimitInput = t.iface([], {
  "amount": "number",
  "period": t.opt(t.union("Period", "null")),
  "periodEnds": t.opt(t.union("string", "null")),
});
const exportedTypeSuite: t.ITypeSuite = {
  LimitInput
};

As you see Period enum is used in validation, but is not included in exportedTypeSuite. Is this a bug? Or are there any options I can use to include enums in output? Do I miss something?

Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dsagalcommented, Oct 27, 2018

Enum support added in v0.1.6 of ts-interface-builder, and v0.1.5 of ts-interface-checker. Closing this request, but please open a new one if it’s not enough for what you need.

0reactions
dsagalcommented, Oct 26, 2018

OK OK, I think it’s not too hard. I’ll give it a shot 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swagger-codegen not generating enums as enum type
It seems once I set stringEnums to true in the openapi-generator, it actually generates enums and not type.
Read more >
enum — Support for enumerations — Python 3.11.1 ...
Enumerations are created either by using class syntax, ... Even though we can use class syntax to create Enums, Enums are not normal...
Read more >
Enums - Swagger
You can use the enum keyword to specify possible values of a request parameter or a model property. For example, the sort parameter...
Read more >
Enum Types - Java™ Tutorials
Note: All enums implicitly extend java.lang.Enum . Because a class can only extend one parent (see Declaring Classes), the Java language does not...
Read more >
KJS: .d.ts generation not working for enum classes : KT-37916
A proper Typescript definition should be generated instead of any . Kotlin code: @JsExport enum class TestEnum { FOO, BAR, BAZ }.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found