Improve error message for JSXExpressions that are comma expressions

This commit is contained in:
Andrew Branch
2019-05-21 14:21:44 -07:00
parent 77a76c157b
commit feaef9c829
7 changed files with 46 additions and 1 deletions
+18
View File
@@ -582,6 +582,20 @@ namespace FourSlash {
});
}
public verifyErrorExistsAtRange(range: Range, code: number) {
const span = ts.createTextSpanFromRange(range);
const hasMatchingError = ts.some(
this.getDiagnostics(range.fileName),
({ code, start, length }) =>
code === code &&
ts.isNumber(start) && ts.isNumber(length) &&
ts.textSpansEqual(span, { start, length }));
if (!hasMatchingError) {
this.raiseError(`No error with code ${code} found at provided range.`);
}
}
public verifyNumberOfErrorsInCurrentFile(expected: number) {
const errors = this.getDiagnostics(this.activeFile.fileName);
const actual = errors.length;
@@ -3968,6 +3982,10 @@ namespace FourSlashInterface {
this.state.verifyNoErrors();
}
public errorExistsAtRange(range: FourSlash.Range, code: number) {
this.state.verifyErrorExistsAtRange(range, code);
}
public numberOfErrorsInCurrentFile(expected: number) {
this.state.verifyNumberOfErrorsInCurrentFile(expected);
}