diff --git a/src/cli-lib.ts b/src/cli-lib.ts index b157aa9..9d91fb4 100644 --- a/src/cli-lib.ts +++ b/src/cli-lib.ts @@ -58,6 +58,12 @@ export async function cli(...args: string[]): Promise { [input, output] = args; } + if (!input) { + console.error("No input file or directory given"); + printUsage(); + return false; + } + const inputStat = await stat(input); if (inputStat.isDirectory()) { diff --git a/src/transform.ts b/src/transform.ts index d6ec78b..5b25c6e 100644 --- a/src/transform.ts +++ b/src/transform.ts @@ -172,7 +172,7 @@ async function removeTypes( if (!p.node.leadingComments) return; for (let i = p.node.leadingComments.length - 1; i >= 0; i--) { - const comment = p.node.leadingComments[i]; + const comment = p.node.leadingComments[i]!; if ( code.slice(comment.end).match(/^\s*\n\s*\n/) || @@ -284,7 +284,7 @@ async function removeTypesFromVueSfcScript( const matches = before.match(/\blang\s*=\s*["']ts["']/); if (matches) { - const lastMatch = matches[matches.length - 1]; + const lastMatch = matches[matches.length - 1]!; const lastMatchIndex = before.lastIndexOf(lastMatch); before = before.slice(0, lastMatchIndex) + diff --git a/tsconfig.json b/tsconfig.json index 8b11893..bc1fef6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,7 +8,7 @@ "moduleResolution": "node", "types": ["node"], "skipLibCheck": true, - "resolveJsonModule": true - }, - "include": ["src/**/*.ts"] + "resolveJsonModule": true, + "noUncheckedIndexedAccess": true + } }