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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quote delimit keys? #6

Open
ben-eb opened this issue Apr 1, 2020 · 0 comments
Open

Quote delimit keys? #6

ben-eb opened this issue Apr 1, 2020 · 0 comments

Comments

@ben-eb
Copy link

ben-eb commented Apr 1, 2020

Hello, many thanks for this library! 馃憤

I have an issue where the interfaces generated are not valid typescript code due to containing special characters. For instance:

export interface ModuleList {
  mc?: string;
  mc.json?: Array<ModuleCode>;
}

This is not valid typescript code. Would it be possible to generate the following instead?

export interface ModuleList {
  mc?: string;
  "mc.json"?: Array<ModuleCode>;
}

I naively solved this by modifying the schema partial to always output quotes, then running the generated file through prettier afterwards, but it is quite the hack:

{{#each properties}}
  "{{@key}}"{{#unless (in? ../required @key)}}?{{/unless}}: {{> schema namespace=../namespace}};
{{/each}}

Thanks! 馃檪

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

No branches or pull requests

1 participant