浏览代码

adapt index.d.ts for end users (#3582)

* adapt index.d.ts for end users

* fix extend return type
wumingyang 9 年之前
父节点
当前提交
4061c42748
共有 6 个文件被更改,包括 10 次插入6 次删除
  1. 1 1
      package.json
  2. 5 1
      types/index.d.ts
  3. 1 1
      types/test/options-test.ts
  4. 1 1
      types/test/plugin-test.ts
  5. 1 1
      types/test/vue-test.ts
  6. 1 1
      types/vue.d.ts

+ 1 - 1
package.json

@@ -3,7 +3,7 @@
   "version": "2.0.0-rc.4",
   "description": "Reactive, component-oriented view layer for modern web interfaces.",
   "main": "dist/vue.common.js",
-  "typings": "index.d.ts",
+  "typings": "types/index.d.ts",
   "files": [
     "dist/vue.common.js",
     "dist/vue.js",

+ 5 - 1
types/index.d.ts

@@ -1,2 +1,6 @@
-import {Vue} from "./vue.d";
+import {Vue as _Vue} from "./vue.d";
+// `Vue` in `export = Vue` must be a namespace
+declare namespace Vue {}
+// TS cannot merge imported class with namespace, declare a subclass to bypass
+declare class Vue extends _Vue {}
 export = Vue;

+ 1 - 1
types/test/options-test.ts

@@ -1,4 +1,4 @@
-import { Vue } from "../vue.d";
+import Vue = require("../index.d");
 import { ComponentOptions } from "../options.d";
 
 interface Component extends Vue {

+ 1 - 1
types/test/plugin-test.ts

@@ -1,4 +1,4 @@
-import { Vue } from "../vue.d";
+import Vue = require("../index.d");
 import { PluginFunction, PluginObject } from "../plugin.d";
 
 class Option {

+ 1 - 1
types/test/vue-test.ts

@@ -1,4 +1,4 @@
-import { Vue } from "../vue.d";
+import Vue = require("../index.d");
 
 class Test extends Vue {
   testProperties() {

+ 1 - 1
types/vue.d.ts

@@ -53,7 +53,7 @@ export declare class Vue {
     keyCodes: { [key: string]: number };
   }
 
-  static extend(options: ComponentOptions): Vue;
+  static extend(options: ComponentOptions): typeof Vue;
   static nextTick(callback: () => void, context?: any[]): void;
   static set<T>(object: Object, key: string, value: T): T;
   static set<T>(array: T[], key: number, value: T): T;