Skip to content

Commit e98fe9e

Browse files
committed
add a note about 2.2 esm config for ts + webpack 2
1 parent 08f08c1 commit e98fe9e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/v2/guide/typescript.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Since these are [published on NPM](https://unpkg.com/vue/types/), you don't even
1414
import Vue = require('vue')
1515
```
1616

17+
<p class="tip">In Vue 2.2.0 we introduced dist files exposed as ES modules, which will be used by default by webpack 2. However, this means if you are using TypeScript with webpack 2, `import Vue = require('vue')` will return an ES module object instead of Vue itself. To fix this, you will need to configure a webpack alias and point `vue` back to `vue/dist/vue[.runtime].common.js`. You will also need to do the same for `vue-router` and `vuex` if you are using them.</p>
18+
1719
Then all methods, properties, and parameters will be type checked. For example, if you misspell the `template` component option as `tempate` (missing the `l`), the TypeScript compiler will print an error message at compile time. If you're using an editor that can lint TypeScript, such as [Visual Studio Code](https://code.visualstudio.com/), you'll even be able to catch these errors before compilation:
1820

1921
![TypeScript Type Error in Visual Studio Code](/images/typescript-type-error.png)

0 commit comments

Comments
 (0)