Skip to content

Commit

Permalink
Fix TypeScript issues
Browse files Browse the repository at this point in the history
Commander can automatically import files for us by specifying
'executableFile' for commands. This unfortunately doesn't work well with
TypeScript, which was why we were using `node -r ts-node` to run the CLI
instead of `ts-node`. This setup to get commander working was also
causing other issues with file imports.

This commit updates so we now manually import files for commands, which
enables us to revert the less-conventional TypeScript config.
  • Loading branch information
stevehanson committed May 10, 2023
1 parent f7d9cc7 commit aa0e634
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bin/belt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

node -r ts-node/register ./react-native/react-native.ts "$@"
yarn ts-node ./react-native/react-native.ts "$@"
10 changes: 8 additions & 2 deletions react-native/react-native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ program
.description(
"Perform React Native and Expo setup and redundant tasks without your pants falling down!"
)
.command("eslint", "Configure ESLint", { executableFile: "eslint.ts" })
.command("prettier", "Configure Prettier", { executableFile: "prettier.ts" })

.command("eslint")
.description("Configure ESLint")
.action(async () => await import("./eslint"))

.command("prettier")
.description("Configure Prettier")
.action(() => import("./prettier"))
.showHelpAfterError()
.parse();
7 changes: 2 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"lib": ["es2019"],
"target": "es2019",
"module": "commonjs",
"strict": true,
"moduleResolution": "node",
"noImplicitThis": true,
"noUnusedLocals": true,
"strict": true,
"sourceMap": true,
"outDir": "./build",
"skipLibCheck": true,
"types": ["node"]
},
"include": ["./**/*"],
"include": ["./**/*"]
}

0 comments on commit aa0e634

Please sign in to comment.