Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

API: expose SourceFile#parseDiagnostics #21940

Copy link
Copy link
@ajafff

Description

@ajafff
Issue body actions

Search Terms: parseDiagnostics

Currently there's no API to directly get the parseDiagnostics of 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.parseJsonText or ts.readJsonConfigFile where 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 getJavaScriptSyntacticDiagnosticsForFile declared in program.ts and 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 getSyntacticDiagnostics as a function from program.ts (or moving it to a different file).

Reactions are currently unavailable

Metadata

Metadata

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

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.