From feccd60f42cae6bf169972f7ebbd0149931f6c89 Mon Sep 17 00:00:00 2001 From: seonghyun Date: Fri, 19 Jan 2024 15:10:25 +0900 Subject: [PATCH] Fix typescript error T2339 --- src/commands/editAction.ts | 10 ++++++---- src/wskContent.ts | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/commands/editAction.ts b/src/commands/editAction.ts index ccda424..f038363 100644 --- a/src/commands/editAction.ts +++ b/src/commands/editAction.ts @@ -19,6 +19,7 @@ import * as fs from 'fs'; import * as vscode from 'vscode'; import * as os from 'os'; import * as path from 'path'; +import { Exec } from 'openwhisk'; import { showConfirmMessage } from '../common'; const actionEditMap: { [key: string]: WskAction } = {}; @@ -43,16 +44,17 @@ export async function editAction(action: WskAction): Promise { vscode.window.showErrorMessage("Can't edit sequence action type"); return; } - if (content.exec.binary) { + + if ((content.exec as Exec).binary) { vscode.window.showErrorMessage("Can't edit binary action code"); return; } - if ((content.exec.kind as string) === 'blackbox' && !content.exec.code) { + if ((content.exec.kind as string) === 'blackbox' && !(content.exec as Exec).code) { vscode.window.showErrorMessage("Can't edit blackbox action without action code"); return; } - if (content.exec.code) { - fs.writeFileSync(localFilePath, content.exec.code); + if ((content.exec as Exec).code) { + fs.writeFileSync(localFilePath, (content.exec as Exec).code); } vscode.workspace.openTextDocument(localFilePath).then((textDocument: vscode.TextDocument) => { diff --git a/src/wskContent.ts b/src/wskContent.ts index 0db04c2..9cf29aa 100644 --- a/src/wskContent.ts +++ b/src/wskContent.ts @@ -46,10 +46,10 @@ export class ActionCodeProvider implements vscode.TextDocumentContentProvider { if (content.exec.kind === 'sequence') { return 'Codeview does not support sequence actions.'; } - if ((content.exec.kind as string) === 'blackbox' && !content.exec.code) { + if ((content.exec.kind as string) === 'blackbox' && !(content.exec as openwhisk.Exec).code) { return 'Codeview does not support native docker actions.'; } - return Promise.resolve(content.exec.code); + return Promise.resolve((content.exec as openwhisk.Exec).code); } }