Skip to content

Alternate collision handling #14

Open
@CWSpear

Description

@CWSpear

Is there a way to handle collisions differently?

For example, we have these JSON translation files, so we don't really have the option of how they're structured, and they're all over the board. An example slice of one we've got has two different definitions for title:

{
  "history": {
    "title": {
      "header": "History",
      "sidebar": "Filter"
    }
  },
  "search": {
    "title": {
      "memberTasks": "Member Tasks",
      "tasks": "Tasks"
    }
  }
}

If you paste this on https://shakyshane.github.io/json-ts/, you'll get this output (not that it merged our title together into an interface with all of the properties as optional):

interface IRootObject {
    history: IHistory;
    search: ISearch;
}
interface IHistory {
    title: ITitle;
}
interface ITitle {
    header?: string;
    sidebar?: string;
    memberTasks?: string;
    tasks?: string;
}
interface ISearch {
    title: ITitle;
}

This has caused some issues. Is there a way we could have the output for this (perhaps with a flag) be something like:

interface IRootObject {
    history: IHistory;
    search: ISearch;
}
interface IHistory {
    title: ITitle;
}
interface ITitle {
    header: string;
    sidebar: string;
}
interface ISearch {
    title: ITitle2;
}
interface ITitle2 {
    memberTasks: string;
    tasks: string;
}

It's not even really important how you handle the naming... ITitle and ITitle2 or IHistoryTitle and ISearchTitle would both work (the latter might be easier to handle?).

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