[contribution] Typescript definition
See original GitHub issueBelow 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
import Vue from "vue";
declare module "*.vue" {
import Vue from "vue";
export default Vue;
}
declare module 'vue/types/vue' {
// Global properties can be declared
// on the `VueConstructor` interface
import VuejsDialog from 'vuejs-dialog';
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?: DOMElement,
data?: any
}
interface Vue {
$dialog: {
alert(message: string, options?: DialogOptions): DialogResult
confirm(message: string, options?: DialogOptions): DialogResult
},
}
}
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/
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:13 (1 by maintainers)
Top Results From Across the Web
TypeScript/CONTRIBUTING.md at main · microsoft ... - GitHub
TypeScript is currently accepting contributions in the form of bug fixes. A bug must have an issue tracking it in the issue tracker...
Read more >Documentation - Publishing - TypeScript
If your types are generated by your source code, publish the types with your source code. Both TypeScript and JavaScript projects can generate...
Read more >Contributing to DefinitelyTyped for the first time
A guide to add missing type definitions to the DefinitelyTyped repository.
Read more >Learn how to contribute to the TypeScript compiler on GitHub ...
The TypeScript projects requires contributors to sign a Contribution License Agreement (CLA). The CONTRIBUTING.md file contains some guidelines ...
Read more >How to Contribute to Open Source TypeScript Projects
“Beginner” feels accurate when labeling your TypeScript skills. Below are a few examples of things you might contribute to while you are at ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thank you @darrensapalo. I will look at this soon. Really appreciate the time and effort.
After corresponding with @ghard1961 briefly about his issue above, it appears that
Promise<Record<string, unknown>>
is not the appropriate return type there. His screenshot revealed to me that its an object that has close, loading, and data variables in it. Reading through the readme, the return type of the promise is a dialog result object which has the following property/functions:So Instead of using
Promise<Record<string, unknown>>
, I think it would be appropriate to add aDialogResult
interface on the vue.d.ts file, as defined by the specs in the readme:Please see first post for updated example.