-
Notifications
You must be signed in to change notification settings - Fork 13.4k
API: expose SourceFile#parseDiagnostics #21940
Copy link
Copy link
Closed
Labels
DeclinedThe issue was declined as something which matches the TypeScript visionThe issue was declined as something which matches the TypeScript visionDomain: APIRelates to the public API for TypeScriptRelates to the public API for TypeScriptSuggestionAn idea for TypeScriptAn idea for TypeScript
Metadata
Metadata
Assignees
Labels
DeclinedThe issue was declined as something which matches the TypeScript visionThe issue was declined as something which matches the TypeScript visionDomain: APIRelates to the public API for TypeScriptRelates to the public API for TypeScriptSuggestionAn idea for TypeScriptAn idea for TypeScript
Type
Fields
Give feedbackNo fields configured for issues without a type.
Search Terms: parseDiagnostics
Currently there's no API to directly get the
parseDiagnosticsof a SourceFile.The only possible solution is creating a Program with this SourceFile and call
program.getSyntacticDiagnostics(sourceFile)...This is especially painful when using
ts.parseJsonTextorts.readJsonConfigFilewhere I need to check for parseDiagnostics.Is there a reason this property is internal? Given that it's always set, I think it's safe to expose it.
Related question: why is
getJavaScriptSyntacticDiagnosticsForFiledeclared inprogram.tsand not directly exposed directly? This function doesn't rely on Program, TypeChecker, Resolver, or Binder.If I want all syntax errors of a JavaScript file, I need to create a Program first.
You could resolve both issues by just exposing
getSyntacticDiagnosticsas a function fromprogram.ts(or moving it to a different file).