Closed JAD3N closed 3 years ago
Maybe we should use dts-gen
result as a base instead?
export = whoiser;
declare function whoiser(query: any, options: any): any;
declare namespace whoiser {
function allTlds(): any;
function asn(query: any, { host = null, timeout = 15000, raw = false }: any): any;
function domain(domain: any, { host = null, timeout = 15000, follow = 2, raw = false }: any): any;
function firstResult(whoisResults: any): any;
function ip(query: any, { host = null, timeout = 15000, raw = false }: any): any;
function query({ host = null, port = 43, timeout = 15000, query = '', querySuffix = '\r\n' }: any): any;
function tld(query: any, { timeout = 15000, raw = false }: any): any;
}
Or maybe this should be done like this?
declare module 'whoiser' {
...
export default whoiser;
export {
tld,
allTlds,
ip,
query,
whoiser,
WhoisSearchResult,
Options,
OptionsGeneric,
OptionsIp,
OptionsDomain,
OptionsTld,
OptionsQuery,
OptionsAsn,
};
}
Maybe we should use
dts-gen
result as a base instead?export = whoiser; declare function whoiser(query: any, options: any): any; declare namespace whoiser { function allTlds(): any; function asn(query: any, { host = null, timeout = 15000, raw = false }: any): any; function domain(domain: any, { host = null, timeout = 15000, follow = 2, raw = false }: any): any; function firstResult(whoisResults: any): any; function ip(query: any, { host = null, timeout = 15000, raw = false }: any): any; function query({ host = null, port = 43, timeout = 15000, query = '', querySuffix = '\r\n' }: any): any; function tld(query: any, { timeout = 15000, raw = false }: any): any; }
Or maybe this should be done like this?
declare module 'whoiser' { ... export default whoiser; export { tld, allTlds, ip, query, whoiser, WhoisSearchResult, Options, OptionsGeneric, OptionsIp, OptionsDomain, OptionsTld, OptionsQuery, OptionsAsn, }; }
I believe the inline exports are bit more intuitive than exporting at the end of the file and more preferable than using a namespace. In my project where I'm using whoiser, I override the typings using the ones proposed, so I'm sure there isn't any problem with them specifically.
I'm okay with changing the pull request if the direction is clear, please let me know how to proceed.
I'm not a ts programmer, so that was my mistake. @JAD3N, your pr looks good for me. I think there's no problem with inline exports.
Also it seems modules are better then namespace according to this document https://www.typescriptlang.org/docs/handbook/namespaces-and-modules.html.
I don't know why but it says we recommended modules over namespaces in modern code
.
@JAD3N what have happened? I think this PR is :+1: and have to be merged into the upstream.
@AndreiIgna can you merge this PR? You can do it locally if it's not possible with web. I can create a new one if it's required.
Thanks for the contributions @JAD3N @AKorezin. This is merged and will be released on npm in 1-2 days
A quick fix for the typings.