Skip to content

Commit

Permalink
Fix DelimiterCase regression after TS 4.8 (#464)
Browse files Browse the repository at this point in the history
  • Loading branch information
skarab42 authored Sep 15, 2022
1 parent 6df18e3 commit 2a2f310
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion source/delimiter-case.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const rawCliOptions: OddlyCasedProperties<SomeOptions> = {
@category Change case
@category Template literal
*/
export type DelimiterCase<Value, Delimiter extends string> = Value extends string
export type DelimiterCase<Value, Delimiter extends string> = string extends Value ? Value : Value extends string
? StringArrayToDelimiterCase<
SplitIncludingDelimiters<Value, WordSeparators | UpperCaseCharacters>,
true,
Expand Down
5 changes: 2 additions & 3 deletions test-d/delimiter-case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ expectType<'##very#prefixed'>(delimiterFromDoublePrefixedKebab);
const delimiterFromRepeatedSeparators: DelimiterCase<'foo____bar', '#'> = 'foo####bar';
expectType<'foo####bar'>(delimiterFromRepeatedSeparators);

// TODO: Fails after TS 4.8.
// const delimiterFromString: DelimiterCase<string, '#'> = 'foobar';
// expectType<string>(delimiterFromString);
const delimiterFromString: DelimiterCase<string, '#'> = 'foobar';
expectType<string>(delimiterFromString);

const delimiterFromScreamingSnake: DelimiterCase<'FOO_BAR', '#'> = 'foo#bar';
expectType<'foo#bar'>(delimiterFromScreamingSnake);
Expand Down

0 comments on commit 2a2f310

Please sign in to comment.