Skip to content

Commit

Permalink
chore: enable noUncheckedIndexedAccess in tsconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
cyco130 committed Feb 19, 2024
1 parent df33027 commit d8f2a2e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/cli-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ export async function cli(...args: string[]): Promise<boolean> {
[input, output] = args;
}

if (!input) {
console.error("No input file or directory given");
printUsage();
return false;
}

const inputStat = await stat(input);

if (inputStat.isDirectory()) {
Expand Down
4 changes: 2 additions & 2 deletions src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/) ||
Expand Down Expand Up @@ -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) +
Expand Down
6 changes: 3 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"moduleResolution": "node",
"types": ["node"],
"skipLibCheck": true,
"resolveJsonModule": true
},
"include": ["src/**/*.ts"]
"resolveJsonModule": true,
"noUncheckedIndexedAccess": true
}
}

0 comments on commit d8f2a2e

Please sign in to comment.