Skip to content

[BUG]: combineClasses option does not work #2724

Open
@TPNils

Description

@TPNils

Issue Type

issue with quicktype output

Context (Environment, Version, Language)

Input Format: json
Output Language: typescript

Version: quicktype-core@23.1.3

Description

I want to convert a bulk amount of json data into typescript interfaces. Apparently some of them appear identical to each other and get merged together, even with the combineClasses: false or omission of the option.

Input Data

see Steps to Reproduce

Expected Behaviour / Output

With the combineClasses: false or combineClasses ommited, i expect to find 2 interfaces

export interface Obj1 {
    definition: string;
}
export interface Obj2 {
    definition: string;
}

Current Behaviour / Output

export interface Obj2 {
    definition: string;
}

Steps to Reproduce

With NodeJS 18.19.1 on windows 10

const { quicktype, InputData, jsonInputForTargetLanguage } = require("quicktype-core");

async function main() {
  const inputData = new InputData();
  await inputData.addSource('json', {name: 'Obj1', samples: [JSON.stringify({definition: 'Obj1'})]}, () => jsonInputForTargetLanguage('typescript'));
  await inputData.addSource('json', {name: 'Obj2', samples: [JSON.stringify({definition: 'Obj2'})]}, () => jsonInputForTargetLanguage('typescript'));

  // same result without combineClasses
  const tsResult = await quicktype({inputData: inputData, combineClasses: false, lang: 'typescript', rendererOptions: {'just-types': 'true'}});
  console.log('typescript\n' + tsResult.lines.join('\n'))
}

main()

With your website

(i dont know how to share setup to your site so i will fall back to a screenshot)
Image

Possible Solution

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions