From ee0715a0736a0aa453b5020432790f07e0eb205f Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 14 Oct 2017 11:13:40 -0700 Subject: [PATCH] Add tests --- .../types/mapped/mappedTypeWithAny.ts | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/cases/conformance/types/mapped/mappedTypeWithAny.ts diff --git a/tests/cases/conformance/types/mapped/mappedTypeWithAny.ts b/tests/cases/conformance/types/mapped/mappedTypeWithAny.ts new file mode 100644 index 00000000000..f8b6f8a39b7 --- /dev/null +++ b/tests/cases/conformance/types/mapped/mappedTypeWithAny.ts @@ -0,0 +1,27 @@ +// @strict: true +// @declaration: true + +type Item = { value: string }; +type ItemMap = { [P in keyof T]: Item }; + +declare let x0: keyof any; +declare let x1: { [P in any]: Item }; +declare let x2: { [P in string]: Item }; +declare let x3: { [P in keyof any]: Item }; +declare let x4: ItemMap; + +// Repro from #19152 + +type Data = { + value: string; +} + +type StrictDataMap = { + [P in keyof T]: Data +} + +declare let z: StrictDataMap; +for (let id in z) { + let data = z[id]; + let x = data.notAValue; // Error +}