Skip to content
This repository was archived by the owner on May 12, 2025. It is now read-only.

Conversation

arodionov
Copy link
Contributor

If a source file has syntax errors, the ParseError is generated, and the file is skipped from parsing.

Syntactically, the check is based on the TS compiler function ts.getPreEmitDiagnostics.
There is a list of error codes that can be ignored or added.

If a source file has syntax errors, the ParseError is generated, and the file is skipped from parsing.
Syntactically check is based on TS compiler function `ts.getPreEmitDiagnostics`.
There are a list of error codes, that can be ignored or added.
@arodionov arodionov merged commit 473fa06 into main Jan 27, 2025
1 check passed
@arodionov arodionov deleted the syntax-errors branch January 27, 2025 19:50
const syntaxErrors = checkSyntaxErrors(program, sourceFile);
if (syntaxErrors.length > 0) {
syntaxErrors.forEach(
e => result.push(ParseError.build(this, input, relativeTo, ctx, new SyntaxError(`Compiler error: ${e[0]} [${e[1]}]`), null))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this end up creating multiple ParseErrors for one source file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there can be many ParseErrors for one source file

// Other critical errors
]);

const excludedCodes = new Set([1039, 1064, 1101, 1107, 1111, 1155, 1166, 1170, 1183, 1203, 1207, 1215, 1238, 1239, 1240, 1241, 1244, 1250,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there constants with readable names for all these codes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can put here the code description.
The full list is available here https://github.com/microsoft/TypeScript/blob/main/src/compiler/diagnosticMessages.json

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants