From 8e47c18636da814117071a2640ccf87c5f16fcfd Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 14 Oct 2017 11:13:52 -0700 Subject: [PATCH] Accept new baselines --- .../reference/mappedTypeWithAny.errors.txt | 31 ++++++++ .../baselines/reference/mappedTypeWithAny.js | 60 +++++++++++++++ .../reference/mappedTypeWithAny.symbols | 71 ++++++++++++++++++ .../reference/mappedTypeWithAny.types | 74 +++++++++++++++++++ 4 files changed, 236 insertions(+) create mode 100644 tests/baselines/reference/mappedTypeWithAny.errors.txt create mode 100644 tests/baselines/reference/mappedTypeWithAny.js create mode 100644 tests/baselines/reference/mappedTypeWithAny.symbols create mode 100644 tests/baselines/reference/mappedTypeWithAny.types diff --git a/tests/baselines/reference/mappedTypeWithAny.errors.txt b/tests/baselines/reference/mappedTypeWithAny.errors.txt new file mode 100644 index 00000000000..0ce53e5044d --- /dev/null +++ b/tests/baselines/reference/mappedTypeWithAny.errors.txt @@ -0,0 +1,31 @@ +tests/cases/conformance/types/mapped/mappedTypeWithAny.ts(23,16): error TS2339: Property 'notAValue' does not exist on type 'Data'. + + +==== tests/cases/conformance/types/mapped/mappedTypeWithAny.ts (1 errors) ==== + 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 + ~~~~~~~~~ +!!! error TS2339: Property 'notAValue' does not exist on type 'Data'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/mappedTypeWithAny.js b/tests/baselines/reference/mappedTypeWithAny.js new file mode 100644 index 00000000000..1e5c662310c --- /dev/null +++ b/tests/baselines/reference/mappedTypeWithAny.js @@ -0,0 +1,60 @@ +//// [mappedTypeWithAny.ts] +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 +} + + +//// [mappedTypeWithAny.js] +"use strict"; +for (var id in z) { + var data = z[id]; + var x = data.notAValue; // Error +} + + +//// [mappedTypeWithAny.d.ts] +declare type Item = { + value: string; +}; +declare 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; +declare type Data = { + value: string; +}; +declare type StrictDataMap = { + [P in keyof T]: Data; +}; +declare let z: StrictDataMap; diff --git a/tests/baselines/reference/mappedTypeWithAny.symbols b/tests/baselines/reference/mappedTypeWithAny.symbols new file mode 100644 index 00000000000..2c204d4b1ef --- /dev/null +++ b/tests/baselines/reference/mappedTypeWithAny.symbols @@ -0,0 +1,71 @@ +=== tests/cases/conformance/types/mapped/mappedTypeWithAny.ts === +type Item = { value: string }; +>Item : Symbol(Item, Decl(mappedTypeWithAny.ts, 0, 0)) +>value : Symbol(value, Decl(mappedTypeWithAny.ts, 0, 13)) + +type ItemMap = { [P in keyof T]: Item }; +>ItemMap : Symbol(ItemMap, Decl(mappedTypeWithAny.ts, 0, 30)) +>T : Symbol(T, Decl(mappedTypeWithAny.ts, 1, 13)) +>P : Symbol(P, Decl(mappedTypeWithAny.ts, 1, 21)) +>T : Symbol(T, Decl(mappedTypeWithAny.ts, 1, 13)) +>Item : Symbol(Item, Decl(mappedTypeWithAny.ts, 0, 0)) + +declare let x0: keyof any; +>x0 : Symbol(x0, Decl(mappedTypeWithAny.ts, 3, 11)) + +declare let x1: { [P in any]: Item }; +>x1 : Symbol(x1, Decl(mappedTypeWithAny.ts, 4, 11)) +>P : Symbol(P, Decl(mappedTypeWithAny.ts, 4, 19)) +>Item : Symbol(Item, Decl(mappedTypeWithAny.ts, 0, 0)) + +declare let x2: { [P in string]: Item }; +>x2 : Symbol(x2, Decl(mappedTypeWithAny.ts, 5, 11)) +>P : Symbol(P, Decl(mappedTypeWithAny.ts, 5, 19)) +>Item : Symbol(Item, Decl(mappedTypeWithAny.ts, 0, 0)) + +declare let x3: { [P in keyof any]: Item }; +>x3 : Symbol(x3, Decl(mappedTypeWithAny.ts, 6, 11)) +>P : Symbol(P, Decl(mappedTypeWithAny.ts, 6, 19)) +>Item : Symbol(Item, Decl(mappedTypeWithAny.ts, 0, 0)) + +declare let x4: ItemMap; +>x4 : Symbol(x4, Decl(mappedTypeWithAny.ts, 7, 11)) +>ItemMap : Symbol(ItemMap, Decl(mappedTypeWithAny.ts, 0, 30)) + +// Repro from #19152 + +type Data = { +>Data : Symbol(Data, Decl(mappedTypeWithAny.ts, 7, 29)) + + value: string; +>value : Symbol(value, Decl(mappedTypeWithAny.ts, 11, 13)) +} + +type StrictDataMap = { +>StrictDataMap : Symbol(StrictDataMap, Decl(mappedTypeWithAny.ts, 13, 1)) +>T : Symbol(T, Decl(mappedTypeWithAny.ts, 15, 19)) + + [P in keyof T]: Data +>P : Symbol(P, Decl(mappedTypeWithAny.ts, 16, 3)) +>T : Symbol(T, Decl(mappedTypeWithAny.ts, 15, 19)) +>Data : Symbol(Data, Decl(mappedTypeWithAny.ts, 7, 29)) +} + +declare let z: StrictDataMap; +>z : Symbol(z, Decl(mappedTypeWithAny.ts, 19, 11)) +>StrictDataMap : Symbol(StrictDataMap, Decl(mappedTypeWithAny.ts, 13, 1)) + +for (let id in z) { +>id : Symbol(id, Decl(mappedTypeWithAny.ts, 20, 8)) +>z : Symbol(z, Decl(mappedTypeWithAny.ts, 19, 11)) + + let data = z[id]; +>data : Symbol(data, Decl(mappedTypeWithAny.ts, 21, 5)) +>z : Symbol(z, Decl(mappedTypeWithAny.ts, 19, 11)) +>id : Symbol(id, Decl(mappedTypeWithAny.ts, 20, 8)) + + let x = data.notAValue; // Error +>x : Symbol(x, Decl(mappedTypeWithAny.ts, 22, 5)) +>data : Symbol(data, Decl(mappedTypeWithAny.ts, 21, 5)) +} + diff --git a/tests/baselines/reference/mappedTypeWithAny.types b/tests/baselines/reference/mappedTypeWithAny.types new file mode 100644 index 00000000000..36fad9140cc --- /dev/null +++ b/tests/baselines/reference/mappedTypeWithAny.types @@ -0,0 +1,74 @@ +=== tests/cases/conformance/types/mapped/mappedTypeWithAny.ts === +type Item = { value: string }; +>Item : Item +>value : string + +type ItemMap = { [P in keyof T]: Item }; +>ItemMap : ItemMap +>T : T +>P : P +>T : T +>Item : Item + +declare let x0: keyof any; +>x0 : string + +declare let x1: { [P in any]: Item }; +>x1 : { [x: string]: Item; } +>P : P +>Item : Item + +declare let x2: { [P in string]: Item }; +>x2 : { [x: string]: Item; } +>P : P +>Item : Item + +declare let x3: { [P in keyof any]: Item }; +>x3 : { [x: string]: Item; } +>P : P +>Item : Item + +declare let x4: ItemMap; +>x4 : ItemMap +>ItemMap : ItemMap + +// Repro from #19152 + +type Data = { +>Data : Data + + value: string; +>value : string +} + +type StrictDataMap = { +>StrictDataMap : StrictDataMap +>T : T + + [P in keyof T]: Data +>P : P +>T : T +>Data : Data +} + +declare let z: StrictDataMap; +>z : StrictDataMap +>StrictDataMap : StrictDataMap + +for (let id in z) { +>id : string +>z : StrictDataMap + + let data = z[id]; +>data : Data +>z[id] : Data +>z : StrictDataMap +>id : string + + let x = data.notAValue; // Error +>x : any +>data.notAValue : any +>data : Data +>notAValue : any +} +