TypeScript/tests/baselines/reference/TypeGuardWithEnumUnion.types
Wesley Wigham 78a99241d8
Reuse input type nodes when serializing signature parameter and return types (#37444)
* Accept change

* Accept the huge set of ever so slightly changed baselines

* Update return type logic to only reuse nodes if original nodes share scope with current node, like property types, only reuse nodes if symbols referened are acessible, reuse nodes for property signatures, too

* Only reuse nodes when a context is provided (otherwise identifier printback may fail)

* Only track symbol if symbol is found and no error is recorded

* Fix type parameter reuse lookup

* Forbid cjs module.exports references in retained nodes

* Adjust check for cjs export references to not include bad module type in output

* Add symbol to all identifiers we see in existing nodes for quickinfo

* Accept fourslash baseline updates

* Accept slightly updated baseline post-merge

* Do not copy original nodes for error types, replace empty type references with any
2020-04-01 19:50:21 -07:00

96 lines
2 KiB
Plaintext

=== tests/cases/conformance/expressions/typeGuards/TypeGuardWithEnumUnion.ts ===
enum Color { R, G, B }
>Color : Color
>R : Color.R
>G : Color.G
>B : Color.B
function f1(x: Color | string) {
>f1 : (x: Color | string) => void
>x : string | Color
if (typeof x === "number") {
>typeof x === "number" : boolean
>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>x : string | Color
>"number" : "number"
var y = x;
>y : Color
>x : Color
var y: Color;
>y : Color
}
else {
var z = x;
>z : string
>x : string
var z: string;
>z : string
}
}
function f2(x: Color | string | string[]) {
>f2 : (x: Color | string | string[]) => void
>x : string | Color | string[]
if (typeof x === "object") {
>typeof x === "object" : boolean
>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>x : string | Color | string[]
>"object" : "object"
var y = x;
>y : string[]
>x : string[]
var y: string[];
>y : string[]
}
if (typeof x === "number") {
>typeof x === "number" : boolean
>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>x : string | Color | string[]
>"number" : "number"
var z = x;
>z : Color
>x : Color
var z: Color;
>z : Color
}
else {
var w = x;
>w : string | string[]
>x : string | string[]
var w: string | string[];
>w : string | string[]
}
if (typeof x === "string") {
>typeof x === "string" : boolean
>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>x : string | Color | string[]
>"string" : "string"
var a = x;
>a : string
>x : string
var a: string;
>a : string
}
else {
var b = x;
>b : Color | string[]
>x : Color | string[]
var b: Color | string[];
>b : Color | string[]
}
}