Skip to content

Commit

Permalink
refactor: Deprecate project/sourceFile.getDiagnostics() and `progra…
Browse files Browse the repository at this point in the history
…m.getPreEmitDiagnostics()`.

BREAKING CHANGE: `project/sourceFile.getDiagnostics()` and `program.getPreEmitDiagnostics()` no longer exist. Use `project/sourceFile.getPreEmitDiagnostics()`.
  • Loading branch information
dsherret committed Aug 18, 2018
1 parent efa7616 commit 7e1a21b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 34 deletions.
6 changes: 6 additions & 0 deletions breaking-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ View [CHANGELOG.md](CHANGELOG.md) for more detail on releases. This file is only

## Version 14

### Deprecated `project/sourceFile.getDiagnostics()`

Use `project.getPreEmitDiagnostics()` and `sourceFile.getPreEmitDiagnostics()` instead. Read why in [#384](issues/384).

Also, deprecated `program.getPreEmitDiagnostics()`. It didn't make sense for this method to be on `Program`.

### `BindingNamedNode` now correctly possibly returns a `BindingElement`

For example, given the following code:
Expand Down
12 changes: 0 additions & 12 deletions src/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,18 +394,6 @@ export class Project {
}
}

/**
* Gets the compiler diagnostics.
* @deprecated Use getPreEmitDiagnostics().
*/
getDiagnostics(): Diagnostic[] {
return [
...this.context.program.getSyntacticDiagnostics(),
...this.context.program.getSemanticDiagnostics(),
...this.context.program.getDeclarationDiagnostics()
];
}

/**
* Gets the pre-emit diagnostics.
*/
Expand Down
12 changes: 0 additions & 12 deletions src/compiler/file/SourceFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -771,18 +771,6 @@ export class SourceFile extends SourceFileBase<ts.SourceFile> {
return errors.throwIfNullOrUndefined(this.getDefaultExportSymbol(), "Expected to find a default export symbol");
}

/**
* Gets the syntactic, semantic, and declaration diagnostics.
* @deprecated - Use getPreEmitDiagnostics().
*/
getDiagnostics(): Diagnostic[] {
return [
...this.context.program.getSyntacticDiagnostics(this),
...this.context.program.getSemanticDiagnostics(this),
...this.context.program.getDeclarationDiagnostics(this)
];
}

/**
* Gets the pre-emit diagnostics of the specified source file.
*/
Expand Down
9 changes: 0 additions & 9 deletions src/compiler/tools/Program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,6 @@ export class Program {
return compilerDiagnostics.map(d => this.context.compilerFactory.getDiagnostic(d));
}

/**
* Gets the pre-emit diagnostics.
* @param sourceFile - Source file.
* @deprecated - Call .getPreEmitDiagnostics() on the source file or project instead.
*/
getPreEmitDiagnostics(sourceFile?: SourceFile): Diagnostic[] {
return this.context.getPreEmitDiagnostics(sourceFile);
}

/**
* Gets the emit module resolution kind.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/next-major-deprecations.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Deprecations in the next major

* Project and SourceFile - getDiagnostics()
None.

0 comments on commit 7e1a21b

Please sign in to comment.