mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Merge pull request #21305 from Microsoft/fix-dt-runner-ExpectError-handling
DT runner:Fix $ExpectError handling
This commit is contained in:
commit
a3ecfd857c
@ -131,13 +131,13 @@ function removeExpectedErrors(errors: string, cwd: string): string {
|
||||
function isUnexpectedError(cwd: string) {
|
||||
return (error: string[]) => {
|
||||
ts.Debug.assertGreaterThanOrEqual(error.length, 1);
|
||||
const match = error[0].match(/(.+\.ts)\((\d+),\d+\): error TS/);
|
||||
const match = error[0].match(/(.+\.tsx?)\((\d+),\d+\): error TS/);
|
||||
if (!match) {
|
||||
return true;
|
||||
}
|
||||
const [, errorFile, lineNumberString] = match;
|
||||
const lines = fs.readFileSync(path.join(cwd, errorFile), { encoding: "utf8" }).split("\n");
|
||||
const lineNumber = parseInt(lineNumberString);
|
||||
const lineNumber = parseInt(lineNumberString) - 1;
|
||||
ts.Debug.assertGreaterThanOrEqual(lineNumber, 0);
|
||||
ts.Debug.assertLessThan(lineNumber, lines.length);
|
||||
const previousLine = lineNumber - 1 > 0 ? lines[lineNumber - 1] : "";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user