Skip to content

Commit

Permalink
Attempted fix for #48
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpocock committed Feb 22, 2023
1 parent 2f4a57e commit 4c2b406
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
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);
}
}
});

0 comments on commit 4c2b406

Please sign in to comment.