Merge pull request #17811 from RyanCavanaugh/fix17544

Filter + log undefined elements from the codeActions array
This commit is contained in:
Ryan Cavanaugh 2017-08-29 15:32:44 -07:00 committed by GitHub
commit fa77e141b0

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);
}
}
}
});