TypeScript/tests/baselines/reference/nonNullMappedType.types
Anders Hejlsberg 15fae38b39
Improve narrowing of generic types in control flow analysis (#43183)
* Narrow type variables with union constraints when merited by contextual type

* Narrow generics with union type constraints as indicated by contextual type

* Accept new baselines

* Add tests

* Fix circularity for JSX elements

* Remove unnecessary isConstraintPosition information from flow cache key

* Update comment

* Add additional tests

* Rename to getNarrowableTypeForReference, remove getConstraintForLocation

* Add comment

* Fix removal of undefined in destructurings with initializers

* Use getContextFreeTypeOfExpression in discriminateContextualTypeByObjectMembers

* In obj[x], use constraint of obj's type only when x's type is non-generic

* Add comment
2021-03-19 17:12:57 -07:00

14 lines
382 B
Plaintext

=== tests/cases/compiler/nonNullMappedType.ts ===
function f<A extends string>(p0: { [key in A]: {} | undefined }, p1: A) {
>f : <A extends string>(p0: { [key in A]: {} | undefined; }, p1: A) => void
>p0 : { [key in A]: {} | undefined; }
>p1 : A
const v: {} = p0[p1]!;
>v : {}
>p0[p1]! : {}
>p0[p1] : {} | undefined
>p0 : { [key in A]: {} | undefined; }
>p1 : A
}