Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(config): update typescript setup in configuration-languages.mdx #6929

Merged
merged 2 commits into from
Jun 27, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/content/configuration/configuration-languages.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Configuration Languages
sort: 2
contributors:
- piouson
- sokra
- skipjack
- tarang9211
Expand Down Expand Up @@ -33,8 +34,8 @@ and then proceed to write your configuration:
**webpack.config.ts**

```typescript
import * as path from 'path';
import * as webpack from 'webpack';
import path from 'path';
import webpack from 'webpack';
// in case you run into any typescript error when configuring `devServer`
import 'webpack-dev-server';

Expand All @@ -50,6 +51,15 @@ const config: webpack.Configuration = {
export default config;
```

**tsconfig.json**

```json
{
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
}
piouson marked this conversation as resolved.
Show resolved Hide resolved
```

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.

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`.
Expand Down