1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
//// [typeGuardNarrowsPrimitiveIntersection.ts]
type Tag = {__tag: any};
declare function isNonBlank(value: string) : value is (string & Tag);
declare function doThis(value: string & Tag): void;
declare function doThat(value: string) : void;
let value: string;
if (isNonBlank(value)) {
doThis(value);
} else {
doThat(value);
}
const enum Tag2 {}
declare function isNonBlank2(value: string) : value is (string & Tag2);
declare function doThis2(value: string & Tag2): void;
declare function doThat2(value: string) : void;
if (isNonBlank2(value)) {
doThis2(value);
} else {
doThat2(value);
}
//// [typeGuardNarrowsPrimitiveIntersection.js]
var value;
if (isNonBlank(value)) {
doThis(value);
}
else {
doThat(value);
}
if (isNonBlank2(value)) {
doThis2(value);
}
else {
doThat2(value);
}
|