vega / ts-json-schema-generator

Generate JSON schema from your Typescript sources
MIT License
1.41k stars 189 forks source link

Type inference won't work with template literals #1355

Open ccpu opened 2 years ago

ccpu commented 2 years ago

Thanks to @daanboer PR(#1265), type inference now works with this library, but I have discovered that it doesn't work with template literals:

export type Replace<
    Input extends string,
    Search extends string,
    Replacement extends string
> = Input extends `${infer Head}${Search}${infer Tail}` ? `${Head}${Replacement}${Tail}` : Input;

export type MyType = Replace<"FooBarBaz", "Bar", "">; // => FooBaz

The ability to use Inferred types with template literals would be great.

arthurfiorette commented 3 months ago

Thanks for the report. Would you like to start a PR?