From b94fd85339dae18c04be4d3f7d0d2a6ea0d4f763 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 21 Jun 2018 21:39:54 -0700 Subject: [PATCH] Added test. --- .../errorsOnWeakTypeIntersectionTargets01.ts | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/cases/compiler/errorsOnWeakTypeIntersectionTargets01.ts diff --git a/tests/cases/compiler/errorsOnWeakTypeIntersectionTargets01.ts b/tests/cases/compiler/errorsOnWeakTypeIntersectionTargets01.ts new file mode 100644 index 00000000000..b64305d4015 --- /dev/null +++ b/tests/cases/compiler/errorsOnWeakTypeIntersectionTargets01.ts @@ -0,0 +1,40 @@ +interface A { + a: number; +} + +interface B { + b?: string; +} + +// 'b' is incompatible. +export let x1: A & B = { + a: 0, + b: 12, +} + +// 'a' is incompatible, 'b' is present and compatible. +export let x2: A & B = { + a: "hello", + b: "hello", +} + +// 'a' is incompatible, 'b' is absent. +export let x3: A & B = { + a: "hello", +} + +// Both 'a' and 'b' are incompatible +export let x4: A & B = { + a: "hello", + b: 0, +} + +// 'b' is compatible, 'a' is missing +export let x5: A & B = { + b: 0, +} + +// 'b' is incompatible, 'a' is missing +export let x6: A & B = { + b: "", +}