Skip to content

Quote delimit keys?#6

Description

@ben-eb

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! 馃檪

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions