Skip to content

Commit 2a2f310

Browse files
authoredSep 15, 2022
Fix DelimiterCase regression after TS 4.8 (#464)
1 parent 6df18e3 commit 2a2f310

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed
 

‎source/delimiter-case.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const rawCliOptions: OddlyCasedProperties<SomeOptions> = {
8888
@category Change case
8989
@category Template literal
9090
*/
91-
export type DelimiterCase<Value, Delimiter extends string> = Value extends string
91+
export type DelimiterCase<Value, Delimiter extends string> = string extends Value ? Value : Value extends string
9292
? StringArrayToDelimiterCase<
9393
SplitIncludingDelimiters<Value, WordSeparators | UpperCaseCharacters>,
9494
true,

‎test-d/delimiter-case.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ expectType<'##very#prefixed'>(delimiterFromDoublePrefixedKebab);
4848
const delimiterFromRepeatedSeparators: DelimiterCase<'foo____bar', '#'> = 'foo####bar';
4949
expectType<'foo####bar'>(delimiterFromRepeatedSeparators);
5050

51-
// TODO: Fails after TS 4.8.
52-
// const delimiterFromString: DelimiterCase<string, '#'> = 'foobar';
53-
// expectType<string>(delimiterFromString);
51+
const delimiterFromString: DelimiterCase<string, '#'> = 'foobar';
52+
expectType<string>(delimiterFromString);
5453

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

0 commit comments

Comments
 (0)
Please sign in to comment.