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.

enums gives relaxed type

See original GitHub issue
const struct = object({text: enums(["foo", "bar"])})
const {text}  = create({ text: "foo"}, struct)

the text variable is given a type of string while I am expecting "foo" | "bar". I can get around the problem with the more verbose union([literal("foo"), literal("bar")])

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
ianstormtaylorcommented, Sep 20, 2022

Fixed and released in 0.16.3! The generic type needed a little tweaking to preserve the more specific types instead of being expanded to string.

1reaction
birtlescommented, Sep 21, 2022

Thanks so much!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Strongly-Typed Enums - ModernesCpp.com
Enumerations are a convenient way to define integer constants with names. These integer constants are called enumerators.
Read more >
Enum vs Strongly typed enum - c++ - Stack Overflow
Scoped enums gives you the ability to specify the underlying type of the ... In <memory> : enum class pointer_safety { relaxed, preferred, ......
Read more >
Handbook - Enums - TypeScript
String enums allow you to give a meaningful and readable value when your code runs, independent of the name of the enum member...
Read more >
Enumeration declaration - cppreference.com
An enumeration has the same size, value representation, and alignment requirements as its underlying type.
Read more >
Gson Advanced — Mapping of Enums - Future Studio
Java enums can be a very helpful data type. They limit the variable values to a predefined amount of constants. While this is...
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