diff --git a/tests/cases/conformance/types/mapped/mappedTypeConstraints.ts b/tests/cases/conformance/types/mapped/mappedTypeConstraints.ts new file mode 100644 index 00000000000..3710f2b9bef --- /dev/null +++ b/tests/cases/conformance/types/mapped/mappedTypeConstraints.ts @@ -0,0 +1,36 @@ +// @strict: true + +function f0(obj: Pick>) { + obj.b; +} + +function f1(obj: Pick>) { + obj.b; +} + +function f2(obj: Pick) { + obj.b; +} + +function f3(obj: Pick) { + obj.a; + obj.b; + obj.c; +} + +function f4(obj: Record | 'c', string>) { + obj.a; + obj.c; +} + +// Repro from #28821 + +type TargetProps = { + foo: string, + bar: string +}; + +const modifier = (targetProps: T) => { + let {bar, ...rest} = targetProps; + rest.foo; +};