Skip to content

Commit 4061c42

Browse files
HerringtonDarkholmeyyx990803
authored andcommitted
adapt index.d.ts for end users (#3582)
* adapt index.d.ts for end users * fix extend return type
1 parent 5a03f52 commit 4061c42

File tree

6 files changed

+10
-6
lines changed

6 files changed

+10
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "2.0.0-rc.4",
44
"description": "Reactive, component-oriented view layer for modern web interfaces.",
55
"main": "dist/vue.common.js",
6-
"typings": "index.d.ts",
6+
"typings": "types/index.d.ts",
77
"files": [
88
"dist/vue.common.js",
99
"dist/vue.js",

types/index.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
import {Vue} from "./vue.d";
1+
import {Vue as _Vue} from "./vue.d";
2+
// `Vue` in `export = Vue` must be a namespace
3+
declare namespace Vue {}
4+
// TS cannot merge imported class with namespace, declare a subclass to bypass
5+
declare class Vue extends _Vue {}
26
export = Vue;

types/test/options-test.ts

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

44
interface Component extends Vue {

types/test/plugin-test.ts

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

44
class Option {

types/test/vue-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Vue } from "../vue.d";
1+
import Vue = require("../index.d");
22

33
class Test extends Vue {
44
testProperties() {

types/vue.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export declare class Vue {
5353
keyCodes: { [key: string]: number };
5454
}
5555

56-
static extend(options: ComponentOptions): Vue;
56+
static extend(options: ComponentOptions): typeof Vue;
5757
static nextTick(callback: () => void, context?: any[]): void;
5858
static set<T>(object: Object, key: string, value: T): T;
5959
static set<T>(array: T[], key: number, value: T): T;

0 commit comments

Comments
 (0)