diff --git a/tests/cases/conformance/types/intersection/intersectionsAndEmptyObjects.ts b/tests/cases/conformance/types/intersection/intersectionsAndEmptyObjects.ts index 86ff93281c..2832a3f36b 100644 --- a/tests/cases/conformance/types/intersection/intersectionsAndEmptyObjects.ts +++ b/tests/cases/conformance/types/intersection/intersectionsAndEmptyObjects.ts @@ -1,3 +1,5 @@ +// @target: es2015 + // Empty object type literals are removed from intersections types // that contain other object types @@ -23,3 +25,54 @@ let x11: C & D; let x12: A & B & C & D; let x13: D & E; let x14: A & B & C & D & E; + +// Repro from #20225 + +type Dictionary = { [name: string]: string }; + +const intersectDictionaries = ( + d1: F1, + d2: F2, +): F1 & F2 => Object.assign({}, d1, d2); + +const testDictionary = (_value: T) => { }; + +const d1 = {}; +testDictionary(d1); +const d2 = intersectDictionaries(d1, d1); +testDictionary(d2); + +const d3 = { + s: '', +}; +testDictionary(d3); +const d4 = intersectDictionaries(d1, d3); +testDictionary(d4); +const d5 = intersectDictionaries(d3, d1); +testDictionary(d5); +const d6 = intersectDictionaries(d3, d3); +testDictionary(d6); + +// Repro from #27044 + +type choices = IChoiceList & { + shoes:boolean; + food:boolean; +}; + +type IMyChoiceList = { + car: true +}; + +type IUnknownChoiceList = {}; + +var defaultChoices: choices<{}>; +var defaultChoicesAndEmpty: choices<{} & {}>; + +var myChoices: choices; +var myChoicesAndEmpty: choices; + +var unknownChoices: choices; +var unknownChoicesAndEmpty: choices;