type guards strangeness · Issue #7224 · microsoft/TypeScript (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

@zpdDG4gta8XKpMCd

Description

@zpdDG4gta8XKpMCd

TypeScript Version:

1.8.0

Code

const enum AsNonBlank {} export function isNonBlank(value: string) : value is string & AsNonBlank { return !/^\s*$/g.test(value); } let value: string; if (isNonBlank(value)) { doThis(value); // expected value to be string & AsNonBlank, actual: string } else { doThat(value); } function doThis(value: string & AsNonBlank): void { } function doThat(value: string) : void { }

Expected behavior:
value should either be string & AsNonBlank
or there must be a message saying that the type guard is invalid or something
Actual behavior:
value is a string