bcherny / json-schema-to-typescript

Compile JSON Schema to TypeScript type declarations
https://bcherny.github.io/json-schema-to-typescript-browser/
MIT License
2.95k stars 392 forks source link

Option to keep primitive types in place #624

Closed fudom closed 2 months ago

fudom commented 2 months ago

I don't want to outsource primitive types. For example instead of export type Name = string assign string directly on the property. No need to separate it as own type.

Btw. I want to use StrictPascalCase. Instead of ID or UUID use Id or Uuid. I have a parameter named id with title "ID (UUID)" and get a type name of "IDUUID". Which is just a string. And for each object it create a new increment type like "IDUUID1" etc. Even if "string === string".

bcherny commented 2 months ago

To do that, remove the title from your property. When title or id are present, JSTT infers that you usually want to name the property.

fudom commented 2 months ago

@bcherny Thanks for answer the side quest. But this issue is about keep privitive types in place instead of export as new type.

Instead of this:

export type Value = string;
export type MyJson {
  value: Value;
}

I want:

export type MyJson {
  value: string;
}

I see no reason to extract primitive types. So it's not a questions. Reopen? Screw it... I craft my own ...