Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/entrypoints/is-array.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
interface ArrayConstructor {
isArray(arg: any): arg is unknown[];
isArray<T>(arg: T): arg is unknown extends T ? unknown[] : any[];
}
2 changes: 2 additions & 0 deletions src/entrypoints/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ declare namespace TSReset {
: T extends symbol
? symbol
: T;

type Cast<A, B> = A extends B ? A : B;
}
14 changes: 14 additions & 0 deletions src/tests/is-array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,17 @@ doNotExecute(() => {

type tests = [Expect<Equal<typeof paths, string[]>>];
});

doNotExecute(() => {
type Unarray<T> = T extends Array<infer U> ? U : T;

function test<T>(value: T) {
const inner = <X extends Unarray<T>>(v: X[]) => {
//
};

if (Array.isArray(value)) {
inner(value);
}
}
});