From 27ee37ef5ebb4c9580c46191dcebd79f049f0c75 Mon Sep 17 00:00:00 2001 From: ktsn Date: Tue, 23 Apr 2019 20:58:53 +0800 Subject: [PATCH 1/3] fix(types): fix global namespace declaration for UMD bundle --- types/index.d.ts | 3 +-- types/test/tsconfig.json | 14 +++----------- types/test/umd-test.ts | 3 +++ types/umd.d.ts | 5 +++++ 4 files changed, 12 insertions(+), 13 deletions(-) create mode 100644 types/test/umd-test.ts create mode 100644 types/umd.d.ts diff --git a/types/index.d.ts b/types/index.d.ts index b0e24d767e9..58ceb209e5d 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,9 +1,8 @@ import { Vue } from "./vue"; +import "./umd"; export default Vue; -export as namespace Vue; - export { CreateElement, VueConstructor diff --git a/types/test/tsconfig.json b/types/test/tsconfig.json index b816ce07cdc..dab30a608bf 100644 --- a/types/test/tsconfig.json +++ b/types/test/tsconfig.json @@ -14,17 +14,9 @@ "vue": ["../index.d.ts"] } }, - "files": [ - "../index.d.ts", - "../options.d.ts", - "../plugin.d.ts", - "../vnode.d.ts", - "../vue.d.ts", - "options-test.ts", - "plugin-test.ts", - "vue-test.ts", - "augmentation-test.ts", - "ssr-test.ts" + "include": [ + "../*.d.ts", + "*.ts" ], "compileOnSave": false } diff --git a/types/test/umd-test.ts b/types/test/umd-test.ts new file mode 100644 index 00000000000..1f06e87b750 --- /dev/null +++ b/types/test/umd-test.ts @@ -0,0 +1,3 @@ +const vm = new Vue({ + template: '
hi
' +}) \ No newline at end of file diff --git a/types/umd.d.ts b/types/umd.d.ts new file mode 100644 index 00000000000..6c85f6b7b86 --- /dev/null +++ b/types/umd.d.ts @@ -0,0 +1,5 @@ +import { Vue } from "./vue"; + +export = Vue; + +export as namespace Vue; From d4893de8454a68be9bc4a1bee05adef202c21cc7 Mon Sep 17 00:00:00 2001 From: ktsn Date: Tue, 23 Apr 2019 21:40:48 +0800 Subject: [PATCH 2/3] fix(types): expose some types in umd namespace for backward compat --- types/test/umd-test.ts | 6 +++++- types/umd.d.ts | 45 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/types/test/umd-test.ts b/types/test/umd-test.ts index 1f06e87b750..afa5bce234b 100644 --- a/types/test/umd-test.ts +++ b/types/test/umd-test.ts @@ -1,3 +1,7 @@ const vm = new Vue({ template: '
hi
' -}) \ No newline at end of file +}) + +const options: Vue.ComponentOptions = { + template: '
test
' +} \ No newline at end of file diff --git a/types/umd.d.ts b/types/umd.d.ts index 6c85f6b7b86..618d484e48d 100644 --- a/types/umd.d.ts +++ b/types/umd.d.ts @@ -1,4 +1,47 @@ -import { Vue } from "./vue"; +import * as V from "./index"; +import { + DefaultData, + DefaultProps, + DefaultMethods, + DefaultComputed, + PropsDefinition +} from "./options"; + +// Expose some types for backword compatibility... +declare namespace Vue { + // vue.d.ts + export type CreateElement = V.CreateElement; + export type VueConstructor = V.VueConstructor; + + // options.d.ts + export type Component, Methods=DefaultMethods, Computed=DefaultComputed, Props=DefaultProps> = V.Component; + export type AsyncComponent, Methods=DefaultMethods, Computed=DefaultComputed, Props=DefaultProps> = V.AsyncComponent; + export type ComponentOptions, Methods=DefaultMethods, Computed=DefaultComputed, PropsDef=PropsDefinition, Props=DefaultProps> = V.ComponentOptions; + export type FunctionalComponentOptions> = V.FunctionalComponentOptions; + export type RenderContext = V.RenderContext; + export type PropType = V.PropType; + export type PropOptions = V.PropOptions; + export type ComputedOptions = V.ComputedOptions; + export type WatchHandler = V.WatchHandler; + export type WatchOptions = V.WatchOptions; + export type WatchOptionsWithHandler = V.WatchOptionsWithHandler; + export type DirectiveFunction = V.DirectiveFunction; + export type DirectiveOptions = V.DirectiveOptions; + + // plugin.d.ts + export type PluginFunction = V.PluginFunction; + export type PluginObject = V.PluginObject; + + // vnode.d.ts + export type VNodeChildren = V.VNodeChildren; + export type VNodeChildrenArrayContents = V.VNodeChildrenArrayContents; + export type VNode = V.VNode; + export type VNodeComponentOptions = V.VNodeComponentOptions; + export type VNodeData = V.VNodeData; + export type VNodeDirective = V.VNodeDirective; +} + +declare class Vue extends V.default {} export = Vue; From db916fb822f981c5a32482d242ba8caf66fb17a6 Mon Sep 17 00:00:00 2001 From: ktsn Date: Wed, 24 Apr 2019 14:56:30 +0800 Subject: [PATCH 3/3] refactor(types): update code style --- types/test/umd-test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/test/umd-test.ts b/types/test/umd-test.ts index afa5bce234b..ffdc7046f92 100644 --- a/types/test/umd-test.ts +++ b/types/test/umd-test.ts @@ -1,7 +1,7 @@ const vm = new Vue({ - template: '
hi
' -}) + template: "
hi
" +}); const options: Vue.ComponentOptions = { - template: '
test
' -} \ No newline at end of file + template: "
test
" +};