From 7ad2661625633f932c76eaca6daca00b0835ce65 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 21 Dec 2018 12:51:01 -0800 Subject: [PATCH] Add tests --- .../types/mapped/mappedTypeConstraints.ts | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/cases/conformance/types/mapped/mappedTypeConstraints.ts 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; +};