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.

string enum with period

See original GitHub issue

There are a few problems with code generated from .\node_modules@types\react-native-fbsdk\index.d.ts. A string enum with a period isn’t handled correctly. It doesn’t compile:

image

This is from this snippet:

export type Permissions = 'public_profile'
    | 'user_friends'
    | 'email'
    | 'user_about_me'
    | 'user_actions.books'
    | 'user_actions.fitness'
    | 'user_actions.music'
    | 'user_actions.news'
    | 'user_actions.video'
    | 'user_birthday'
    | 'user_education_history'

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
humheicommented, Jul 3, 2018

I sended a PR for this issue #231 I think the generated code should as follows

type [<StringEnum>] [<RequireQualifiedAccess>] Permissions =
    | Public_profile
    | User_friends
    | Email
    | User_about_me
    | [<CompiledName "user_actions.books">] User_actions_books
    | [<CompiledName "user_actions.fitness">] User_actions_fitness
    | [<CompiledName "user_actions.music">] User_actions_music
    | [<CompiledName "user_actions.news">] User_actions_news
    | [<CompiledName "user_actions.video">] User_actions_video
    | User_birthday
    | User_education_history

As // by default Fable lowercases the first letter of the name for the value | Public_profile will compiled to pulbic_profile automatically

2reactions
humheicommented, Jul 17, 2018

Sorry for the delay release. Currently the npm authentication is invalidated #236 @ctaggart will fix it You can also try ts2fable@next for now. I think the last version of it fixed the issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java - create enums with dot notation
I need to have enums with dot notation like this WEATHER.SUNNY since they represent topics using wildcards. I know that this is not...
Read more >
How can I write an enum for date periods where not all ...
But I have two other standard date periods that do not have a static number of months. One is YEAR_TO_DATE and another is...
Read more >
TypeScript string enums, and when and how to use them
No matter how much you know about TypeScript enums, this guide covers all the best practices for using string-based enums in production.
Read more >
EnumToString((ENUM_TIMEFRAMES)Period()) problem
There may be a size limit on the string. My guess is 32 characters. StringSubstr(EnumToString((ENUM_TIMEFRAMES)Period()),7)+" ...
Read more >
Enum Period
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate...
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