This commit is contained in:
xiaofa
2019-09-17 18:56:19 +08:00
parent 909bc61f01
commit 58e0469252
+2 -2
View File
@@ -7,14 +7,14 @@ namespace ts.codefix {
errorCodes,
getCodeActions: context => {
const { sourceFile, span, program } = context;
const variableStatement = getVaribleStatement(sourceFile, span.start, program);
const variableStatement = getVariableStatement(sourceFile, span.start, program);
const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, variableStatement));
return [createCodeFixAction(fixId, changes, Diagnostics.Convert_const_to_let, fixId, Diagnostics.Convert_const_to_let)];
},
fixIds: [fixId]
});
function getVaribleStatement(sourceFile: SourceFile, pos: number, program: Program) {
function getVariableStatement(sourceFile: SourceFile, pos: number, program: Program) {
const token = getTokenAtPosition(sourceFile, pos);
const checker = program.getTypeChecker();
const symbol = checker.getSymbolAtLocation(token);