mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 21:06:50 -05:00
Support code-fix-all for importFixes (#25137)
* Support code-fix-all for importFixes * Change description * Update API (#25283)
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
/* @internal */
|
||||
namespace ts {
|
||||
export interface CodeFixRegistration {
|
||||
errorCodes: number[];
|
||||
errorCodes: ReadonlyArray<number>;
|
||||
getCodeActions(context: CodeFixContext): CodeFixAction[] | undefined;
|
||||
fixIds?: string[];
|
||||
fixIds?: ReadonlyArray<string>;
|
||||
getAllCodeActions?(context: CodeFixAllContext): CombinedCodeActions;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace ts {
|
||||
const errorCodeToFixes = createMultiMap<CodeFixRegistration>();
|
||||
const fixIdToRegistration = createMap<CodeFixRegistration>();
|
||||
|
||||
type DiagnosticAndArguments = DiagnosticMessage | [DiagnosticMessage, string] | [DiagnosticMessage, string, string];
|
||||
export type DiagnosticAndArguments = DiagnosticMessage | [DiagnosticMessage, string] | [DiagnosticMessage, string, string];
|
||||
function diagnosticToString(diag: DiagnosticAndArguments): string {
|
||||
return isArray(diag)
|
||||
? formatStringFromArgs(getLocaleSpecificMessage(diag[0]), diag.slice(1) as ReadonlyArray<string>)
|
||||
@@ -89,7 +89,7 @@ namespace ts {
|
||||
return createCombinedCodeActions(changes, commands.length === 0 ? undefined : commands);
|
||||
}
|
||||
|
||||
export function eachDiagnostic({ program, sourceFile, cancellationToken }: CodeFixAllContext, errorCodes: number[], cb: (diag: DiagnosticWithLocation) => void): void {
|
||||
export function eachDiagnostic({ program, sourceFile, cancellationToken }: CodeFixAllContext, errorCodes: ReadonlyArray<number>, cb: (diag: DiagnosticWithLocation) => void): void {
|
||||
for (const diag of program.getSemanticDiagnostics(sourceFile, cancellationToken).concat(computeSuggestionDiagnostics(sourceFile, program, cancellationToken))) {
|
||||
if (contains(errorCodes, diag.code)) {
|
||||
cb(diag as DiagnosticWithLocation);
|
||||
|
||||
Reference in New Issue
Block a user