Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
Show TS version in ExpectType error (#237)
Browse files Browse the repository at this point in the history
I didn't add a test because tslint doesn't support baselines with
newlines in them. It works locally, though.
  • Loading branch information
sandersn authored Jun 11, 2019
1 parent 7864214 commit 79ef7d1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/rules/expectRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export class Rule extends Lint.Rules.TypedRule {
static FAILURE_STRING_ASSERTION_MISSING_NODE = "Can not match a node to this assertion.";
static FAILURE_STRING_EXPECTED_ERROR = "Expected an error on this line, but found none.";

static FAILURE_STRING(expectedType: string, actualType: string): string {
return `Expected type to be:\n ${expectedType}\ngot:\n ${actualType}`;
static FAILURE_STRING(expectedVersion: string, expectedType: string, actualType: string): string {
return `TypeScript@${expectedVersion} expected type to be:\n ${expectedType}\ngot:\n ${actualType}`;
}

applyWithProgram(sourceFile: SourceFile, lintProgram: Program): Lint.RuleFailure[] {
Expand Down Expand Up @@ -184,7 +184,7 @@ function walk(

const { unmetExpectations, unusedAssertions } = getExpectTypeFailures(sourceFile, typeAssertions, checker, ts);
for (const { node, expected, actual } of unmetExpectations) {
ctx.addFailureAtNode(node, Rule.FAILURE_STRING(expected, actual));
ctx.addFailureAtNode(node, Rule.FAILURE_STRING(versionName, expected, actual));
}
for (const line of unusedAssertions) {
addFailureAtLine(line, Rule.FAILURE_STRING_ASSERTION_MISSING_NODE);
Expand Down

0 comments on commit 79ef7d1

Please sign in to comment.