mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 01:04:49 -05:00
Narrow types by satisfies expressions (#60782)
This commit is contained in:
committed by
GitHub
parent
7f802bbca2
commit
efe07a0921
@@ -279,3 +279,13 @@ const foobarPred = (fb: typeof foobar) => fb.type === "foo";
|
||||
if (foobarPred(foobar)) {
|
||||
foobar.foo;
|
||||
}
|
||||
|
||||
// https://github.com/microsoft/TypeScript/issues/60778
|
||||
const arrTest: Array<number> = [1, 2, null, 3].filter(
|
||||
(x) => (x != null) satisfies boolean,
|
||||
);
|
||||
|
||||
function isEmptyString(x: unknown) {
|
||||
const rv = x === "";
|
||||
return rv satisfies boolean;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user