From 46f5e5fad14785023e022c88ef09c1637ad5f5f8 Mon Sep 17 00:00:00 2001 From: gcnew Date: Sat, 6 Aug 2016 01:10:02 +0300 Subject: [PATCH] Surface noErrorTruncation option --- src/compiler/commandLineParser.ts | 5 +++++ src/compiler/diagnosticMessages.json | 4 ++++ .../reference/noErrorTruncation.errors.txt | 22 +++++++++++++++++++ .../baselines/reference/noErrorTruncation.js | 21 ++++++++++++++++++ tests/cases/compiler/noErrorTruncation.ts | 15 +++++++++++++ 5 files changed, 67 insertions(+) create mode 100644 tests/baselines/reference/noErrorTruncation.errors.txt create mode 100644 tests/baselines/reference/noErrorTruncation.js create mode 100644 tests/cases/compiler/noErrorTruncation.ts diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 7e2c6eb8d33..c1408187d88 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -126,6 +126,11 @@ namespace ts { type: "boolean", description: Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, }, + { + name: "noErrorTruncation", + type: "boolean", + description: Diagnostics.Do_not_truncate_verbose_types, + }, { name: "noImplicitAny", type: "boolean", diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 8126d5c605e..e3ac2d78c63 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2828,6 +2828,10 @@ "category": "Message", "code": 6137 }, + "Do not truncate verbose types.": { + "category": "Message", + "code": 6138 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", "code": 7005 diff --git a/tests/baselines/reference/noErrorTruncation.errors.txt b/tests/baselines/reference/noErrorTruncation.errors.txt new file mode 100644 index 00000000000..d27fad84e50 --- /dev/null +++ b/tests/baselines/reference/noErrorTruncation.errors.txt @@ -0,0 +1,22 @@ +tests/cases/compiler/noErrorTruncation.ts(10,7): error TS2322: Type 'number' is not assignable to type '{ someLongOptionA: string; } | { someLongOptionB: string; } | { someLongOptionC: string; } | { someLongOptionD: string; } | { someLongOptionE: string; } | { someLongOptionF: string; }'. + + +==== tests/cases/compiler/noErrorTruncation.ts (1 errors) ==== + // @noErrorTruncation + + type SomeLongOptionA = { someLongOptionA: string } + type SomeLongOptionB = { someLongOptionB: string } + type SomeLongOptionC = { someLongOptionC: string } + type SomeLongOptionD = { someLongOptionD: string } + type SomeLongOptionE = { someLongOptionE: string } + type SomeLongOptionF = { someLongOptionF: string } + + const x: SomeLongOptionA + ~ +!!! error TS2322: Type 'number' is not assignable to type '{ someLongOptionA: string; } | { someLongOptionB: string; } | { someLongOptionC: string; } | { someLongOptionD: string; } | { someLongOptionE: string; } | { someLongOptionF: string; }'. + | SomeLongOptionB + | SomeLongOptionC + | SomeLongOptionD + | SomeLongOptionE + | SomeLongOptionF = 42; + \ No newline at end of file diff --git a/tests/baselines/reference/noErrorTruncation.js b/tests/baselines/reference/noErrorTruncation.js new file mode 100644 index 00000000000..70bbc6bd8dc --- /dev/null +++ b/tests/baselines/reference/noErrorTruncation.js @@ -0,0 +1,21 @@ +//// [noErrorTruncation.ts] +// @noErrorTruncation + +type SomeLongOptionA = { someLongOptionA: string } +type SomeLongOptionB = { someLongOptionB: string } +type SomeLongOptionC = { someLongOptionC: string } +type SomeLongOptionD = { someLongOptionD: string } +type SomeLongOptionE = { someLongOptionE: string } +type SomeLongOptionF = { someLongOptionF: string } + +const x: SomeLongOptionA + | SomeLongOptionB + | SomeLongOptionC + | SomeLongOptionD + | SomeLongOptionE + | SomeLongOptionF = 42; + + +//// [noErrorTruncation.js] +// @noErrorTruncation +var x = 42; diff --git a/tests/cases/compiler/noErrorTruncation.ts b/tests/cases/compiler/noErrorTruncation.ts new file mode 100644 index 00000000000..5bd6ecf1d74 --- /dev/null +++ b/tests/cases/compiler/noErrorTruncation.ts @@ -0,0 +1,15 @@ +// @noErrorTruncation + +type SomeLongOptionA = { someLongOptionA: string } +type SomeLongOptionB = { someLongOptionB: string } +type SomeLongOptionC = { someLongOptionC: string } +type SomeLongOptionD = { someLongOptionD: string } +type SomeLongOptionE = { someLongOptionE: string } +type SomeLongOptionF = { someLongOptionF: string } + +const x: SomeLongOptionA + | SomeLongOptionB + | SomeLongOptionC + | SomeLongOptionD + | SomeLongOptionE + | SomeLongOptionF = 42;