-
Notifications
You must be signed in to change notification settings - Fork 109
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
[contribution] Typescript definition #51
Comments
Thank you @darrensapalo. I will look at this soon. Really appreciate the time and effort. |
Thank you for your work. 🙂 |
It has been about a year since last update, has this been fixed yet? I can use it in my app by doing (this as any).$dialog.confirm('My message') but its a terrible way of doing things. |
An updated version, including filename: declare module 'vuejs-dialog' {
import { PluginFunction } from 'vue'
export const install: PluginFunction<Record<string, unknown>>
interface DialogOptions {
html?: boolean
loader?: boolean
reverse?: boolean
okText?: string
cancelText?: string
animation?: 'zoom' | 'bounce' | 'fade'
type?: 'basic' | 'soft' | 'hard'
verification?: string
verificationHelp?: string
clicksCount?: number
backdropClose?: true
customClass?: string
}
interface DialogResult {
close?: () => void
loading?: () => void
node?: Element
data?: unknown
}
module 'vue/types/vue' {
interface Vue {
$dialog: {
alert(message: string, options?: DialogOptions): DialogResult
confirm(message: string, options?: DialogOptions): DialogResult
}
}
}
module '@nuxt/types' {
interface NuxtAppOptions {
$dialog: {
alert(message: string, options?: DialogOptions):DialogResult
confirm(message: string, options?: DialogOptions): DialogResult
}
}
}
module 'vuex/types/index' {
interface Store<S> {
$dialog: {
alert(message: string, options?: DialogOptions): DialogResult
confirm(message: string, options?: DialogOptions): DialogResult
}
}
}
} If you havent yet; create a declare module '*.vue' {
import Vue from 'vue'
export default Vue
} Im not sure if -- Edit: Replaced |
this.$dialog this gives me an error: This expression is not callable.
|
I have added your vuejs-dialog.d.ts from above to the project, btw. |
@ghard1961 Double check whether the complaint of your ts compiler is:
If it is the latter, then the type definitions provided for Better for you to set up a reproducible error via stackblitz or jsfiddle so that someone can assist you specifically for the issue you are encountering. |
[cid:[email protected]]
This is what I see. The return type of d has a close argument on it. I include a console.log of the “d” variable here:
[cid:[email protected]]
Perhaps I am missing something, but d having a return type of “Record<string,unknown>” is not accurate?
Thank you for your attention.
Glenn
From: Darren <[email protected]>
Sent: Wednesday, September 23, 2020 12:21 PM
To: Godofbrowser/vuejs-dialog <[email protected]>
Cc: Glenn Hard <[email protected]>; Mention <[email protected]>
Subject: Re: [Godofbrowser/vuejs-dialog] [contribution] Typescript definition (#51)
@ghard1961<https://protect-us.mimecast.com/s/ua2ZCmZ07kSjRGX6fO3sA2?domain=github.com> Double check whether the complaint of your ts compiler is:
1. Not being able to detect this.$dialog.confirm as a missing func definition, or
2. The error is on your line 111, which is d.close(), not having call signatures.
If it is the latter, then the type definitions provided for this.$dialog.confirm() method works as expected. It is your function call of d.close() that is erroneous. From your error message, it appears to be that d is interpreted as an any or type, which prevents the typescript compiler from figuring out what functions are available for that variable. If this is the case- there isn't any issues with the ts definitions suggested above.
Better for you to set up a reproducible error via stackblitz or jsfiddle so that someone can assist you specifically for the issue you are encountering.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<https://protect-us.mimecast.com/s/YMR3ClYk80U2zDGkhGD3hJ?domain=github.com>, or unsubscribe<https://protect-us.mimecast.com/s/Jwc3Cn5mGli76QwxHNJGYn?domain=github.com>.
|
Unfortunately, the images you attached on your mail application doesn't show properly on GitHub where I am reviewing your feedback, so I can't see the images you're sharing. Could you resend that? Let's take a peek. |
Here is the email sent again:
[cid:[email protected]]
This is what I see. The return type of d has a close argument on it. I include a console.log of the “d” variable here:
[cid:[email protected]]
Perhaps I am missing something, but d having a return type of “Record<string,unknown>” is not accurate?
Thank you for your attention.
Glenn
From: Darren <[email protected]<mailto:[email protected]>>
Sent: Wednesday, September 23, 2020 12:21 PM
To: Godofbrowser/vuejs-dialog <[email protected]<mailto:[email protected]>>
Cc: Glenn Hard <[email protected]<mailto:[email protected]>>; Mention <[email protected]<mailto:[email protected]>>
Subject: Re: [Godofbrowser/vuejs-dialog] [contribution] Typescript definition (#51)
@ghard1961<https://protect-us.mimecast.com/s/ua2ZCmZ07kSjRGX6fO3sA2?domain=github.com> Double check whether the complaint of your ts compiler is:
1. Not being able to detect this.$dialog.confirm as a missing func definition, or
2. The error is on your line 111, which is d.close(), not having call signatures.
If it is the latter, then the type definitions provided for this.$dialog.confirm() method works as expected. It is your function call of d.close() that is erroneous. From your error message, it appears to be that d is interpreted as an any or type, which prevents the typescript compiler from figuring out what functions are available for that variable. If this is the case- there isn't any issues with the ts definitions suggested above.
Better for you to set up a reproducible error via stackblitz or jsfiddle so that someone can assist you specifically for the issue you are encountering.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<https://protect-us.mimecast.com/s/YMR3ClYk80U2zDGkhGD3hJ?domain=github.com>, or unsubscribe<https://protect-us.mimecast.com/s/Jwc3Cn5mGli76QwxHNJGYn?domain=github.com>.
From: Darren <[email protected]>
Sent: Wednesday, September 23, 2020 2:06 PM
To: Godofbrowser/vuejs-dialog <[email protected]>
Cc: Glenn Hard <[email protected]>; Mention <[email protected]>
Subject: Re: [Godofbrowser/vuejs-dialog] [contribution] Typescript definition (#51)
Unfortunately, the images you attached on your mail application doesn't show properly on GitHub<https://protect-us.mimecast.com/s/NgFaCQWKAXHkN4oRfx8FIL?domain=github.com> where I am reviewing your feedback, so I can't see the images you're sharing.
Could you resend that? Let's take a peek.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<https://protect-us.mimecast.com/s/iJSDCR6K8XivgP5OcNZufy?domain=github.com>, or unsubscribe<https://protect-us.mimecast.com/s/QndJCVO2JWUxPjgZiypaM8?domain=github.com>.
|
After corresponding with @ghard1961 briefly about his issue above, it appears that
So Instead of using
Please see first post for updated example. |
This vuejs-dialog.d.ts works for me. Thanks for the help! `declare module 'vuejs-dialog' { export const install: PluginFunction<Record<string, unknown>> interface DialogResult { interface DialogOptions { module 'vue/types/vue' { module '@nuxt/types' { module 'vuex/types/index' { |
That did not get stored like i figured it would. Try again here: declare module 'vuejs-dialog' { export const install: PluginFunction<Record<string, unknown>> interface DialogResult { interface DialogOptions { module 'vue/types/vue' { module '@nuxt/types' { module 'vuex/types/index' { |
Below is some unpolished work for the typescript definition of this library.
I am not sure how to contribute to the typescript
@types
npm registry, or how to write it specifically for publishing. Currently, the following code works for my use:filename:
vue-file-import.d.ts
Last updated: September 24, 2020
Dumping a set of resources here for providing typescript definitions:
https://www.detroitlabs.com/blog/2018/02/28/adding-custom-type-definitions-to-a-third-party-library/
The text was updated successfully, but these errors were encountered: