Skip to content

Commit 4fc9831

Browse files
committed
Filter + log undefined elements from the codeActions array
1 parent 80a7ed9 commit 4fc9831

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/services/codeFixProvider.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,19 @@ namespace ts {
3636

3737
export function getFixes(context: CodeFixContext): CodeAction[] {
3838
const fixes = codeFixes[context.errorCode];
39-
let allActions: CodeAction[] = [];
39+
const allActions: CodeAction[] = [];
4040

4141
forEach(fixes, f => {
4242
const actions = f.getCodeActions(context);
4343
if (actions && actions.length > 0) {
44-
allActions = allActions.concat(actions);
44+
for (const action of actions) {
45+
if (action === undefined) {
46+
context.host.log(`Action for error code ${context.errorCode} added an invalid action entry; please log a bug`);
47+
}
48+
else {
49+
allActions.push(action);
50+
}
51+
}
4552
}
4653
});
4754

0 commit comments

Comments
 (0)