Skip to content

refactor TypeScript typings to use ES style exports #5016

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
62 changes: 30 additions & 32 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
import * as V from "./vue";
import * as Options from "./options";
import * as Plugin from "./plugin";
import * as VNode from "./vnode";
import { Vue } from "./vue";

// `Vue` in `export = Vue` must be a namespace
// All available types are exported via this namespace
declare namespace Vue {
export type CreateElement = V.CreateElement;
export default Vue;

export type Component = Options.Component;
export type AsyncComponent = Options.AsyncComponent;
export type ComponentOptions<V extends Vue> = Options.ComponentOptions<V>;
export type FunctionalComponentOptions = Options.FunctionalComponentOptions;
export type RenderContext = Options.RenderContext;
export type PropOptions = Options.PropOptions;
export type ComputedOptions<V extends Vue> = Options.ComputedOptions<V>;
export type WatchHandler<V extends Vue> = Options.WatchHandler<V, any>;
export type WatchOptions = Options.WatchOptions;
export type DirectiveFunction = Options.DirectiveFunction;
export type DirectiveOptions = Options.DirectiveOptions;
export {
CreateElement
} from "./vue";

export type PluginFunction<T> = Plugin.PluginFunction<T>;
export type PluginObject<T> = Plugin.PluginObject<T>;
export {
Component,
AsyncComponent,
ComponentOptions,
FunctionalComponentOptions,
RenderContext,
PropOptions,
ComputedOptions,
WatchHandler,
WatchOptions,
DirectiveFunction,
DirectiveOptions
} from "./options";

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;
}
export {
PluginFunction,
PluginObject
} from "./plugin";

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

export = Vue;
export {
VNodeChildren,
VNodeChildrenArrayContents,
VNode,
VNodeComponentOptions,
VNodeData,
VNodeDirective
} from "./vnode";
2 changes: 1 addition & 1 deletion types/test/augmentation-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Vue = require("../index");
import Vue from "../index";

declare module "../vue" {
// add instance property and method
Expand Down
2 changes: 1 addition & 1 deletion types/test/options-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Vue = require("../index");
import Vue from "../index";
import { ComponentOptions, FunctionalComponentOptions } from "../index";

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

class Option {
Expand Down
2 changes: 1 addition & 1 deletion types/test/vue-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Vue = require("../index");
import Vue from "../index";

class Test extends Vue {
a: number;
Expand Down