Skip to content

Commit f541097

Browse files
ktsnyyx990803
authored andcommitted
Expose all types via index.d.ts (vuejs#3608)
* expose all types via index.d.ts * Fix typo
1 parent 63e4757 commit f541097

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

types/index.d.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,33 @@
11
import {Vue as _Vue} from "./vue";
2+
import * as Options from "./options";
3+
import * as Plugin from "./plugin";
4+
import * as VNode from "./vnode";
5+
26
// `Vue` in `export = Vue` must be a namespace
3-
declare namespace Vue {}
7+
// All available types are exported via this namespace
8+
declare namespace Vue {
9+
export type ComponentOptions = Options.ComponentOptions;
10+
export type FunctionalComponentOptions = Options.FunctionalComponentOptions;
11+
export type RenderContext = Options.RenderContext;
12+
export type PropOptions = Options.PropOptions;
13+
export type ComputedOptions = Options.ComputedOptions;
14+
export type WatchHandler = Options.WatchHandler;
15+
export type WatchOptions = Options.WatchOptions;
16+
export type DirectiveFunction = Options.DirectiveFunction;
17+
export type DirectiveOptions = Options.DirectiveOptions;
18+
19+
export type PluginFunction<T> = Plugin.PluginFunction<T>;
20+
export type PluginObject<T> = Plugin.PluginObject<T>;
21+
22+
export type VNodeChildren = VNode.VNodeChildren;
23+
export type VNodeChildrenArrayContents = VNode.VNodeChildrenArrayContents;
24+
export type VNode = VNode.VNode;
25+
export type VNodeComponentOptions = VNode.VNodeComponentOptions;
26+
export type VNodeData = VNode.VNodeData;
27+
export type VNodeDirective = VNode.VNodeDirective;
28+
}
29+
430
// TS cannot merge imported class with namespace, declare a subclass to bypass
531
declare class Vue extends _Vue {}
32+
633
export = Vue;

types/test/options-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Vue = require("../index");
2-
import { ComponentOptions, FunctionalComponentOptions } from "../options";
2+
import { ComponentOptions, FunctionalComponentOptions } from "../index";
33

44
interface Component extends Vue {
55
a: number;

types/test/plugin-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Vue = require("../index");
2-
import { PluginFunction, PluginObject } from "../plugin";
2+
import { PluginFunction, PluginObject } from "../index";
33

44
class Option {
55
prefix: string;

0 commit comments

Comments
 (0)