Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7a56e55

Browse files
piousonchenxsan
andauthored
docs(config): update typescript setup in configuration-languages.mdx (#6929)
* docs(config): update ts configuration-languages `import *` not required when `esModuleInterop: true` in `tsconfig.json`. ```json { "devDependencies": { "@types/node": "^20.3.1", "@types/webpack": "^5.28.1", "@types/webpack-dev-server": "^4.7.2", "ts-loader": "^9.2.6", "ts-node": "^10.9.1", "typescript": "^5.1.3", "webpack": "^5.88.0", "webpack-cli": "^5.1.4", "webpack-dev-server": "^4.7.4" } } ``` * Update src/content/configuration/configuration-languages.mdx Co-authored-by: Sam Chen <chenxsan@gmail.com> --------- Co-authored-by: Sam Chen <chenxsan@gmail.com>
1 parent 606ca6e commit 7a56e55

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

‎src/content/configuration/configuration-languages.mdx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: Configuration Languages
33
sort: 2
44
contributors:
5+
- piouson
56
- sokra
67
- skipjack
78
- tarang9211
@@ -33,8 +34,8 @@ and then proceed to write your configuration:
3334
**webpack.config.ts**
3435

3536
```typescript
36-
import *aspath from 'path';
37-
import *aswebpack from 'webpack';
37+
import path from 'path';
38+
import webpack from 'webpack';
3839
// in case you run into any typescript error when configuring `devServer`
3940
import 'webpack-dev-server';
4041

@@ -50,6 +51,17 @@ const config: webpack.Configuration = {
5051
export default config;
5152
```
5253

54+
**tsconfig.json**
55+
56+
```json
57+
{
58+
"compilerOptions": {
59+
"allowSyntheticDefaultImports": true,
60+
"esModuleInterop": true
61+
}
62+
}
63+
```
64+
5365
The above sample assumes version >= 2.7 or newer of TypeScript is used with the new `esModuleInterop` and `allowSyntheticDefaultImports` compiler options in your `tsconfig.json` file.
5466

5567
Note that you'll also need to check your `tsconfig.json` file. If the `module` in `compilerOptions` in `tsconfig.json` is `commonjs`, the setting is complete, else webpack will fail with an error. This occurs because `ts-node` does not support any module syntax other than `commonjs`.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /