Skip to content

Commit

Permalink
Expose all types via index.d.ts (#3608)
Browse files Browse the repository at this point in the history
* expose all types via index.d.ts

* Fix typo
  • Loading branch information
ktsn authored and yyx990803 committed Sep 8, 2016
1 parent 63e4757 commit f541097
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
29 changes: 28 additions & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
import {Vue as _Vue} from "./vue";
import * as Options from "./options";
import * as Plugin from "./plugin";
import * as VNode from "./vnode";

// `Vue` in `export = Vue` must be a namespace
declare namespace Vue {}
// All available types are exported via this namespace
declare namespace Vue {
export type ComponentOptions = Options.ComponentOptions;
export type FunctionalComponentOptions = Options.FunctionalComponentOptions;
export type RenderContext = Options.RenderContext;
export type PropOptions = Options.PropOptions;
export type ComputedOptions = Options.ComputedOptions;
export type WatchHandler = Options.WatchHandler;
export type WatchOptions = Options.WatchOptions;
export type DirectiveFunction = Options.DirectiveFunction;
export type DirectiveOptions = Options.DirectiveOptions;

export type PluginFunction<T> = Plugin.PluginFunction<T>;
export type PluginObject<T> = Plugin.PluginObject<T>;

export type VNodeChildren = VNode.VNodeChildren;
export type VNodeChildrenArrayContents = VNode.VNodeChildrenArrayContents;
export type VNode = VNode.VNode;
export type VNodeComponentOptions = VNode.VNodeComponentOptions;
export type VNodeData = VNode.VNodeData;
export type VNodeDirective = VNode.VNodeDirective;
}

// TS cannot merge imported class with namespace, declare a subclass to bypass
declare class Vue extends _Vue {}

export = Vue;
2 changes: 1 addition & 1 deletion types/test/options-test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Vue = require("../index");
import { ComponentOptions, FunctionalComponentOptions } from "../options";
import { ComponentOptions, FunctionalComponentOptions } from "../index";

interface Component extends Vue {
a: number;
Expand Down
2 changes: 1 addition & 1 deletion types/test/plugin-test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Vue = require("../index");
import { PluginFunction, PluginObject } from "../plugin";
import { PluginFunction, PluginObject } from "../index";

class Option {
prefix: string;
Expand Down

0 comments on commit f541097

Please sign in to comment.