diff --git a/src/v2/guide/typescript.md b/src/v2/guide/typescript.md index 26f5fabb48..d171b167bd 100644 --- a/src/v2/guide/typescript.md +++ b/src/v2/guide/typescript.md @@ -70,6 +70,18 @@ const Component = { } ``` +To use Vue types in an environment without a module bundler, you can create a custom type definition file containing `declare global` (see [Declaration Merging https://www.typescriptlang.org/docs/handbook/declaration-merging.html](https://www.typescriptlang.org/docs/handbook/declaration-merging.html)). + +``` ts +//global.d.ts - name does not matter +import { VueConstructor } from 'vue' + +declare global { + const Vue: VueConstructor +} +``` + + ## Class-Style Vue Components If you prefer a class-based API when declaring components, you can use the officially maintained [vue-class-component](https://github.com/vuejs/vue-class-component) decorator: