You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var x: any = "foo";
if(typeof x === 'string') {
console.log(x.subtr(1)); // Error, 'subtr' does not exist on 'string'
}
// x is still any here
x.unknown(); // OK
I am not seeing the error or intellisense for the console.log statement.
Are type guards actually supported in this case or only for union types?
I am using the following example that I took directly from the blog post (http://blogs.msdn.com/b/typescript/archive/2014/11/18/what-s-new-in-the-typescript-type-system.aspx)
I am not seeing the error or intellisense for the console.log statement.
Are type guards actually supported in this case or only for union types?