getSyntacticDiagnostics
abstract fun getSyntacticDiagnostics(fileName: String): ReadonlyArray<DiagnosticWithLocation>(source)
Gets errors indicating invalid syntax in a file.
In English, "this cdeo have, erorrs" is syntactically invalid because it has typos, grammatical errors, and misplaced punctuation. Likewise, examples of syntax errors in TypeScript are missing parentheses in an if
statement, mismatched curly braces, and using a reserved keyword as a variable name.
These diagnostics are inexpensive to compute and don't require knowledge of other files. Note that a non-empty result increases the likelihood of false positives from getSemanticDiagnostics
.
While these represent the majority of syntax-related diagnostics, there are some that require the type system, which will be present in getSemanticDiagnostics
.
Parameters
fileName
A path to the file you want syntactic diagnostics for