mirror of
https://github.com/sindresorhus/type-fest.git
synced 2025-12-08 19:25:05 +00:00
Join: Faster handing of readonly empty tuple (#765)
This commit is contained in:
parent
fe03e0a87a
commit
855fb642f2
2
source/join.d.ts
vendored
2
source/join.d.ts
vendored
@ -51,7 +51,7 @@ const path: Join<['hello' | undefined, 'world' | null], '.'> = ['hello', 'world'
|
||||
export type Join<
|
||||
Items extends readonly JoinableItem[],
|
||||
Delimiter extends string,
|
||||
> = Items extends []
|
||||
> = Items extends readonly []
|
||||
? ''
|
||||
: Items extends readonly [JoinableItem?]
|
||||
? `${NullishCoalesce<Items[0], ''>}`
|
||||
|
||||
@ -48,6 +48,11 @@ const tuple = ['foo', 'bar', 'baz'] as const;
|
||||
const joinedTuple: Join<typeof tuple, ','> = 'foo,bar,baz';
|
||||
expectType<'foo,bar,baz'>(joinedTuple);
|
||||
|
||||
// Typeof of const empty tuple.
|
||||
const emptyTuple = [] as const;
|
||||
const joinedEmptyTuple: Join<typeof emptyTuple, ','> = '';
|
||||
expectType<''>(joinedEmptyTuple);
|
||||
|
||||
// Typeof of string[].
|
||||
const stringArray = ['foo', 'bar', 'baz'];
|
||||
const joinedStringArray: Join<typeof stringArray, ','> = '';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user