From d1393a60d48a7420cc7a38ccead8da4751e8a7d8 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 26 Nov 2016 12:22:29 -0800 Subject: [PATCH] Add regression test --- .../mappedTypeInferenceCircularity.js | 12 +++++++++ .../mappedTypeInferenceCircularity.symbols | 26 ++++++++++++++++++ .../mappedTypeInferenceCircularity.types | 27 +++++++++++++++++++ .../mappedTypeInferenceCircularity.ts | 7 +++++ 4 files changed, 72 insertions(+) create mode 100644 tests/baselines/reference/mappedTypeInferenceCircularity.js create mode 100644 tests/baselines/reference/mappedTypeInferenceCircularity.symbols create mode 100644 tests/baselines/reference/mappedTypeInferenceCircularity.types create mode 100644 tests/cases/compiler/mappedTypeInferenceCircularity.ts diff --git a/tests/baselines/reference/mappedTypeInferenceCircularity.js b/tests/baselines/reference/mappedTypeInferenceCircularity.js new file mode 100644 index 00000000000..d5918d342f6 --- /dev/null +++ b/tests/baselines/reference/mappedTypeInferenceCircularity.js @@ -0,0 +1,12 @@ +//// [mappedTypeInferenceCircularity.ts] +// Repro from #12511 + +type HTML = { [K in 'div']: Block }; +type Block

= (func: HTML) => {}; + +declare var h: HTML; +h.div(h); + +//// [mappedTypeInferenceCircularity.js] +// Repro from #12511 +h.div(h); diff --git a/tests/baselines/reference/mappedTypeInferenceCircularity.symbols b/tests/baselines/reference/mappedTypeInferenceCircularity.symbols new file mode 100644 index 00000000000..33dceb5cd76 --- /dev/null +++ b/tests/baselines/reference/mappedTypeInferenceCircularity.symbols @@ -0,0 +1,26 @@ +=== tests/cases/compiler/mappedTypeInferenceCircularity.ts === +// Repro from #12511 + +type HTML = { [K in 'div']: Block }; +>HTML : Symbol(HTML, Decl(mappedTypeInferenceCircularity.ts, 0, 0)) +>K : Symbol(K, Decl(mappedTypeInferenceCircularity.ts, 2, 15)) +>Block : Symbol(Block, Decl(mappedTypeInferenceCircularity.ts, 2, 42)) +>HTML : Symbol(HTML, Decl(mappedTypeInferenceCircularity.ts, 0, 0)) + +type Block

= (func: HTML) => {}; +>Block : Symbol(Block, Decl(mappedTypeInferenceCircularity.ts, 2, 42)) +>P : Symbol(P, Decl(mappedTypeInferenceCircularity.ts, 3, 11)) +>T : Symbol(T, Decl(mappedTypeInferenceCircularity.ts, 3, 17)) +>func : Symbol(func, Decl(mappedTypeInferenceCircularity.ts, 3, 20)) +>HTML : Symbol(HTML, Decl(mappedTypeInferenceCircularity.ts, 0, 0)) + +declare var h: HTML; +>h : Symbol(h, Decl(mappedTypeInferenceCircularity.ts, 5, 11)) +>HTML : Symbol(HTML, Decl(mappedTypeInferenceCircularity.ts, 0, 0)) + +h.div(h); +>h.div : Symbol(div) +>h : Symbol(h, Decl(mappedTypeInferenceCircularity.ts, 5, 11)) +>div : Symbol(div) +>h : Symbol(h, Decl(mappedTypeInferenceCircularity.ts, 5, 11)) + diff --git a/tests/baselines/reference/mappedTypeInferenceCircularity.types b/tests/baselines/reference/mappedTypeInferenceCircularity.types new file mode 100644 index 00000000000..451da474756 --- /dev/null +++ b/tests/baselines/reference/mappedTypeInferenceCircularity.types @@ -0,0 +1,27 @@ +=== tests/cases/compiler/mappedTypeInferenceCircularity.ts === +// Repro from #12511 + +type HTML = { [K in 'div']: Block }; +>HTML : HTML +>K : K +>Block : Block

+>HTML : HTML + +type Block

= (func: HTML) => {}; +>Block : Block

+>P : P +>T : T +>func : HTML +>HTML : HTML + +declare var h: HTML; +>h : HTML +>HTML : HTML + +h.div(h); +>h.div(h) : {} +>h.div : Block +>h : HTML +>div : Block +>h : HTML + diff --git a/tests/cases/compiler/mappedTypeInferenceCircularity.ts b/tests/cases/compiler/mappedTypeInferenceCircularity.ts new file mode 100644 index 00000000000..56fe08c5fe2 --- /dev/null +++ b/tests/cases/compiler/mappedTypeInferenceCircularity.ts @@ -0,0 +1,7 @@ +// Repro from #12511 + +type HTML = { [K in 'div']: Block }; +type Block

= (func: HTML) => {}; + +declare var h: HTML; +h.div(h); \ No newline at end of file