From 5b5a88fef8340acdf6a3ed7eb5037da877c74d16 Mon Sep 17 00:00:00 2001 From: Evan You Date: Sun, 26 Feb 2017 18:23:47 -0500 Subject: [PATCH] refactor TypeScript typings to use ES style exports --- types/index.d.ts | 62 ++++++++++++++++----------------- types/test/augmentation-test.ts | 2 +- types/test/options-test.ts | 2 +- types/test/plugin-test.ts | 2 +- types/test/vue-test.ts | 2 +- 5 files changed, 34 insertions(+), 36 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index 28350fcfdbe..a9a5b9a7fe0 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -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 = 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 { + CreateElement +} from "./vue"; - export type PluginFunction = Plugin.PluginFunction; - export type PluginObject = Plugin.PluginObject; +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"; diff --git a/types/test/augmentation-test.ts b/types/test/augmentation-test.ts index dd569052be4..a1915c39711 100644 --- a/types/test/augmentation-test.ts +++ b/types/test/augmentation-test.ts @@ -1,4 +1,4 @@ -import Vue = require("../index"); +import Vue from "../index"; declare module "../vue" { // add instance property and method diff --git a/types/test/options-test.ts b/types/test/options-test.ts index 61173c8408c..ab56d378135 100644 --- a/types/test/options-test.ts +++ b/types/test/options-test.ts @@ -1,4 +1,4 @@ -import Vue = require("../index"); +import Vue from "../index"; import { ComponentOptions, FunctionalComponentOptions } from "../index"; interface Component extends Vue { diff --git a/types/test/plugin-test.ts b/types/test/plugin-test.ts index eb1a0d12afa..698864434c6 100644 --- a/types/test/plugin-test.ts +++ b/types/test/plugin-test.ts @@ -1,4 +1,4 @@ -import Vue = require("../index"); +import Vue from "../index"; import { PluginFunction, PluginObject } from "../index"; class Option { diff --git a/types/test/vue-test.ts b/types/test/vue-test.ts index e2f6f38c300..e254ce28bc1 100644 --- a/types/test/vue-test.ts +++ b/types/test/vue-test.ts @@ -1,4 +1,4 @@ -import Vue = require("../index"); +import Vue from "../index"; class Test extends Vue { a: number;