TypeScript/tests/cases/compiler/nonNullParameterExtendingStringAssignableToString.ts
Wesley Wigham 66fa9f6cd7
Just map type variables to constraints at certain positions for narrowing so that we do not map primitives (#21384)
* Use a limited version of getApparentType that doesnt map primitives

* Reuse [most of]  getBaseConstraintOfType, since it does the needed behaviors

* Move new function next to the very similar function
2018-02-21 12:51:26 -08:00

9 lines
264 B
TypeScript

// @strict: true
declare function foo(p: string): void;
function fn<T extends string | undefined, U extends string>(one: T, two: U) {
let three = Boolean() ? one : two;
foo(one!);
foo(two!);
foo(three!); // this line is the important one
}