mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Fix test
This commit is contained in:
parent
3b5c72c4bc
commit
d20664aa69
@ -41,7 +41,7 @@ function foo4(x: number | string | boolean) {
|
||||
: x.toString(); // number
|
||||
})(x); // x here is narrowed to number | boolean
|
||||
}
|
||||
// Type guards affect nested function expressions and nested function declarations
|
||||
// Type guards do not affect nested function declarations
|
||||
function foo5(x: number | string | boolean) {
|
||||
if (typeof x === "string") {
|
||||
var y = x; // string;
|
||||
@ -121,7 +121,7 @@ function foo4(x) {
|
||||
: x.toString(); // number
|
||||
})(x); // x here is narrowed to number | boolean
|
||||
}
|
||||
// Type guards affect nested function expressions and nested function declarations
|
||||
// Type guards do not affect nested function declarations
|
||||
function foo5(x) {
|
||||
if (typeof x === "string") {
|
||||
var y = x; // string;
|
||||
|
||||
@ -27,9 +27,9 @@ function foo(x: number | string | boolean) {
|
||||
>toString : Symbol(Object.toString, Decl(lib.d.ts, --, --))
|
||||
|
||||
: x.toString(); // number
|
||||
>x.toString : Symbol(toString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>x.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(typeGuardsInFunctionAndModuleBlock.ts, 2, 13))
|
||||
>toString : Symbol(toString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
|
||||
|
||||
} ();
|
||||
}
|
||||
@ -60,9 +60,9 @@ function foo2(x: number | string | boolean) {
|
||||
>toString : Symbol(Object.toString, Decl(lib.d.ts, --, --))
|
||||
|
||||
: x.toString(); // number
|
||||
>x.toString : Symbol(toString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>x.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(typeGuardsInFunctionAndModuleBlock.ts, 12, 14))
|
||||
>toString : Symbol(toString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
|
||||
|
||||
} (x); // x here is narrowed to number | boolean
|
||||
>x : Symbol(x, Decl(typeGuardsInFunctionAndModuleBlock.ts, 12, 14))
|
||||
@ -91,9 +91,9 @@ function foo3(x: number | string | boolean) {
|
||||
>toString : Symbol(Object.toString, Decl(lib.d.ts, --, --))
|
||||
|
||||
: x.toString(); // number
|
||||
>x.toString : Symbol(toString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>x.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(typeGuardsInFunctionAndModuleBlock.ts, 22, 14))
|
||||
>toString : Symbol(toString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
|
||||
|
||||
})();
|
||||
}
|
||||
@ -123,14 +123,14 @@ function foo4(x: number | string | boolean) {
|
||||
>toString : Symbol(Object.toString, Decl(lib.d.ts, --, --))
|
||||
|
||||
: x.toString(); // number
|
||||
>x.toString : Symbol(toString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>x.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(typeGuardsInFunctionAndModuleBlock.ts, 32, 14))
|
||||
>toString : Symbol(toString, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --))
|
||||
|
||||
})(x); // x here is narrowed to number | boolean
|
||||
>x : Symbol(x, Decl(typeGuardsInFunctionAndModuleBlock.ts, 32, 14))
|
||||
}
|
||||
// Type guards affect nested function expressions and nested function declarations
|
||||
// Type guards do not affect nested function declarations
|
||||
function foo5(x: number | string | boolean) {
|
||||
>foo5 : Symbol(foo5, Decl(typeGuardsInFunctionAndModuleBlock.ts, 41, 1))
|
||||
>x : Symbol(x, Decl(typeGuardsInFunctionAndModuleBlock.ts, 43, 14))
|
||||
|
||||
@ -21,14 +21,14 @@ function foo(x: number | string | boolean) {
|
||||
>f : () => string
|
||||
|
||||
var b = x; // number | boolean
|
||||
>b : number | string | boolean
|
||||
>x : number | string | boolean
|
||||
>b : number | boolean
|
||||
>x : number | boolean
|
||||
|
||||
return typeof x === "boolean"
|
||||
>typeof x === "boolean" ? x.toString() // boolean : x.toString() : string
|
||||
>typeof x === "boolean" : boolean
|
||||
>typeof x : string
|
||||
>x : number | string | boolean
|
||||
>x : number | boolean
|
||||
>"boolean" : string
|
||||
|
||||
? x.toString() // boolean
|
||||
@ -40,7 +40,7 @@ function foo(x: number | string | boolean) {
|
||||
: x.toString(); // number
|
||||
>x.toString() : string
|
||||
>x.toString : (radix?: number) => string
|
||||
>x : number | string
|
||||
>x : number
|
||||
>toString : (radix?: number) => string
|
||||
|
||||
} ();
|
||||
@ -66,14 +66,14 @@ function foo2(x: number | string | boolean) {
|
||||
>a : number | boolean
|
||||
|
||||
var b = x; // new scope - number | boolean
|
||||
>b : number | string | boolean
|
||||
>x : number | string | boolean
|
||||
>b : number | boolean
|
||||
>x : number | boolean
|
||||
|
||||
return typeof x === "boolean"
|
||||
>typeof x === "boolean" ? x.toString() // boolean : x.toString() : string
|
||||
>typeof x === "boolean" : boolean
|
||||
>typeof x : string
|
||||
>x : number | string | boolean
|
||||
>x : number | boolean
|
||||
>"boolean" : string
|
||||
|
||||
? x.toString() // boolean
|
||||
@ -85,7 +85,7 @@ function foo2(x: number | string | boolean) {
|
||||
: x.toString(); // number
|
||||
>x.toString() : string
|
||||
>x.toString : (radix?: number) => string
|
||||
>x : number | string
|
||||
>x : number
|
||||
>toString : (radix?: number) => string
|
||||
|
||||
} (x); // x here is narrowed to number | boolean
|
||||
@ -111,14 +111,14 @@ function foo3(x: number | string | boolean) {
|
||||
>() => { var b = x; // new scope - number | boolean return typeof x === "boolean" ? x.toString() // boolean : x.toString(); // number } : () => string
|
||||
|
||||
var b = x; // new scope - number | boolean
|
||||
>b : number | string | boolean
|
||||
>x : number | string | boolean
|
||||
>b : number | boolean
|
||||
>x : number | boolean
|
||||
|
||||
return typeof x === "boolean"
|
||||
>typeof x === "boolean" ? x.toString() // boolean : x.toString() : string
|
||||
>typeof x === "boolean" : boolean
|
||||
>typeof x : string
|
||||
>x : number | string | boolean
|
||||
>x : number | boolean
|
||||
>"boolean" : string
|
||||
|
||||
? x.toString() // boolean
|
||||
@ -130,7 +130,7 @@ function foo3(x: number | string | boolean) {
|
||||
: x.toString(); // number
|
||||
>x.toString() : string
|
||||
>x.toString : (radix?: number) => string
|
||||
>x : number | string
|
||||
>x : number
|
||||
>toString : (radix?: number) => string
|
||||
|
||||
})();
|
||||
@ -156,14 +156,14 @@ function foo4(x: number | string | boolean) {
|
||||
>a : number | boolean
|
||||
|
||||
var b = x; // new scope - number | boolean
|
||||
>b : number | string | boolean
|
||||
>x : number | string | boolean
|
||||
>b : number | boolean
|
||||
>x : number | boolean
|
||||
|
||||
return typeof x === "boolean"
|
||||
>typeof x === "boolean" ? x.toString() // boolean : x.toString() : string
|
||||
>typeof x === "boolean" : boolean
|
||||
>typeof x : string
|
||||
>x : number | string | boolean
|
||||
>x : number | boolean
|
||||
>"boolean" : string
|
||||
|
||||
? x.toString() // boolean
|
||||
@ -175,13 +175,13 @@ function foo4(x: number | string | boolean) {
|
||||
: x.toString(); // number
|
||||
>x.toString() : string
|
||||
>x.toString : (radix?: number) => string
|
||||
>x : number | string
|
||||
>x : number
|
||||
>toString : (radix?: number) => string
|
||||
|
||||
})(x); // x here is narrowed to number | boolean
|
||||
>x : number | boolean
|
||||
}
|
||||
// Type guards affect nested function expressions and nested function declarations
|
||||
// Type guards do not affect nested function declarations
|
||||
function foo5(x: number | string | boolean) {
|
||||
>foo5 : (x: number | string | boolean) => void
|
||||
>x : number | string | boolean
|
||||
|
||||
@ -40,7 +40,7 @@ function foo4(x: number | string | boolean) {
|
||||
: x.toString(); // number
|
||||
})(x); // x here is narrowed to number | boolean
|
||||
}
|
||||
// Type guards affect nested function expressions and nested function declarations
|
||||
// Type guards do not affect nested function declarations
|
||||
function foo5(x: number | string | boolean) {
|
||||
if (typeof x === "string") {
|
||||
var y = x; // string;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user