From 0002d9553bf67fd31710c1f7fe0359a6db4f98b1 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 12 May 2017 01:38:17 -0700 Subject: [PATCH] Accepted baselines. --- ...teralTypeRelatabilityMessages01.errors.txt | 35 +++++++++++++++++++ .../literalTypeRelatabilityMessages01.js | 29 +++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 tests/baselines/reference/literalTypeRelatabilityMessages01.errors.txt create mode 100644 tests/baselines/reference/literalTypeRelatabilityMessages01.js diff --git a/tests/baselines/reference/literalTypeRelatabilityMessages01.errors.txt b/tests/baselines/reference/literalTypeRelatabilityMessages01.errors.txt new file mode 100644 index 00000000000..01917314f5e --- /dev/null +++ b/tests/baselines/reference/literalTypeRelatabilityMessages01.errors.txt @@ -0,0 +1,35 @@ +tests/cases/compiler/literalTypeRelatabilityMessages01.ts(6,9): error TS2322: Type 'string | number | boolean' is not assignable to type 'number | boolean'. + Type 'boolean' is not assignable to type 'false | 0'. +tests/cases/compiler/literalTypeRelatabilityMessages01.ts(9,9): error TS2322: Type 'number | boolean' is not assignable to type 'true | 1 | "hello"'. + Type 'boolean' is not assignable to type 'true | 1 | "hello"'. +tests/cases/compiler/literalTypeRelatabilityMessages01.ts(13,1): error TS2365: Operator '===' cannot be applied to types 'false | 0' and 'true | 1 | "hello"'. +tests/cases/compiler/literalTypeRelatabilityMessages01.ts(15,1): error TS2365: Operator '===' cannot be applied to types 'true | 1 | "hello"' and 'false | 0'. + + +==== tests/cases/compiler/literalTypeRelatabilityMessages01.ts (4 errors) ==== + declare let a: false | 0; + declare let b: true | 1 | "hello"; + + function nope() { + if (Math.random() < 0.5) { + a = b; + ~ +!!! error TS2322: Type 'string | number | boolean' is not assignable to type 'number | boolean'. +!!! error TS2322: Type 'boolean' is not assignable to type 'false | 0'. + } + else { + b = a; + ~ +!!! error TS2322: Type 'number | boolean' is not assignable to type 'true | 1 | "hello"'. +!!! error TS2322: Type 'boolean' is not assignable to type 'true | 1 | "hello"'. + } + } + + a === b; + ~~~~~~~ +!!! error TS2365: Operator '===' cannot be applied to types 'false | 0' and 'true | 1 | "hello"'. + + b === a; + ~~~~~~~ +!!! error TS2365: Operator '===' cannot be applied to types 'true | 1 | "hello"' and 'false | 0'. + \ No newline at end of file diff --git a/tests/baselines/reference/literalTypeRelatabilityMessages01.js b/tests/baselines/reference/literalTypeRelatabilityMessages01.js new file mode 100644 index 00000000000..dfc824b965f --- /dev/null +++ b/tests/baselines/reference/literalTypeRelatabilityMessages01.js @@ -0,0 +1,29 @@ +//// [literalTypeRelatabilityMessages01.ts] +declare let a: false | 0; +declare let b: true | 1 | "hello"; + +function nope() { + if (Math.random() < 0.5) { + a = b; + } + else { + b = a; + } +} + +a === b; + +b === a; + + +//// [literalTypeRelatabilityMessages01.js] +function nope() { + if (Math.random() < 0.5) { + a = b; + } + else { + b = a; + } +} +a === b; +b === a;