From 3e2a87c5df99affd8c096b0e5d795d04472258b3 Mon Sep 17 00:00:00 2001 From: HJfod <60038575+HJfod@users.noreply.github.com> Date: Sat, 18 Jan 2025 22:52:25 +0200 Subject: [PATCH] fix old typescript syntax --- src/project/mod.ts | 52 +++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/project/mod.ts b/src/project/mod.ts index 280af4e..2c6caef 100644 --- a/src/project/mod.ts +++ b/src/project/mod.ts @@ -723,14 +723,15 @@ export class ModJsonSuggestionsProvider implements CodeActionProvider { token: CancellationToken ): ProviderResult<(CodeAction | Command)[]> { const modJson = parseTree(document.getText()); + const actions: CodeAction[] = []; function addCorrector, N>( key: string, mapper: (result: N, old: L[0]) => void - ): CodeAction | undefined { + ) { const prop = modJson?.children?.find(c => c.children?.at(0)?.value === key); if (!prop) { - return undefined; + return; } const propValue = prop.children?.at(1); const indentation = document.positionAt(prop.offset).character; @@ -755,33 +756,32 @@ export class ModJsonSuggestionsProvider implements CodeActionProvider { return result; }, {} as N), undefined, indentation).replace(/\n/g, `\n${" ".repeat(indentation)}`) ); - return action; + actions.push(action); } - return undefined; } - return [ - addCorrector("dependencies", (result, dep) => { - // Shorthand - if (dep.importance === "required" && dep.platforms === undefined) { - result[dep.id] = dep.version; - } - // Longhand - else { - result[dep.id] = { - importance: dep.importance, - version: dep.version, - platforms: dep.platforms, - }; - } - }), - addCorrector("incompatibilities", (result, inc) => { - result[inc.id] = { - importance: inc.importance, - version: inc.version, - platforms: inc.platforms, + addCorrector("dependencies", (result, dep) => { + // Shorthand + if (dep.importance === "required" && dep.platforms === undefined) { + result[dep.id] = dep.version; + } + // Longhand + else { + result[dep.id] = { + importance: dep.importance, + version: dep.version, + platforms: dep.platforms, }; - }) - ].filter(v => !!v); + } + }); + addCorrector("incompatibilities", (result, inc) => { + result[inc.id] = { + importance: inc.importance, + version: inc.version, + platforms: inc.platforms, + }; + }); + + return actions; } }