Skip to content
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

Typescript Defnition for Vue.use function doesn't allow for custom parameters #6357

Closed
RizziFrank opened this issue Aug 12, 2017 · 0 comments · Fixed by #6363
Closed

Typescript Defnition for Vue.use function doesn't allow for custom parameters #6357

RizziFrank opened this issue Aug 12, 2017 · 0 comments · Fixed by #6363
Assignees

Comments

@RizziFrank
Copy link

Version

2.4.2

Reproduction link

https://github.com/johnlindquist/vue-typescript-simple

Steps to reproduce

Create a new Vuejs project with Typescript and add a plugin that passes 3 arguments into the use command.

  1. download https://github.com/johnlindquist/vue-typescript-simple

  2. install vue-native-websocket

    npm install vue-native-websocket --save

  3. Add the following lines to src/main.ts:

    import VueNativeSock from 'vue-native-websocket'
    Vue.use(VueNativeSock, 'ws://localhost:9090', { store: store, format: 'json' })

What is expected?

That the vue.d.ts definition for the use function reflects the actual functionality.

What is actually happening?

The vue.d.ts definition only allows for the Plugin object or function and an options object.


The actual function defined in vue/use.js takes in the Plugin object or function and any number of optional parameters, it doesn't actually ask for an options object, that's all up to the Plugin.

My suggestion would be to make the following change:
The vue.d.ts line 101 should be:

static use<T>(plugin: PluginObject<T> | PluginFunction<T>, ...additionalParams: any[]): void;

and not:

static use<T>(plugin: PluginObject<T> | PluginFunction<T>, options?: T): void;

You could have both options available, but the way that the function is written in use.js, the definition I've written above should be more correct.

@HerringtonDarkholme HerringtonDarkholme self-assigned this Aug 14, 2017
HerringtonDarkholme added a commit to HerringtonDarkholme/vue that referenced this issue Aug 14, 2017
change Vue.use to accept more arguments
ztlevi pushed a commit to ztlevi/vue that referenced this issue Feb 14, 2018
f2009 pushed a commit to f2009/vue that referenced this issue Jan 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants