TypeScript/tests/baselines/reference/definiteAssignmentOfDestructuredVariable.types
Anders Hejlsberg 7a1c5b7a20
Avoid expensive relationship checking in mapped type member resolution (#36754)
* Avoid expensive relationship checking in mapped type member resolution

* Accept new baselines
2020-02-12 15:05:01 -08:00

38 lines
763 B
Plaintext

=== tests/cases/compiler/definiteAssignmentOfDestructuredVariable.ts ===
// https://github.com/Microsoft/TypeScript/issues/20994
interface Options {
a?: number | object;
>a : number | object | undefined
b: () => void;
>b : () => void
}
class C<T extends Options> {
>C : C<T>
foo!: { [P in keyof T]: T[P] }
>foo : { [P in keyof T]: T[P]; }
method() {
>method : () => void
let { a, b } = this.foo;
>a : T["a"] | undefined
>b : T["b"]
>this.foo : { [P in keyof T]: T[P]; }
>this : this
>foo : { [P in keyof T]: T[P]; }
!(a && b);
>!(a && b) : boolean
>(a && b) : T["b"] | undefined
>a && b : T["b"] | undefined
>a : T["a"] | undefined
>b : T["b"]
a;
>a : T["a"] | undefined
}
}