8000 fix(types): fix global namespace declaration for UMD bundle by ktsn · Pull Request #9912 · vuejs/vue · GitHub
[go: up one dir, main page]

Skip to content

fix(types): fix global namespace declaration for UMD bundle #9912

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

Merged
merged 3 commits into from
Apr 25, 2019
Merged
Show file tree
Hide file tree
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
Prev Previous commit
Next Next commit
fix(types): expose some types in umd namespace for backward compat
  • Loading branch information
ktsn committed Apr 23, 2019
commit d4893de8454a68be9bc4a1bee05adef202c21cc7
6 changes: 5 additions & 1 deletion types/test/umd-test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const vm = new Vue({
template: '<div>hi</div>'
})
})

const options: Vue.ComponentOptions<Vue> = {
template: '<div>test</div>'
}
45 changes: 44 additions & 1 deletion types/umd.d.ts
Original file line number Diff line number Diff line change
@@ -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 extends Vue = Vue> = V.VueConstructor<V>;

// options.d.ts
export type Component<Data=DefaultData<never>, Methods=DefaultMethods<never>, Computed=DefaultComputed, Props=DefaultProps> = V.Component<Data, Methods, Computed, Props>;
export type AsyncComponent<Data=DefaultData<never>, Methods=DefaultMethods<never>, Computed=DefaultComputed, Props=DefaultProps> = V.AsyncComponent<Data, Methods, Computed, Props>;
export type ComponentOptions<V extends Vue, Data=DefaultData<V>, Methods=DefaultMethods<V>, Computed=DefaultComputed, PropsDef=PropsDefinition<DefaultProps>, Props=DefaultProps> = V.ComponentOptions<V, Data, Methods, Computed, PropsDef, Props>;
export type FunctionalComponentOptions<Props = DefaultProps, PropDefs = PropsDefinition<Props>> = V.FunctionalComponentOptions<Props, PropDefs>;
export type RenderContext<Props=DefaultProps> = V.RenderContext<Props>;
export type PropType<T> = V.PropType<T>;
export type PropOptions<T=any> = V.PropOptions<T>;
export type ComputedOptions<T> = V.ComputedOptions<T>;
export type WatchHandler<T> = V.WatchHandler<T>;
export type WatchOptions = V.WatchOptions;
export type WatchOptionsWithHandler<T> = V.WatchOptionsWithHandler<T>;
export type DirectiveFunction = V.DirectiveFunction;
export type DirectiveOptions = V.DirectiveOptions;

// plugin.d.ts
export type PluginFunction<T> = V.PluginFunction<T>;
export type PluginObject<T> = V.PluginObject<T>;

// 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;

Expand Down
0