-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Explore using a different isArray declaration
- Loading branch information
Showing
2 changed files
with
59 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
declare const MyArray: { | ||
isArray<T>(arg: T | {}): arg is T extends readonly any[] ? readonly any[] : any[]; | ||
}; | ||
|
||
declare const a: readonly string[] | string; | ||
declare const b: string[] | string; | ||
declare const c: unknown; | ||
|
||
if (MyArray.isArray(a)) { | ||
a; | ||
} | ||
else { | ||
a; | ||
} | ||
a; | ||
|
||
if (MyArray.isArray(b)) { | ||
b; | ||
} | ||
else { | ||
b; | ||
} | ||
b; | ||
|
||
if (MyArray.isArray(c)) { | ||
c; | ||
} | ||
|
||
|
||
function f<T>(x: T) { | ||
const a: readonly T[] | string = null!; | ||
const b: T[] | string = null!; | ||
const c: T = null!; | ||
|
||
if (MyArray.isArray(a)) { | ||
a; | ||
} | ||
else { | ||
a; | ||
} | ||
a; | ||
|
||
if (MyArray.isArray(b)) { | ||
b; | ||
} | ||
else { | ||
b; | ||
} | ||
b; | ||
|
||
if (MyArray.isArray(c)) { | ||
c; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters