Skip to content

Commit

Permalink
refactor: DiagnosticMessageChain#getNext() now returns an array to …
Browse files Browse the repository at this point in the history
…match TS 3.6.

BREAKING CHANGE: `DiagnosticMessageChain#getNext()` now returns an array to match TS 3.6.
  • Loading branch information
dsherret committed Aug 31, 2019
1 parent f42ff74 commit 4943196
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/compiler/tools/results/DiagnosticMessageChain.ts
@@ -1,3 +1,4 @@
import { IsExact, AssertTrue } from "conditional-type-checks";
import { DiagnosticCategory, ts } from "../../../typescript";

/**
Expand Down Expand Up @@ -27,14 +28,19 @@ export class DiagnosticMessageChain {
}

/**
* Gets th enext diagnostic message chain in the chain.
* Gets the next diagnostic message chains in the chain.
*/
getNext(): DiagnosticMessageChain | undefined {
const next = this.compilerObject.next;
getNext(): DiagnosticMessageChain[] | undefined {
// pre-TS 3.6 this was not an array
type _assertType = AssertTrue<IsExact<ts.DiagnosticMessageChain["next"], ts.DiagnosticMessageChain[] | undefined>>;
const next = this.compilerObject.next as ts.DiagnosticMessageChain | ts.DiagnosticMessageChain[] | undefined;
if (next == null)
return undefined;

return new DiagnosticMessageChain(next);
if (next instanceof Array)
return next.map(n => new DiagnosticMessageChain(n));

return [new DiagnosticMessageChain(next)];
}

/**
Expand Down

0 comments on commit 4943196

Please sign in to comment.