-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
Add typescript definition #3509
Conversation
interface Array<T> { | ||
$remove(item: T): Array<T>; | ||
$set(index: any, val: T): T; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, these methods are deprecated on 2.0. We can just remove them.
static compile(template: string): {render: Function, staticRenderFns: Function}; | ||
} | ||
|
||
declare namespace Vue { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we no longer need namespaces for declarations because we can use external module definition format.
Instead of this, I think it would be better to separate files and import the types as needed.
@kaorun343 |
* separate files * remove unnecessary `{[key: string]: any}` * from singular to plural
* Add more definitions * Rename filename and interface * Sort definitions * Fix indent
This is awesome, @kaorun343. I was just thinking the other day how much better Vue'd be with the help of Typescript. Keep it up! 👍 |
I've done my work. |
|
||
export interface ComputedOptions { | ||
get(this: Vue): any; | ||
set(this: Vue, value: any): void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ComputedOptions may have cache: boolean
property. And all options are optional.
@kaorun343 |
I've done 👍 |
Great job 😄 |
render?(createElement: typeof Vue.prototype.$createElement): VNode; | ||
staticRenderFns?: (() => VNode)[]; | ||
|
||
init?(): void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems init
is changed to beforeCreated
. #2873
Great Job! This type definition has very high quality. Kudos to @kaorun343 |
Is this ready? |
Yes! |
Great, can we also add:
|
Manually squashed and merged as dfc64e8 - Thanks for the hard work! |
I have used it locally. There are some issues that block the adoption I think...
For point1 adding a new field is enough. But point2 needs more elaboration. TS cannot export a class as a whole. The workaround hack is |
One workaround is changin import {Vue as _V} from './vue'
declare class Vue extends _V {}
declare namespace Vue {}
export = Vue
This is hideous hack, and TS users must Another way is adding two private fields to Vue: What's your opinions? @yyx990803 @kaorun343 @ktsn |
I think changing index.d.ts is better solution because it can clearly separate the code for adapting Vue's implementation in that file. |
@ktsn You mean change something in Babel preset to support
|
@HerringtonDarkholme |
keyCodes: { [key: string]: number }; | ||
} | ||
|
||
static extend(options: ComponentOptions): Vue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems extend should return typeof Vue
. https://rc.vuejs.org/api/#Vue-extend
This is so nice to have d.ts files in the npm packages (for all central components), I really like the way things a going for Vue, I still miss my constructor for classes, to make TS nicer to dance with :-) But my real issue are, how will a render function look like ? I like to use the new VNode system, from Typescript, but I cant seem to find the prototype anymore (found it in rc7). Also, has anyone tried to use TSX in any of the modes ? |
@druppy Thanks for supporting vue. But github issues are mainly for bug report/ feature request. And please file relevant reviews under a pull request. You can ask question in gitter and forum. And you may also find https://github.com/vuejs/awesome-vue helpful. |
Hi.
This is a definition file for Vue.js 2.0.
I would like to unite the way of providing these definition files, I think, so I took the same way of Vuex.
I referenced a rc.vuejs.org, and it is not complete. These are the TODO List of this.
I hope that this PR will be merged and modified the files to achieve these things by other people.
createElement
and writing the interfaceVNode
and others.vue-class-component
to use this new definition file when this is finishedThanks.