From 0c9d2427ae391df81f849965c1214834a5cb7d05 Mon Sep 17 00:00:00 2001 From: Bartosz Dokurno Date: Sun, 28 Aug 2022 00:42:46 +0200 Subject: [PATCH 1/2] Fix tsconfigs --- src/client/tsconfig.json | 18 ++++++++++++++++++ src/server/tsconfig.json | 21 +++++++++++++++++++++ tsconfig.client.json | 20 -------------------- tsconfig.json | 5 +++++ tsconfig.server.json | 21 --------------------- webpack.config.js | 6 ++++-- 6 files changed, 48 insertions(+), 43 deletions(-) create mode 100644 src/client/tsconfig.json create mode 100644 src/server/tsconfig.json delete mode 100644 tsconfig.client.json create mode 100644 tsconfig.json delete mode 100644 tsconfig.server.json diff --git a/src/client/tsconfig.json b/src/client/tsconfig.json new file mode 100644 index 0000000..319a534 --- /dev/null +++ b/src/client/tsconfig.json @@ -0,0 +1,18 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./public/js/", + "noImplicitAny": true, + "module": "es6", + "moduleResolution": "node", + "target": "es5", + "jsx": "react", + "allowSyntheticDefaultImports": true, + "lib":[ + "es2015", "dom" + ] + }, + "include": [ + "." + ], +} diff --git a/src/server/tsconfig.json b/src/server/tsconfig.json new file mode 100644 index 0000000..fc00e7d --- /dev/null +++ b/src/server/tsconfig.json @@ -0,0 +1,21 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./dist/", + "module": "commonjs", + "target": "es5", + "allowSyntheticDefaultImports": true, + "lib": [ + "es2017" + ], + "types": [ + "node", "express", + ], + "typeRoots": [ + "./src/server/types" + ] + }, + "include": [ + "." + ], +} diff --git a/tsconfig.client.json b/tsconfig.client.json deleted file mode 100644 index 23ddaae..0000000 --- a/tsconfig.client.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "outDir": "./public/js/", - "noImplicitAny": true, - "module": "es6", - "moduleResolution": "node", - "target": "es5", - "jsx": "react", - "allowSyntheticDefaultImports": true, - "lib":[ - "es2015", "dom" - ] - }, - "include": [ - "src/client/**/*" - ], - "exclude": [ - "node_modules" - ] - } \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..4c5fcf7 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,5 @@ +{ + "exclude": [ + "node_modules" + ] +} diff --git a/tsconfig.server.json b/tsconfig.server.json deleted file mode 100644 index d846e75..0000000 --- a/tsconfig.server.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compilerOptions": { - "outDir": "./dist/", - "noImplicitAny": true, - "module": "commonjs", - "target": "es5", - "allowSyntheticDefaultImports": true, - "lib": [ - "es2017" - ], - "types": [ - "node", "express" - ] - }, - "include": [ - "src/server/**/*" - ], - "exclude": [ - "node_modules" - ] - } \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js index ff24ff8..485e226 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -11,7 +11,8 @@ const serverConfig = { loader: 'ts-loader', exclude: /node_modules/, options: { - configFile: 'tsconfig.server.json' + context: path.resolve(__dirname, './src/server'), + configFile: 'tsconfig.json' } } ] @@ -41,7 +42,8 @@ const clientConfig = { loader: 'ts-loader', exclude: /node_modules/, options: { - configFile: 'tsconfig.client.json' + context: path.resolve(__dirname, './src/client'), + configFile: 'tsconfig.json' } }, { From 1ee5808bef43e0664e29532e0b19358cb589b279 Mon Sep 17 00:00:00 2001 From: Bartosz Dokurno Date: Sun, 28 Aug 2022 00:56:08 +0200 Subject: [PATCH 2/2] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 86b7a9e..56f33e8 100644 --- a/README.md +++ b/README.md @@ -162,9 +162,9 @@ This takes the **all** Bootstrap variables _anywhere_ you use it and replaces it - `README.md` the markdown file that displays here in GitHub that you're reading right now. And what I probably use as my "lecture" notes during my videos! -- `tsconfig.client.json` the TypeScript rules our TSC compiler will follow and allow when building our React app. There are several options to play with to standarize `import` statements, allow the use of `any` (don't do this though lol), but make sure not to remove `"jsx": "react",` by mistake or it won't know what you're trying to write in those `.tsx` files! +- `src/client/tsconfig.json` the TypeScript rules our TSC compiler will follow and allow when building our React app. There are several options to play with to standarize `import` statements, allow the use of `any` (don't do this though lol), but make sure not to remove `"jsx": "react",` by mistake or it won't know what you're trying to write in those `.tsx` files! -- `tsconfig.server.json` the same as above, basically, except for our server code. We tell it to include the types for `node` and `express` so it can help us write the basics of our server with improved intellisense support and less manual strong typing. Basically it makes our TSC "infer" some of the basic server types for us automatically. +- `src/server/tsconfig.json` the same as above, basically, except for our server code. We tell it to include the types for `node` and `express` so it can help us write the basics of our server with improved intellisense support and less manual strong typing. Basically it makes our TSC "infer" some of the basic server types for us automatically. - `webpack.config.js` the rules, loaders, and plugins our entire build process follows. There's a lot of stuff _bundled_ 🤣🤣 in this one .. so let's break down the high points in its own subsection below.