From 97ee9516d671eb52fe96fa6694f6a2bbe12fcf29 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 5 Oct 2017 09:10:55 -0700 Subject: [PATCH] Update baselines --- .../excessPropertyCheckWithUnions.symbols | 144 +++++++++++++ .../excessPropertyCheckWithUnions.types | 196 ++++++++++++++++++ 2 files changed, 340 insertions(+) create mode 100644 tests/baselines/reference/excessPropertyCheckWithUnions.symbols create mode 100644 tests/baselines/reference/excessPropertyCheckWithUnions.types diff --git a/tests/baselines/reference/excessPropertyCheckWithUnions.symbols b/tests/baselines/reference/excessPropertyCheckWithUnions.symbols new file mode 100644 index 00000000000..332166e396c --- /dev/null +++ b/tests/baselines/reference/excessPropertyCheckWithUnions.symbols @@ -0,0 +1,144 @@ +=== tests/cases/compiler/excessPropertyCheckWithUnions.ts === +type ADT = { +>ADT : Symbol(ADT, Decl(excessPropertyCheckWithUnions.ts, 0, 0)) + + tag: "A", +>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 0, 12)) + + a1: string +>a1 : Symbol(a1, Decl(excessPropertyCheckWithUnions.ts, 1, 13)) + +} | { + tag: "D", +>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 3, 5)) + + d20: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 +>d20 : Symbol(d20, Decl(excessPropertyCheckWithUnions.ts, 4, 13)) + +} | { + tag: "T", +>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 6, 5)) +} +let wrong: ADT = { tag: "T", a1: "extra" } +>wrong : Symbol(wrong, Decl(excessPropertyCheckWithUnions.ts, 9, 3)) +>ADT : Symbol(ADT, Decl(excessPropertyCheckWithUnions.ts, 0, 0)) +>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 9, 18)) +>a1 : Symbol(a1, Decl(excessPropertyCheckWithUnions.ts, 9, 28)) + +wrong = { tag: "A", d20: 12 } +>wrong : Symbol(wrong, Decl(excessPropertyCheckWithUnions.ts, 9, 3)) +>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 10, 9)) +>d20 : Symbol(d20, Decl(excessPropertyCheckWithUnions.ts, 10, 19)) + +wrong = { tag: "D" } +>wrong : Symbol(wrong, Decl(excessPropertyCheckWithUnions.ts, 9, 3)) +>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 11, 9)) + +type Ambiguous = { +>Ambiguous : Symbol(Ambiguous, Decl(excessPropertyCheckWithUnions.ts, 11, 20)) + + tag: "A", +>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 13, 18)) + + x: string +>x : Symbol(x, Decl(excessPropertyCheckWithUnions.ts, 14, 13)) + +} | { + tag: "A", +>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 16, 5)) + + y: number +>y : Symbol(y, Decl(excessPropertyCheckWithUnions.ts, 17, 13)) + +} | { + tag: "B", +>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 19, 5)) + + z: boolean +>z : Symbol(z, Decl(excessPropertyCheckWithUnions.ts, 20, 13)) + +} | { + tag: "C" +>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 22, 5)) +} +let amb: Ambiguous +>amb : Symbol(amb, Decl(excessPropertyCheckWithUnions.ts, 25, 3)) +>Ambiguous : Symbol(Ambiguous, Decl(excessPropertyCheckWithUnions.ts, 11, 20)) + +// no error for ambiguous tag, even when it could satisfy both constituents at once +amb = { tag: "A", x: "hi" } +>amb : Symbol(amb, Decl(excessPropertyCheckWithUnions.ts, 25, 3)) +>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 27, 7)) +>x : Symbol(x, Decl(excessPropertyCheckWithUnions.ts, 27, 17)) + +amb = { tag: "A", y: 12 } +>amb : Symbol(amb, Decl(excessPropertyCheckWithUnions.ts, 25, 3)) +>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 28, 7)) +>y : Symbol(y, Decl(excessPropertyCheckWithUnions.ts, 28, 17)) + +amb = { tag: "A", x: "hi", y: 12 } +>amb : Symbol(amb, Decl(excessPropertyCheckWithUnions.ts, 25, 3)) +>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 29, 7)) +>x : Symbol(x, Decl(excessPropertyCheckWithUnions.ts, 29, 17)) +>y : Symbol(y, Decl(excessPropertyCheckWithUnions.ts, 29, 26)) + +// correctly error on excess property 'extra', even when ambiguous +amb = { tag: "A", x: "hi", extra: 12 } +>amb : Symbol(amb, Decl(excessPropertyCheckWithUnions.ts, 25, 3)) +>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 32, 7)) +>x : Symbol(x, Decl(excessPropertyCheckWithUnions.ts, 32, 17)) +>extra : Symbol(extra, Decl(excessPropertyCheckWithUnions.ts, 32, 26)) + +amb = { tag: "A", y: 12, extra: 12 } +>amb : Symbol(amb, Decl(excessPropertyCheckWithUnions.ts, 25, 3)) +>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 33, 7)) +>y : Symbol(y, Decl(excessPropertyCheckWithUnions.ts, 33, 17)) +>extra : Symbol(extra, Decl(excessPropertyCheckWithUnions.ts, 33, 24)) + +// assignability errors still work. +// But note that the error for `z: true` is the fallback one of reporting on +// the last constituent since assignability error reporting can't find a single best discriminant either. +amb = { tag: "A" } +>amb : Symbol(amb, Decl(excessPropertyCheckWithUnions.ts, 25, 3)) +>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 38, 7)) + +amb = { tag: "A", z: true } +>amb : Symbol(amb, Decl(excessPropertyCheckWithUnions.ts, 25, 3)) +>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 39, 7)) +>z : Symbol(z, Decl(excessPropertyCheckWithUnions.ts, 39, 17)) + +type Overlapping = +>Overlapping : Symbol(Overlapping, Decl(excessPropertyCheckWithUnions.ts, 39, 27)) + + | { a: 1, b: 1, first: string } +>a : Symbol(a, Decl(excessPropertyCheckWithUnions.ts, 42, 7)) +>b : Symbol(b, Decl(excessPropertyCheckWithUnions.ts, 42, 13)) +>first : Symbol(first, Decl(excessPropertyCheckWithUnions.ts, 42, 19)) + + | { a: 2, second: string } +>a : Symbol(a, Decl(excessPropertyCheckWithUnions.ts, 43, 7)) +>second : Symbol(second, Decl(excessPropertyCheckWithUnions.ts, 43, 13)) + + | { b: 3, third: string } +>b : Symbol(b, Decl(excessPropertyCheckWithUnions.ts, 44, 7)) +>third : Symbol(third, Decl(excessPropertyCheckWithUnions.ts, 44, 13)) + +let over: Overlapping +>over : Symbol(over, Decl(excessPropertyCheckWithUnions.ts, 45, 3)) +>Overlapping : Symbol(Overlapping, Decl(excessPropertyCheckWithUnions.ts, 39, 27)) + +// these two are not reported because there are two discriminant properties +over = { a: 1, b: 1, first: "ok", second: "error" } +>over : Symbol(over, Decl(excessPropertyCheckWithUnions.ts, 45, 3)) +>a : Symbol(a, Decl(excessPropertyCheckWithUnions.ts, 48, 8)) +>b : Symbol(b, Decl(excessPropertyCheckWithUnions.ts, 48, 14)) +>first : Symbol(first, Decl(excessPropertyCheckWithUnions.ts, 48, 20)) +>second : Symbol(second, Decl(excessPropertyCheckWithUnions.ts, 48, 33)) + +over = { a: 1, b: 1, first: "ok", third: "error" } +>over : Symbol(over, Decl(excessPropertyCheckWithUnions.ts, 45, 3)) +>a : Symbol(a, Decl(excessPropertyCheckWithUnions.ts, 49, 8)) +>b : Symbol(b, Decl(excessPropertyCheckWithUnions.ts, 49, 14)) +>first : Symbol(first, Decl(excessPropertyCheckWithUnions.ts, 49, 20)) +>third : Symbol(third, Decl(excessPropertyCheckWithUnions.ts, 49, 33)) + diff --git a/tests/baselines/reference/excessPropertyCheckWithUnions.types b/tests/baselines/reference/excessPropertyCheckWithUnions.types new file mode 100644 index 00000000000..1d6bdd32eb2 --- /dev/null +++ b/tests/baselines/reference/excessPropertyCheckWithUnions.types @@ -0,0 +1,196 @@ +=== tests/cases/compiler/excessPropertyCheckWithUnions.ts === +type ADT = { +>ADT : ADT + + tag: "A", +>tag : "A" + + a1: string +>a1 : string + +} | { + tag: "D", +>tag : "D" + + d20: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 +>d20 : 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 + +} | { + tag: "T", +>tag : "T" +} +let wrong: ADT = { tag: "T", a1: "extra" } +>wrong : ADT +>ADT : ADT +>{ tag: "T", a1: "extra" } : { tag: "T"; a1: string; } +>tag : string +>"T" : "T" +>a1 : string +>"extra" : "extra" + +wrong = { tag: "A", d20: 12 } +>wrong = { tag: "A", d20: 12 } : { tag: "A"; d20: 12; } +>wrong : ADT +>{ tag: "A", d20: 12 } : { tag: "A"; d20: 12; } +>tag : string +>"A" : "A" +>d20 : number +>12 : 12 + +wrong = { tag: "D" } +>wrong = { tag: "D" } : { tag: "D"; } +>wrong : ADT +>{ tag: "D" } : { tag: "D"; } +>tag : string +>"D" : "D" + +type Ambiguous = { +>Ambiguous : Ambiguous + + tag: "A", +>tag : "A" + + x: string +>x : string + +} | { + tag: "A", +>tag : "A" + + y: number +>y : number + +} | { + tag: "B", +>tag : "B" + + z: boolean +>z : boolean + +} | { + tag: "C" +>tag : "C" +} +let amb: Ambiguous +>amb : Ambiguous +>Ambiguous : Ambiguous + +// no error for ambiguous tag, even when it could satisfy both constituents at once +amb = { tag: "A", x: "hi" } +>amb = { tag: "A", x: "hi" } : { tag: "A"; x: string; } +>amb : Ambiguous +>{ tag: "A", x: "hi" } : { tag: "A"; x: string; } +>tag : string +>"A" : "A" +>x : string +>"hi" : "hi" + +amb = { tag: "A", y: 12 } +>amb = { tag: "A", y: 12 } : { tag: "A"; y: number; } +>amb : Ambiguous +>{ tag: "A", y: 12 } : { tag: "A"; y: number; } +>tag : string +>"A" : "A" +>y : number +>12 : 12 + +amb = { tag: "A", x: "hi", y: 12 } +>amb = { tag: "A", x: "hi", y: 12 } : { tag: "A"; x: string; y: number; } +>amb : Ambiguous +>{ tag: "A", x: "hi", y: 12 } : { tag: "A"; x: string; y: number; } +>tag : string +>"A" : "A" +>x : string +>"hi" : "hi" +>y : number +>12 : 12 + +// correctly error on excess property 'extra', even when ambiguous +amb = { tag: "A", x: "hi", extra: 12 } +>amb = { tag: "A", x: "hi", extra: 12 } : { tag: "A"; x: string; extra: number; } +>amb : Ambiguous +>{ tag: "A", x: "hi", extra: 12 } : { tag: "A"; x: string; extra: number; } +>tag : string +>"A" : "A" +>x : string +>"hi" : "hi" +>extra : number +>12 : 12 + +amb = { tag: "A", y: 12, extra: 12 } +>amb = { tag: "A", y: 12, extra: 12 } : { tag: "A"; y: number; extra: number; } +>amb : Ambiguous +>{ tag: "A", y: 12, extra: 12 } : { tag: "A"; y: number; extra: number; } +>tag : string +>"A" : "A" +>y : number +>12 : 12 +>extra : number +>12 : 12 + +// assignability errors still work. +// But note that the error for `z: true` is the fallback one of reporting on +// the last constituent since assignability error reporting can't find a single best discriminant either. +amb = { tag: "A" } +>amb = { tag: "A" } : { tag: "A"; } +>amb : Ambiguous +>{ tag: "A" } : { tag: "A"; } +>tag : string +>"A" : "A" + +amb = { tag: "A", z: true } +>amb = { tag: "A", z: true } : { tag: "A"; z: true; } +>amb : Ambiguous +>{ tag: "A", z: true } : { tag: "A"; z: true; } +>tag : string +>"A" : "A" +>z : boolean +>true : true + +type Overlapping = +>Overlapping : Overlapping + + | { a: 1, b: 1, first: string } +>a : 1 +>b : 1 +>first : string + + | { a: 2, second: string } +>a : 2 +>second : string + + | { b: 3, third: string } +>b : 3 +>third : string + +let over: Overlapping +>over : Overlapping +>Overlapping : Overlapping + +// these two are not reported because there are two discriminant properties +over = { a: 1, b: 1, first: "ok", second: "error" } +>over = { a: 1, b: 1, first: "ok", second: "error" } : { a: 1; b: 1; first: string; second: string; } +>over : Overlapping +>{ a: 1, b: 1, first: "ok", second: "error" } : { a: 1; b: 1; first: string; second: string; } +>a : number +>1 : 1 +>b : number +>1 : 1 +>first : string +>"ok" : "ok" +>second : string +>"error" : "error" + +over = { a: 1, b: 1, first: "ok", third: "error" } +>over = { a: 1, b: 1, first: "ok", third: "error" } : { a: 1; b: 1; first: string; third: string; } +>over : Overlapping +>{ a: 1, b: 1, first: "ok", third: "error" } : { a: 1; b: 1; first: string; third: string; } +>a : number +>1 : 1 +>b : number +>1 : 1 +>first : string +>"ok" : "ok" +>third : string +>"error" : "error" +