Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special characters in field names #4

Open
jvilk opened this issue May 12, 2017 · 6 comments
Open

Special characters in field names #4

jvilk opened this issue May 12, 2017 · 6 comments

Comments

@jvilk
Copy link
Owner

jvilk commented May 12, 2017

Support field names that are not proper JavaScript identifiers.

e.g.: ")hello"

In the non-identifier case, switch to using index [""] notation for accessing properties on JS objects.

@Mart-Bogdan
Copy link

I'd add for not only filed names, but also type names

input was:

{
  "stores": [ "xxxx"
  ],
  "products": {
    "892303": [
      {
        "sku": "892304",
        "upc": []
      },
      {
        "sku": "10137374",
        "upc": []
      }
    ],
    "PRD4UH16V3K5TO7": [
      {
        "sku": "4UH16V3K5TO7",
        "upc": []
      }
    ]
  },
  "origin": "browse"
}

Output:

export interface ProductAvailabitlityRequest {
  stores?: (string)[] | null;
  products: Products;
  origin: string;
}
export interface Products {
  892303?: (892303EntityOrPRD4UH16V3K5TO7Entity)[] | null;
  PRD4UH16V3K5TO7?: (892303EntityOrPRD4UH16V3K5TO7Entity)[] | null;
}
export interface 892303EntityOrPRD4UH16V3K5TO7Entity {
  sku: string;
  upc?: (null)[] | null;
}

I'd suggest escapting interface name, say _8923... in this case, and for prop name use quotes (")

@jvilk
Copy link
Owner Author

jvilk commented Jul 16, 2018

Good call. I may revisit this issue in a couple of months, once I finish defending my PhD + moving.

@renatomariscal
Copy link

I got blocked by this issue recently, I have a potential fix in #18

@realJoshByrnes
Copy link

Just had the same issue
Created:
itineraries:created?: string[] | null;
Should be:
['itineraries:created']?: string[] | null;

@RobertjanTuit
Copy link

Proposed fix: #26
You can point your package to https://github.com/RobertjanTuit/MakeTypes temporarily to use until is merged

@RobertjanTuit
Copy link

Actually, those are 2 characters I did not have in the list yet added them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants