Filter + log undefined elements from the codeActions array

This commit is contained in:
Ryan Cavanaugh
2017-08-15 10:35:15 -07:00
parent 80a7ed9a42
commit 4fc9831a43

View File

@@ -36,12 +36,19 @@ namespace ts {
export function getFixes(context: CodeFixContext): CodeAction[] {
const fixes = codeFixes[context.errorCode];
let allActions: CodeAction[] = [];
const allActions: CodeAction[] = [];
forEach(fixes, f => {
const actions = f.getCodeActions(context);
if (actions && actions.length > 0) {
allActions = allActions.concat(actions);
for (const action of actions) {
if (action === undefined) {
context.host.log(`Action for error code ${context.errorCode} added an invalid action entry; please log a bug`);
}
else {
allActions.push(action);
}
}
}
});