mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
PR Feedback
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
/* @internal */
|
||||
/* @internal */
|
||||
namespace ts {
|
||||
export interface CodeFix {
|
||||
name: string;
|
||||
errorCodes: string[];
|
||||
getCodeActions(context: CodeFixContext): CodeAction[];
|
||||
}
|
||||
@@ -14,7 +13,7 @@ namespace ts {
|
||||
newLineCharacter: string;
|
||||
}
|
||||
|
||||
export namespace codeFix {
|
||||
export namespace codefix {
|
||||
const codeFixes: Map<CodeFix[]> = {};
|
||||
|
||||
export function registerCodeFix(action: CodeFix) {
|
||||
@@ -37,8 +36,6 @@ namespace ts {
|
||||
const fixes = codeFixes[context.errorCode];
|
||||
let allActions: CodeAction[] = [];
|
||||
|
||||
Debug.assert(fixes && fixes.length > 0, "No fixes found for error: '${errorCode}'.");
|
||||
|
||||
forEach(fixes, f => {
|
||||
const actions = f.getCodeActions(context);
|
||||
if (actions && actions.length > 0) {
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
///<reference path='..\services.ts' />
|
||||
///<reference path='codeFixProvider.ts' />
|
||||
///<reference path='superFixes.ts' />
|
||||
///<reference path='unusedIdentifierFixes.ts' />
|
||||
///<reference path='changeExtendsToImplementsFix.ts' />
|
||||
///<reference path='interfaceFixes.ts' />
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
/* @internal */
|
||||
namespace ts.codeFix {
|
||||
namespace ts.codefix {
|
||||
function getOpenBraceEnd(constructor: ConstructorDeclaration, sourceFile: SourceFile) {
|
||||
// First token is the open curly, this is where we want to put the 'super' call.
|
||||
return constructor.body.getFirstToken(sourceFile).getEnd();
|
||||
}
|
||||
|
||||
registerCodeFix({
|
||||
name: "AddMissingSuperCallFix",
|
||||
errorCodes: ["TS2377"],
|
||||
errorCodes: [`TS${Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code}`],
|
||||
getCodeActions: (context: CodeFixContext) => {
|
||||
const sourceFile = context.sourceFile;
|
||||
const token = getTokenAtPosition(sourceFile, context.span.start);
|
||||
@@ -22,8 +21,7 @@ namespace ts.codeFix {
|
||||
});
|
||||
|
||||
registerCodeFix({
|
||||
name: "MakeSuperCallTheFirstStatementInTheConstructor",
|
||||
errorCodes: ["TS17009"],
|
||||
errorCodes: [`TS${Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code}`],
|
||||
getCodeActions: (context: CodeFixContext) => {
|
||||
const sourceFile = context.sourceFile;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user