From f3a9cf0dfd1f63d24c11f5ec7aefaa7785777e18 Mon Sep 17 00:00:00 2001 From: Peter Blazejewicz Date: Sun, 18 Mar 2018 19:34:24 +0100 Subject: [PATCH] Update TypeScript configuration example to TS 2.7 The updated snippet uses the same syntax as in any ES6/ES2015 based module imports in vanilla JavaScript thanks to new features from TypeScript 2.7 or newer The relevant not has been added to the sample to mention these new configuration compiler properties. Thanks! --- src/content/configuration/configuration-languages.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/content/configuration/configuration-languages.md b/src/content/configuration/configuration-languages.md index a3ac2379200f..f9f4d4f3413b 100644 --- a/src/content/configuration/configuration-languages.md +++ b/src/content/configuration/configuration-languages.md @@ -26,8 +26,8 @@ and then proceed to write your configuration: __webpack.config.ts__ ```typescript -import * as webpack from 'webpack'; -import * as path from 'path'; +import path from 'path'; +import webpack from 'webpack'; const config: webpack.Configuration = { entry: './foo.js', @@ -40,6 +40,8 @@ const config: webpack.Configuration = { export default config; ``` +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`. There are two solutions to this issue: