YousefED / typescript-json-schema

Generate json-schema from your Typescript sources
BSD 3-Clause "New" or "Revised" License
3.08k stars 318 forks source link

Bug: Template literal types compiles to array of strings #575

Closed Komock closed 7 months ago

Komock commented 9 months ago

Stackblitz demo - https://stackblitz.com/edit/stackblitz-starters-8zhuuy?file=schema.json I'm trying to compile schema for the following type:

type HexColor = `#${string}`;

export type InputType = {
  background: HexColor;
}

Result

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "properties": {
        "background": {
            "items": {
                "type": "string"
            },
            "type": "array"
        }
    },
    "type": "object"
}

Expected

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "properties": {
        "background": {
            "type": "string"
        }
    },
    "type": "object"
}

Or I do something wrong? 🤔

MyzBai commented 7 months ago

duplicate of #426. Has been fixed in 0.61.0