You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/guides/typescript.mdx
+27-16Lines changed: 27 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ Now we'll modify the directory structure & the configuration files:
35
35
├── package.json
36
36
├── package-lock.json
37
37
+ ├── tsconfig.json
38
-
- ├── webpack.config.ts
38
+
- ├── webpack.config.js
39
39
+ ├── webpack.config.ts
40
40
├── /dist
41
41
│ ├── bundle.js
@@ -55,12 +55,14 @@ Let's set up a configuration to support JSX and compile TypeScript down to ES5..
55
55
"compilerOptions": {
56
56
"outDir": "./dist/",
57
57
"noImplicitAny": true,
58
-
"module": "es6",
59
-
"target": "es5",
60
-
"jsx": "react",
61
-
"allowJs": true,
62
-
"moduleResolution": "node"
63
-
}
58
+
"module": "esnext",
59
+
"moduleResolution": "bundler",
60
+
"target": "esnext",
61
+
"jsx": "react-jsx",
62
+
"allowJs": true
63
+
},
64
+
"include": ["src/**/*"],
65
+
"exclude": ["node_modules"]
64
66
}
65
67
```
66
68
@@ -116,7 +118,14 @@ export default config;
116
118
117
119
This will direct webpack to _enter_ through `./index.ts`, _load_ all `.ts` and `.tsx` files through the `ts-loader`, and _output_ a `bundle.js` file in our current directory.
118
120
119
-
Now lets change the import of `lodash` in our `./index.ts` due to the fact that there is no default export present in `lodash` definitions.
121
+
Next, we need to adjust how we import `lodash` in our `./index.ts`. Since the lodash definitions don't include a default export, we'll need to update our import statement.
122
+
First, make sure to install the [TypeScript definitions](#using-third-party-libraries):
123
+
124
+
```bash
125
+
npm install --save-dev @types/lodash
126
+
```
127
+
128
+
Then, update your import at the top of the file:
120
129
121
130
**./index.ts**
122
131
@@ -177,7 +186,7 @@ If you use [`compilerOptions.paths`](https://www.typescriptlang.org/tsconfig#pat
0 commit comments